diff options
| -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 |
