Index: snprintf.c =================================================================== --- snprintf.c (revision 6342) +++ snprintf.c (working copy) @@ -87,6 +87,9 @@ * Martin Pool (mbp@samba.org) May 2003 * Put in a prototype for dummy_snprintf() to quiet compiler warnings. * + * Sean Young (sean@mess.org) April 2005 + * fmtint() had a too smaller buffer to format ULLONG_MAX. + * * Move #endif to make sure VA_COPY, LDOUBLE, etc are defined even * if the C library has some snprintf functions already. **************************************************************/ @@ -198,7 +201,7 @@ static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, char *value, int flags, int min, int max); static void fmtint(char *buffer, size_t *currlen, size_t maxlen, - long value, int base, int min, int max, int flags); + LLONG value, int base, int min, int max, int flags); static void fmtfp(char *buffer, size_t *currlen, size_t maxlen, LDOUBLE fvalue, int min, int max, int flags); static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c); @@ -505,11 +508,11 @@ /* Have to handle DP_F_NUM (ie 0x and 0 alternates) */ static void fmtint(char *buffer, size_t *currlen, size_t maxlen, - long value, int base, int min, int max, int flags) + LLONG value, int base, int min, int max, int flags) { int signvalue = 0; - unsigned long uvalue; - char convert[20]; + LLONG uvalue; + char convert[21]; int place = 0; int spadlen = 0; /* amount to space pad */ int zpadlen = 0; /* amount to zero pad */ @@ -537,10 +540,10 @@ do { convert[place++] = (caps? "0123456789ABCDEF":"0123456789abcdef") - [uvalue % (unsigned)base ]; - uvalue = (uvalue / (unsigned)base ); - } while(uvalue && (place < 20)); - if (place == 20) place--; + [uvalue % (unsigned LLONG)base ]; + uvalue = (uvalue / (unsigned LLONG)base ); + } while(uvalue && (place < sizeof(convert))); + if (place == sizeof(convert)) place--; convert[place] = 0; zpadlen = max - place;