aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@users.noreply.github.com>2021-05-07 10:35:28 -0400
committerGitHub <noreply@github.com>2021-05-07 10:35:28 -0400
commitb072d93e47949c9729c979fceef8a7c7bfd22d39 (patch)
tree96172b7aa41d6e0b4a44a4d8e67e7bcfd15511ef /lib
parent003c7d1b27140d42c026c25fbca1cef545bfb5c7 (diff)
downloadcleanpath-b072d93e47949c9729c979fceef8a7c7bfd22d39.tar.gz
Improvements (#4)
* Move display code into functions * Mark windows supported * Guard against overruns * Add --list argument to docs
Diffstat (limited to 'lib')
-rw-r--r--lib/cleanpath.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/cleanpath.c b/lib/cleanpath.c
index 2337869..fdb615d 100644
--- a/lib/cleanpath.c
+++ b/lib/cleanpath.c
@@ -43,7 +43,7 @@ struct CleanPath *cleanpath_init(const char *path, const char *sep) {
// Split string by separator
elem = strtok(result->data, sep);
- for (i = 0; elem != NULL; i++) {
+ for (i = 0; i < CLEANPATH_PART_MAX && elem != NULL; i++) {
result->part[i] = elem;
elem = strtok(NULL, sep);
}
@@ -67,7 +67,7 @@ void cleanpath_filter(struct CleanPath *path, unsigned mode, const char *pattern
#endif
int match;
- for (size_t i = 0; path->part[i]; i++) {
+ for (size_t i = 0; i < CLEANPATH_PART_MAX && path->part[i]; i++) {
match = 0;
switch(mode) {
case CLEANPATH_FILTER_LOOSE:
@@ -109,7 +109,7 @@ char *cleanpath_read(struct CleanPath *path) {
goto cleanpath_read__failure;
}
- for (size_t i = 0; path->part[i] != NULL; i++) {
+ for (size_t i = 0; i < CLEANPATH_PART_MAX && path->part[i] != NULL; i++) {
// Ignore filtered paths
if (*path->part[i] == '\0') {
continue;