diff options
author | Karel Zak | 2012-06-15 12:26:05 +0200 |
---|---|---|
committer | Karel Zak | 2012-06-15 12:26:05 +0200 |
commit | 9d670a2ab4b5b6d5a19aa4d392353f64b7218a5b (patch) | |
tree | f36547dd53f32a83799e129bdb633ed190beb452 /libmount/src/cache.c | |
parent | libmount: fix trivial typos (diff) | |
download | kernel-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.c | 6 |
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")) |