aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2020-06-19 04:48:29 -0500
committerRob Landley <rob@landley.net>2020-06-19 04:48:29 -0500
commitf00639a92d015e42ca8b10b86dc6a12e5f11bb62 (patch)
tree5ad0978076d40c716f41ee79b8d778f5295f8a88
parent5100ebb672a4151dedf2ae4cc7f4bc4fdaa84b7b (diff)
downloadtoybox-f00639a92d015e42ca8b10b86dc6a12e5f11bb62.tar.gz
Bugfix: the code to trim \n off xgetline() was using allocated not read length.
-rw-r--r--lib/xwrap.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/xwrap.c b/lib/xwrap.c
index c09923ba..b144b2f4 100644
--- a/lib/xwrap.c
+++ b/lib/xwrap.c
@@ -1050,7 +1050,7 @@ char *xgetline(FILE *fp, int *len)
if (1>(ll = getline(&new, &linelen, fp))) {
if (errno) perror_msg("getline");
new = 0;
- } else if (new[linelen-1] == '\n') new[--linelen] = 0;
+ } else if (new[ll-1] == '\n') new[--ll] = 0;
if (len) *len = ll;
return new;