diff options
author | Allen Winter <allen.winter@kdab.com> | 2022-09-29 11:06:52 -0400 |
---|---|---|
committer | Allen Winter <allen.winter@kdab.com> | 2022-09-29 11:06:52 -0400 |
commit | a435a775bedf35404a18351c3b925b05d4311dbd (patch) | |
tree | fd752651974d5c211b66e6720fe469a2d6ecc587 | |
parent | ad099a5f10526ee94d413acf0a9272846dece283 (diff) | |
parent | 2ca167a6077fc1464b1dd3dde93b68c50dc0f720 (diff) | |
download | libical-git-a435a775bedf35404a18351c3b925b05d4311dbd.tar.gz |
Merge branch '3.0'
-rw-r--r-- | src/libical/icalparser.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libical/icalparser.c b/src/libical/icalparser.c index faa40b1a..295dced9 100644 --- a/src/libical/icalparser.c +++ b/src/libical/icalparser.c @@ -132,8 +132,10 @@ static char *parser_get_next_char(char c, char *str, int qm) char *p = str; char next_char = *p; char prev_char = 0; + unsigned int cnt = 0; - while (next_char != '\0') { + while ((cnt < TMP_BUF_SIZE) && (next_char != '\0')) { + cnt++; if ((prev_char != '\0') && (prev_char != '\\')) { if (qm == 1 && next_char == '"') { /* Encountered a quote, toggle quote mode */ @@ -157,13 +159,15 @@ static char *make_segment(char *start, char *end) { char *buf, *tmp; ptrdiff_t size = (ptrdiff_t)(end - start); + ptrdiff_t cnt = 0; buf = icalmemory_new_buffer((size_t)(size + 1)); strncpy(buf, start, size); *(buf + size) = 0; tmp = (buf + size); - while ((tmp >= buf) && ((*tmp == '\0') || iswspace((wint_t)*tmp))) { + while ((cnt < size) && (tmp >= buf) && ((*tmp == '\0') || iswspace((wint_t)*tmp))) { + cnt++; *tmp = 0; tmp--; } |