diff options
author | Chad Loder <cloder@cvs.openbsd.org> | 2006-10-10 19:54:07 +0000 |
---|---|---|
committer | Chad Loder <cloder@cvs.openbsd.org> | 2006-10-10 19:54:07 +0000 |
commit | fe7766db38c88474f87fc0e6f0b94e6d8c758ce2 (patch) | |
tree | 9cc50cd3617e68b3336000a634342f41e02776dd /usr.bin | |
parent | bc4e62575cd6c31244955e62c0b66a304ea7cd97 (diff) |
Fix an instance of foo[strlen(foo) - 1] = something, which is dangerous
because strlen(foo) could be 0.
OK beck@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/less/tags.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/usr.bin/less/tags.c b/usr.bin/less/tags.c index bb09dffc8fb..2aebe160708 100644 --- a/usr.bin/less/tags.c +++ b/usr.bin/less/tags.c @@ -536,6 +536,7 @@ findgtag(tag, type) while (fgets(buf, sizeof(buf), fp)) { char *name, *file, *line; + size_t len; if (sigs) { @@ -545,8 +546,8 @@ findgtag(tag, type) #endif return TAG_INTR; } - if (buf[strlen(buf) - 1] == '\n') - buf[strlen(buf) - 1] = 0; + if ((len = strlen(buf)) && buf[len - 1] == '\n') + buf[len - 1] = 0; else { int c; |