summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-02-21 18:47:21 +0000
committerJeremy Allison <jra@samba.org>2000-02-21 18:47:21 +0000
commited95d8ed4f3281b62dc38f5f9004dbe72102bed7 (patch)
treefd8576628ddd89c78897ea61c2317e3b5c246767
parent0e004212d25ebee5db7b27e017ddb1015f4c2a7e (diff)
downloadsamba-ed95d8ed4f3281b62dc38f5f9004dbe72102bed7.tar.gz
samba-ed95d8ed4f3281b62dc38f5f9004dbe72102bed7.tar.bz2
samba-ed95d8ed4f3281b62dc38f5f9004dbe72102bed7.zip
Fix for crash bug from Paul Tyler <pct@ansto.gov.au>.
Jeremy. (This used to be commit 89aa4d8ca9cc9e8e6dd4566076c0cace8b82d838)
-rw-r--r--source3/lib/snprintf.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/source3/lib/snprintf.c b/source3/lib/snprintf.c
index 5409598548..70ce95916f 100644
--- a/source3/lib/snprintf.c
+++ b/source3/lib/snprintf.c
@@ -694,8 +694,7 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
if ( r_length < dec_pt )
dec_pt = r_length;
- if (dec_pt <= 0)
- {
+ if (dec_pt <= 0) {
iplace = 1;
iconvert[0] = '0';
iconvert[1] = '\0';
@@ -705,22 +704,24 @@ static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
while(r_length)
fconvert[fplace++] = result[--r_length];
- while(dec_pt < 0)
- fconvert[fplace++] = '0';
- }
- else
- {
+ while ((dec_pt < 0) && (fplace < max)) {
+ fconvert[fplace++] = '0';
+ dec_pt++;
+ }
+ } else {
int c;
iplace=0;
- for(c=dec_pt; c; iconvert[iplace++] = result[--c]);
+ for(c=dec_pt; c; iconvert[iplace++] = result[--c])
+ ;
iconvert[iplace] = '\0';
result += dec_pt;
fplace = 0;
- for(c=(r_length-dec_pt); c; fconvert[fplace++] = result[--c]);
- }
+ for(c=(r_length-dec_pt); c; fconvert[fplace++] = result[--c])
+ ;
+ }
#endif /* fcvt */
/* -1 for decimal point, another -1 if we are printing a sign */