MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / gds__ulstr

Function gds__ulstr

src/yvalve/gds.cpp:441–467  ·  view source on GitHub ↗

This function is very crude, but signal-safe. CVC: This function converts a FB_UINT64 into a string. I renamed the param maxlen to minlen because it represents the minimum length the number will be printed in. However, this means buffer should be large enough to contain any ULONG (11 bytes) and thus prevent a buffer overflow. If minlen >= 11, then buffer should have be of size = (minlen + 1).

Source from the content-addressed store, hash-verified

439// any ULONG (11 bytes) and thus prevent a buffer overflow. If minlen >= 11,
440// then buffer should have be of size = (minlen + 1).
441void gds__ulstr(char* buffer, FB_UINT64 value, const int minlen, const char filler)
442{
443 FB_UINT64 n = value;
444
445 int c = 0;
446 do {
447 n = n / 10;
448 c++;
449 } while (n);
450
451 if (minlen > c)
452 c = minlen;
453
454 char* p = buffer + c;
455
456 do {
457 *--p = '0' + (value % 10);
458 value = value / 10;
459 } while (value);
460
461 fb_assert(p >= buffer); // did we overflow?
462
463 while (p != buffer) {
464 *--p = filler;
465 }
466 buffer[c] = 0;
467}
468
469
470ISC_STATUS API_ROUTINE gds__decode(ISC_STATUS code, USHORT* fac, USHORT* code_class)

Callers 3

write_pageFunction · 0.85
API_ROUTINE gds__traceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected