]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: verify arroy bound before reference [cppcheck]
authorSami Kerola <kerolasa@iki.fi>
Tue, 7 Feb 2012 21:31:03 +0000 (22:31 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 8 Feb 2012 13:08:49 +0000 (14:08 +0100)
[libblkid/src/read.c:428]: (style) Array index end is used before limits check

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
libblkid/src/read.c

index b284ff004eb05a10c6381c06484153cfdfa7d149..60d13db0cfb09f31251cd53e7a96d9891a69bdf2 100644 (file)
@@ -425,7 +425,7 @@ void blkid_read_cache(blkid_cache cache)
                        continue;
                end = strlen(buf) - 1;
                /* Continue reading next line if it ends with a backslash */
-               while (buf[end] == '\\' && end < sizeof(buf) - 2 &&
+               while (end < (sizeof(buf) - 2) && buf[end] == '\\' &&
                       fgets(buf + end, sizeof(buf) - end, file)) {
                        end = strlen(buf) - 1;
                        lineno++;