summary refs log tree commit diff
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2018-05-19 02:39:44 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2018-05-28 17:12:23 +0800
commit0e18261c159f0af3d9ea7eae116d201bc1e05dd5 (patch)
tree2c54b4e7a4b3e5fd8dedb49ca2d197f91f29a762
parentvar: Set IFS to fixed value at start time (diff)
downloaddash-0e18261c159f0af3d9ea7eae116d201bc1e05dd5.tar.gz
dash-0e18261c159f0af3d9ea7eae116d201bc1e05dd5.zip
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@gondor.apana.org.au>
Diffstat (limited to '')
-rw-r--r--src/output.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/output.c b/src/output.c
index 4d3b4c2..34243ea 100644
--- a/src/output.c
+++ b/src/output.c
@@ -286,7 +286,7 @@ fmtstr(char *outbuf, size_t length, const char *fmt, ...)
 	va_start(ap, fmt);
 	ret = xvsnprintf(outbuf, length, fmt, ap);
 	va_end(ap);
-	return ret;
+	return ret > (int)length ? length : ret;
 }