diff options
Diffstat (limited to 'source/parsing.c')
| -rw-r--r-- | source/parsing.c | 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 8 insertions, 2 deletions
diff --git a/source/parsing.c b/source/parsing.c index f6b1a02..0d63b51 100644 --- a/source/parsing.c +++ b/source/parsing.c @@ -62,12 +62,18 @@ void cgit_parse_url(const char *url) static char *substr(const char *head, const char *tail) { + size_t len; char *buf; if (tail < head) return xstrdup(""); - buf = xmalloc(tail - head + 1); - strlcpy(buf, head, tail - head + 1); + // head points into the commit buffer, so strlcpy would measure the + // whole remaining commit just to copy a name or a subject off the front + // of it. + len = tail - head; + buf = xmalloc(len + 1); + memcpy(buf, head, len); + buf[len] = '\0'; return buf; } |
