diff options
author | Tobias Stoeckmann | 2016-10-03 22:06:23 +0200 |
---|---|---|
committer | Karel Zak | 2016-10-06 14:56:39 +0200 |
commit | b56b13684e01ab56738e602b35a2c133e8f9b92a (patch) | |
tree | 640c7b4f3e88051c818ba4cb9b8e372c0349c051 /text-utils/rev.c | |
parent | rev: Avoid calling free in a signal handler (diff) | |
download | kernel-qcow2-util-linux-b56b13684e01ab56738e602b35a2c133e8f9b92a.tar.gz kernel-qcow2-util-linux-b56b13684e01ab56738e602b35a2c133e8f9b92a.tar.xz kernel-qcow2-util-linux-b56b13684e01ab56738e602b35a2c133e8f9b92a.zip |
rev: Avoid out of boundary read
Check if the length of the parsed string is at least 1,
otherwise an out of boundary read would occur.
Diffstat (limited to 'text-utils/rev.c')
-rw-r--r-- | text-utils/rev.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/text-utils/rev.c b/text-utils/rev.c index ace2cd6a6..735aaef3d 100644 --- a/text-utils/rev.c +++ b/text-utils/rev.c @@ -149,6 +149,9 @@ int main(int argc, char *argv[]) while (fgetws(buf, bufsiz, fp)) { len = wcslen(buf); + if (len == 0) + continue; + /* This is my hack from setpwnam.c -janl */ while (buf[len-1] != '\n' && !feof(fp)) { /* Extend input buffer if it failed getting the whole line */ |