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).
| 439 | // any ULONG (11 bytes) and thus prevent a buffer overflow. If minlen >= 11, |
| 440 | // then buffer should have be of size = (minlen + 1). |
| 441 | void 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 | |
| 470 | ISC_STATUS API_ROUTINE gds__decode(ISC_STATUS code, USHORT* fac, USHORT* code_class) |
no outgoing calls
no test coverage detected