summaryrefslogtreecommitdiffstats
path: root/openbsd-compat/bsd-snprintf.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2023-03-31 05:51:20 +0200
committerDamien Miller <djm@mindrot.org>2023-04-03 02:01:01 +0200
commitb36b162be5e6206f12b734222b7bc517c13a6bc8 (patch)
treea9ca3d379605fe63a571652883134ae4730b87a4 /openbsd-compat/bsd-snprintf.c
parentupstream: Explicitly ignore return from waitpid here too. (diff)
downloadopenssh-b36b162be5e6206f12b734222b7bc517c13a6bc8.tar.xz
openssh-b36b162be5e6206f12b734222b7bc517c13a6bc8.zip
need va_end() after va_copy(); ok dtucker
spotted by Coverity
Diffstat (limited to '')
-rw-r--r--openbsd-compat/bsd-snprintf.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/openbsd-compat/bsd-snprintf.c b/openbsd-compat/bsd-snprintf.c
index bc505b838..0d23a86c5 100644
--- a/openbsd-compat/bsd-snprintf.c
+++ b/openbsd-compat/bsd-snprintf.c
@@ -320,7 +320,7 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args_in)
value = va_arg (args, int);
if (fmtint(buffer, &currlen, maxlen,
value, 10, min, max, flags) == -1)
- return -1;
+ goto fail;
break;
case 'o':
flags |= DP_F_UNSIGNED;
@@ -340,7 +340,7 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args_in)
value = (long)va_arg (args, unsigned int);
if (fmtint(buffer, &currlen, maxlen, value,
8, min, max, flags) == -1)
- return -1;
+ goto fail;
break;
case 'u':
flags |= DP_F_UNSIGNED;
@@ -360,7 +360,7 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args_in)
value = (long)va_arg (args, unsigned int);
if (fmtint(buffer, &currlen, maxlen, value,
10, min, max, flags) == -1)
- return -1;
+ goto fail;
break;
case 'X':
flags |= DP_F_UP;
@@ -382,7 +382,7 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args_in)
value = (long)va_arg (args, unsigned int);
if (fmtint(buffer, &currlen, maxlen, value,
16, min, max, flags) == -1)
- return -1;
+ goto fail;
break;
case 'f':
if (cflags == DP_C_LDOUBLE)
@@ -391,7 +391,7 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args_in)
fvalue = va_arg (args, double);
if (fmtfp(buffer, &currlen, maxlen, fvalue,
min, max, flags) == -1)
- return -1;
+ goto fail;
break;
case 'E':
flags |= DP_F_UP;
@@ -402,7 +402,7 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args_in)
fvalue = va_arg (args, double);
if (fmtfp(buffer, &currlen, maxlen, fvalue,
min, max, flags) == -1)
- return -1;
+ goto fail;
break;
case 'G':
flags |= DP_F_UP;
@@ -413,7 +413,7 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args_in)
fvalue = va_arg (args, double);
if (fmtfp(buffer, &currlen, maxlen, fvalue,
min, max, flags) == -1)
- return -1;
+ goto fail;
break;
case 'c':
DOPR_OUTCH(buffer, currlen, maxlen,
@@ -428,13 +428,13 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args_in)
if (min > 0 && max >= 0 && min > max) max = min;
if (fmtstr(buffer, &currlen, maxlen,
strvalue, flags, min, max) == -1)
- return -1;
+ goto fail;
break;
case 'p':
strvalue = va_arg (args, void *);
if (fmtint(buffer, &currlen, maxlen,
(long) strvalue, 16, min, max, flags) == -1)
- return -1;
+ goto fail;
break;
#if we_dont_want_this_in_openssh
case 'n':
@@ -494,8 +494,11 @@ dopr(char *buffer, size_t maxlen, const char *format, va_list args_in)
else if (maxlen > 0)
buffer[maxlen - 1] = '\0';
}
-
+ va_end(args);
return currlen < INT_MAX ? (int)currlen : -1;
+ fail:
+ va_end(args);
+ return -1;
}
static int