summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-08-02 15:24:59 -0400
committerJakob Kaivo <jkk@ung.org>2019-08-02 15:24:59 -0400
commit1e1bb9c04bd7f8504c0cf776b62feca69fb8cb93 (patch)
treea284b9d8eb26917cbd362a33b0233aa947f710e6
parent287b5e4d665684cf8712144f394b1560c1456b99 (diff)
detect chunk overflow
-rw-r--r--split.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/split.c b/split.c
index 5366221..81671a7 100644
--- a/split.c
+++ b/split.c
@@ -39,9 +39,12 @@ static char *nextsuffix(size_t n, char s[])
return s;
}
- for (size_t i = n-1; i > 0; i--) {
+ for (size_t i = n - 1; ; i--) {
s[i] = *(strchr(alphabet, s[i]) + 1);
if (s[i] == '\0') {
+ if (i == 0) {
+ return NULL;
+ }
s[i] = alphabet[0];
} else {
break;