[openssh-commits] [openssh] 01/01: need va_end() after va_copy(); ok dtucker

git+noreply at mindrot.org git+noreply at mindrot.org
Mon Apr 3 10:01:23 AEST 2023


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit b36b162be5e6206f12b734222b7bc517c13a6bc8
Author: Damien Miller <djm at mindrot.org>
Date:   Fri Mar 31 14:51:20 2023 +1100

    need va_end() after va_copy(); ok dtucker
    
    spotted by Coverity
---
 openbsd-compat/bsd-snprintf.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/openbsd-compat/bsd-snprintf.c b/openbsd-compat/bsd-snprintf.c
index bc505b83..0d23a86c 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

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list