diff options
author | 2006-10-10 19:54:06 +0000 | |
---|---|---|
committer | 2006-10-10 19:54:06 +0000 | |
commit | 166a0646601fa05758a8be128c6a0eb5238809f7 (patch) | |
tree | dcaf0bee1baacdc8fccdc74c9ca6caf0f4d370ec | |
parent | - add the Hitachi adapter (diff) | |
download | wireguard-openbsd-166a0646601fa05758a8be128c6a0eb5238809f7.tar.xz wireguard-openbsd-166a0646601fa05758a8be128c6a0eb5238809f7.zip |
Fix an instance of foo[strlen(foo) - 1] = something, which is dangerous
because strlen(foo) could be 0.
OK beck@
-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; |