summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--openbsd-compat/bsd-snprintf.c33
2 files changed, 29 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index dd8bd3561..7dd2e4ab8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
120070123
2 - (dtucker) [openbsd-compat/bsd-snprintf.c] Static declarations for public
3 library interfaces aren't very helpful. Fix up the DOPR_OUTCH macro
4 so it works properly and modify its callers so that they don't pre or
5 post decrement arguments that are conditionally evaluated. While there,
6 put SNPRINTF_CONST back as it prevents build failures in some
7 configurations. ok djm@ (for most of it)
8
120070122 920070122
2 - (djm) [ssh-rand-helper.8] manpage nits; 10 - (djm) [ssh-rand-helper.8] manpage nits;
3 from dleonard AT vintela.com (bz#1529) 11 from dleonard AT vintela.com (bz#1529)
@@ -2678,4 +2686,4 @@
2678 OpenServer 6 and add osr5bigcrypt support so when someone migrates 2686 OpenServer 6 and add osr5bigcrypt support so when someone migrates
2679 passwords between UnixWare and OpenServer they will still work. OK dtucker@ 2687 passwords between UnixWare and OpenServer they will still work. OK dtucker@
2680 2688
2681$Id: ChangeLog,v 1.4607 2007/01/22 01:44:53 djm Exp $ 2689$Id: ChangeLog,v 1.4608 2007/01/23 13:07:29 dtucker Exp $
diff --git a/openbsd-compat/bsd-snprintf.c b/openbsd-compat/bsd-snprintf.c
index cefb1d1ad..41d2be238 100644
--- a/openbsd-compat/bsd-snprintf.c
+++ b/openbsd-compat/bsd-snprintf.c
@@ -168,12 +168,13 @@
168 168
169#define DOPR_OUTCH(buf, pos, buflen, thechar) \ 169#define DOPR_OUTCH(buf, pos, buflen, thechar) \
170 do { \ 170 do { \
171 if (++pos >= INT_MAX) { \ 171 if (pos + 1 >= INT_MAX) { \
172 errno = ERANGE; \ 172 errno = ERANGE; \
173 return -1; \ 173 return -1; \
174 } \
174 if (pos < buflen) \ 175 if (pos < buflen) \
175 buf[pos] = thechar; \ 176 buf[pos] = thechar; \
176 } \ 177 (pos)++; \
177 } while (0) 178 } while (0)
178 179
179static int dopr(char *buffer, size_t maxlen, const char *format, 180static int dopr(char *buffer, size_t maxlen, const char *format,
@@ -494,7 +495,8 @@ fmtstr(char *buffer, size_t *currlen, size_t maxlen,
494 ++cnt; 495 ++cnt;
495 } 496 }
496 while (*value && (cnt < max)) { 497 while (*value && (cnt < max)) {
497 DOPR_OUTCH(buffer, *currlen, maxlen, *value++); 498 DOPR_OUTCH(buffer, *currlen, maxlen, *value);
499 *value++;
498 ++cnt; 500 ++cnt;
499 } 501 }
500 while ((padlen < 0) && (cnt < max)) { 502 while ((padlen < 0) && (cnt < max)) {
@@ -582,8 +584,10 @@ fmtint(char *buffer, size_t *currlen, size_t maxlen,
582 } 584 }
583 585
584 /* Digits */ 586 /* Digits */
585 while (place > 0) 587 while (place > 0) {
586 DOPR_OUTCH(buffer, *currlen, maxlen, convert[--place]); 588 --place;
589 DOPR_OUTCH(buffer, *currlen, maxlen, convert[place]);
590 }
587 591
588 /* Left Justified spaces */ 592 /* Left Justified spaces */
589 while (spadlen < 0) { 593 while (spadlen < 0) {
@@ -788,8 +792,10 @@ fmtfp (char *buffer, size_t *currlen, size_t maxlen,
788 if (signvalue) 792 if (signvalue)
789 DOPR_OUTCH(buffer, *currlen, maxlen, signvalue); 793 DOPR_OUTCH(buffer, *currlen, maxlen, signvalue);
790 794
791 while (iplace > 0) 795 while (iplace > 0) {
792 DOPR_OUTCH(buffer, *currlen, maxlen, iconvert[--iplace]); 796 --iplace;
797 DOPR_OUTCH(buffer, *currlen, maxlen, iconvert[iplace]);
798 }
793 799
794#ifdef DEBUG_SNPRINTF 800#ifdef DEBUG_SNPRINTF
795 printf("fmtfp: fplace=%d zpadlen=%d\n", fplace, zpadlen); 801 printf("fmtfp: fplace=%d zpadlen=%d\n", fplace, zpadlen);
@@ -807,9 +813,10 @@ fmtfp (char *buffer, size_t *currlen, size_t maxlen,
807 --zpadlen; 813 --zpadlen;
808 } 814 }
809 815
810 while (fplace > 0) 816 while (fplace > 0) {
811 DOPR_OUTCH(buffer, *currlen, maxlen, 817 --fplace;
812 fconvert[--fplace]); 818 DOPR_OUTCH(buffer, *currlen, maxlen, fconvert[fplace]);
819 }
813 } 820 }
814 821
815 while (padlen < 0) { 822 while (padlen < 0) {
@@ -821,7 +828,7 @@ fmtfp (char *buffer, size_t *currlen, size_t maxlen,
821#endif /* !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) */ 828#endif /* !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) */
822 829
823#if !defined(HAVE_VSNPRINTF) 830#if !defined(HAVE_VSNPRINTF)
824static int 831int
825vsnprintf (char *str, size_t count, const char *fmt, va_list args) 832vsnprintf (char *str, size_t count, const char *fmt, va_list args)
826{ 833{
827 return dopr(str, count, fmt, args); 834 return dopr(str, count, fmt, args);
@@ -829,8 +836,8 @@ vsnprintf (char *str, size_t count, const char *fmt, va_list args)
829#endif 836#endif
830 837
831#if !defined(HAVE_SNPRINTF) 838#if !defined(HAVE_SNPRINTF)
832static int 839int
833snprintf(char *str, size_t count, const char *fmt, ...) 840snprintf(char *str, size_t count, SNPRINTF_CONST char *fmt, ...)
834{ 841{
835 size_t ret; 842 size_t ret;
836 va_list ap; 843 va_list ap;