diff options
| author | tslil clingman <tslil@posteo.de> | 2021-10-06 08:50:27 -0400 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2026-08-28 19:37:41 +0100 |
| commit | 3a4c7107d682b4219cc87a696ecfe3a6095512be (patch) | |
| tree | 1ff86ee30afb637e21e6cc156f56ef84c55eb771 /src/geminict.c | |
| parent | cf175fc346f1b208766b1f55d3673a7b208f322a (diff) | |
Enforce quoted ptn string for geminict
Diffstat (limited to 'src/geminict.c')
| -rw-r--r-- | src/geminict.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/geminict.c b/src/geminict.c index 2ac2eab..d25b40c 100644 --- a/src/geminict.c +++ b/src/geminict.c @@ -311,8 +311,29 @@ int main(int argc, char **argv) { char* line = argv[1]; // Some maximum length we're willing to parse - const uint32_t len = strnlen(line, 65535); - if (!line || len == 0 || len == 65535) return EXIT_FAILURE; + uint32_t len = strnlen(line, 65535); + if (!line || len < 2 || len == 65535) { + puts("Malformed input."); + return EXIT_FAILURE; + } + + // strip quotes + if (line[0]=='\'') { + line++; + len--; + } else { + puts("Malformed input."); + return EXIT_FAILURE; + } + + if (line[len-1]=='\'') { + line[len-1]=0; + len--; + } else { + puts("Malformed input."); + return EXIT_FAILURE; + } + uint32_t start = 0, end = 0; while (start < len) { // Find first separator |
