[git commit] ash: output: Fix fmtstr return value

Denys Vlasenko vda.linux at googlemail.com
Sun Feb 16 18:14:45 UTC 2020


commit: https://git.busybox.net/busybox/commit/?id=3f7fb2c89ad75bbdd3b69e302124c8179c273bb4
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

Upstream commit:

    Date: Sat, 19 May 2018 02:39:44 +0800
    output: Fix fmtstr return value

    The function fmtstr is meant to return the actual length of output
    produced, rather than the untruncated length.

    Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 shell/ash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/shell/ash.c b/shell/ash.c
index db7dffc72..a006a1c26 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -713,7 +713,7 @@ fmtstr(char *outbuf, size_t length, const char *fmt, ...)
 	ret = vsnprintf(outbuf, length, fmt, ap);
 	va_end(ap);
 	INT_ON;
-	return ret;
+	return ret > (int)length ? length : ret;
 }
 
 static void


More information about the busybox-cvs mailing list