]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
rev: Avoid out of boundary read
authorTobias Stoeckmann <tobias@stoeckmann.org>
Mon, 3 Oct 2016 20:06:23 +0000 (22:06 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 6 Oct 2016 12:56:39 +0000 (14:56 +0200)
Check if the length of the parsed string is at least 1,
otherwise an out of boundary read would occur.

text-utils/rev.c

index ace2cd6a6bc29bd460b3613422b4ff98a3d8e1f9..735aaef3d9f76383bbfa4caa32eac36f154c1fc7 100644 (file)
@@ -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 */