diff options
author | Rob Landley <rob@landley.net> | 2014-10-27 19:20:31 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2014-10-27 19:20:31 -0500 |
commit | de36079ccdceffee0ed750ab8780b0c68925ba2f (patch) | |
tree | c550db4d385d38aeca904ca3a2864ff225555554 | |
parent | 45b3882a1187f0e957efbc4fc5d797ba9603f545 (diff) | |
download | toybox-de36079ccdceffee0ed750ab8780b0c68925ba2f.tar.gz |
Fix use after free error spotted by ?ukasz Szpakowski.
-rw-r--r-- | toys/posix/tail.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/toys/posix/tail.c b/toys/posix/tail.c index e1048be7..aba53180 100644 --- a/toys/posix/tail.c +++ b/toys/posix/tail.c @@ -176,9 +176,13 @@ static void do_tail(int fd, char *name) linepop = try[count] == '\n'; if (lines > 0) { + char c; + do { + c = *list->data; if (!--(list->len)) free(dlist_pop(&list)); - } while (*(list->data++) != '\n'); + else list->data++; + } while (c != '\n'); lines--; } } |