summaryrefslogtreecommitdiffstats
path: root/libmount/src/cache.c
diff options
context:
space:
mode:
authorKarel Zak2012-06-15 12:26:05 +0200
committerKarel Zak2012-06-15 12:26:05 +0200
commit9d670a2ab4b5b6d5a19aa4d392353f64b7218a5b (patch)
treef36547dd53f32a83799e129bdb633ed190beb452 /libmount/src/cache.c
parentlibmount: fix trivial typos (diff)
downloadkernel-qcow2-util-linux-9d670a2ab4b5b6d5a19aa4d392353f64b7218a5b.tar.gz
kernel-qcow2-util-linux-9d670a2ab4b5b6d5a19aa4d392353f64b7218a5b.tar.xz
kernel-qcow2-util-linux-9d670a2ab4b5b6d5a19aa4d392353f64b7218a5b.zip
libmount: make some string operations more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/cache.c')
-rw-r--r--libmount/src/cache.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/libmount/src/cache.c b/libmount/src/cache.c
index 8962a903c..fe9c821e1 100644
--- a/libmount/src/cache.c
+++ b/libmount/src/cache.c
@@ -595,7 +595,7 @@ int test_resolve_path(struct libmnt_test *ts, int argc, char *argv[])
size_t sz = strlen(line);
char *p;
- if (line[sz - 1] == '\n')
+ if (sz > 0 && line[sz - 1] == '\n')
line[sz - 1] = '\0';
p = mnt_resolve_path(line, cache);
@@ -618,7 +618,7 @@ int test_resolve_spec(struct libmnt_test *ts, int argc, char *argv[])
size_t sz = strlen(line);
char *p;
- if (line[sz - 1] == '\n')
+ if (sz > 0 && line[sz - 1] == '\n')
line[sz - 1] = '\0';
p = mnt_resolve_spec(line, cache);
@@ -641,7 +641,7 @@ int test_read_tags(struct libmnt_test *ts, int argc, char *argv[])
while(fgets(line, sizeof(line), stdin)) {
size_t sz = strlen(line);
- if (line[sz - 1] == '\n')
+ if (sz > 0 && line[sz - 1] == '\n')
line[sz - 1] = '\0';
if (!strcmp(line, "quit"))