]> andersk Git - openssh.git/commitdiff
- (dtucker) [openbsd-compat/bsd-snprintf.c] Static declarations for public
authordtucker <dtucker>
Tue, 23 Jan 2007 13:07:29 +0000 (13:07 +0000)
committerdtucker <dtucker>
Tue, 23 Jan 2007 13:07:29 +0000 (13:07 +0000)
   library interfaces aren't very helpful. Fix up the DOPR_OUTCH macro
   so it works properly and modify its callers so that they don't pre or
   post decrement arguments that are conditionally evaluated. While there,
   put SNPRINTF_CONST back as it prevents build failures in some
   configurations.  ok djm@ (for most of it)

ChangeLog
openbsd-compat/bsd-snprintf.c

index 53e08ddd6944e7dc938da900a8979238479fba39..cffddac172eaea9d1fee78e3b63e8c43757fe682 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+20070123
+ - (dtucker) [openbsd-compat/bsd-snprintf.c] Static declarations for public
+   library interfaces aren't very helpful. Fix up the DOPR_OUTCH macro
+   so it works properly and modify its callers so that they don't pre or
+   post decrement arguments that are conditionally evaluated. While there,
+   put SNPRINTF_CONST back as it prevents build failures in some
+   configurations.  ok djm@ (for most of it)
+
 20070122
  - (djm) [ssh-rand-helper.8] manpage nits;
    from dleonard AT vintela.com (bz#1529)
index cefb1d1add510e5dac3d69233b7a61ed05040711..41d2be23899c14414f28397a307626702cae8d5e 100644 (file)
 
 #define DOPR_OUTCH(buf, pos, buflen, thechar) \
        do { \
-               if (++pos >= INT_MAX) { \
+               if (pos + 1 >= INT_MAX) { \
                        errno = ERANGE; \
                        return -1; \
+               } \
                if (pos < buflen) \
                        buf[pos] = thechar; \
-               } \
+               (pos)++; \
        } while (0)
 
 static int dopr(char *buffer, size_t maxlen, const char *format, 
@@ -494,7 +495,8 @@ fmtstr(char *buffer, size_t *currlen, size_t maxlen,
                ++cnt;
        }
        while (*value && (cnt < max)) {
-               DOPR_OUTCH(buffer, *currlen, maxlen, *value++);
+               DOPR_OUTCH(buffer, *currlen, maxlen, *value);
+               *value++;
                ++cnt;
        }
        while ((padlen < 0) && (cnt < max)) {
@@ -582,8 +584,10 @@ fmtint(char *buffer, size_t *currlen, size_t maxlen,
        }
 
        /* Digits */
-       while (place > 0) 
-               DOPR_OUTCH(buffer, *currlen, maxlen, convert[--place]);
+       while (place > 0) {
+               --place;
+               DOPR_OUTCH(buffer, *currlen, maxlen, convert[place]);
+       }
   
        /* Left Justified spaces */
        while (spadlen < 0) {
@@ -788,8 +792,10 @@ fmtfp (char *buffer, size_t *currlen, size_t maxlen,
        if (signvalue) 
                DOPR_OUTCH(buffer, *currlen, maxlen, signvalue);
        
-       while (iplace > 0) 
-               DOPR_OUTCH(buffer, *currlen, maxlen, iconvert[--iplace]);
+       while (iplace > 0) {
+               --iplace;
+               DOPR_OUTCH(buffer, *currlen, maxlen, iconvert[iplace]);
+       }
 
 #ifdef DEBUG_SNPRINTF
        printf("fmtfp: fplace=%d zpadlen=%d\n", fplace, zpadlen);
@@ -807,9 +813,10 @@ fmtfp (char *buffer, size_t *currlen, size_t maxlen,
                        --zpadlen;
                }
 
-               while (fplace > 0) 
-                       DOPR_OUTCH(buffer, *currlen, maxlen,
-                           fconvert[--fplace]);
+               while (fplace > 0) {
+                       --fplace;
+                       DOPR_OUTCH(buffer, *currlen, maxlen, fconvert[fplace]);
+               }
        }
 
        while (padlen < 0) {
@@ -821,7 +828,7 @@ fmtfp (char *buffer, size_t *currlen, size_t maxlen,
 #endif /* !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) */
 
 #if !defined(HAVE_VSNPRINTF)
-static int
+int
 vsnprintf (char *str, size_t count, const char *fmt, va_list args)
 {
        return dopr(str, count, fmt, args);
@@ -829,8 +836,8 @@ vsnprintf (char *str, size_t count, const char *fmt, va_list args)
 #endif
 
 #if !defined(HAVE_SNPRINTF)
-static int
-snprintf(char *str, size_t count, const char *fmt, ...)
+int
+snprintf(char *str, size_t count, SNPRINTF_CONST char *fmt, ...)
 {
        size_t ret;
        va_list ap;
This page took 0.096485 seconds and 5 git commands to generate.