diff options
author | Cy Schubert <cy@FreeBSD.org> | 2020-05-21 05:01:52 +0000 |
---|---|---|
committer | Cy Schubert <cy@FreeBSD.org> | 2020-05-21 05:01:52 +0000 |
commit | 6a53c00e64c4cf911eb00846733d9e6a47b2e7f4 (patch) | |
tree | 60a7720d2d4edfe62b094e2665743e8879ebb911 /sldns/parse.c | |
parent | e2fe726866d062155f6b1aae749375475ef19191 (diff) |
Diffstat (limited to 'sldns/parse.c')
-rw-r--r-- | sldns/parse.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/sldns/parse.c b/sldns/parse.c index b30264e88e794..f4de8602fd693 100644 --- a/sldns/parse.c +++ b/sldns/parse.c @@ -120,7 +120,7 @@ sldns_fget_token_l(FILE *f, char *token, const char *delim, size_t limit, int *l if (line_nr) { *line_nr = *line_nr + 1; } - if (limit > 0 && (i >= limit || (size_t)(t-token) >= limit)) { + if (limit > 0 && (i+1 >= limit || (size_t)(t-token)+1 >= limit)) { *t = '\0'; return -1; } @@ -141,7 +141,8 @@ sldns_fget_token_l(FILE *f, char *token, const char *delim, size_t limit, int *l if (c != '\0' && c != '\n') { i++; } - if (limit > 0 && (i >= limit || (size_t)(t-token) >= limit)) { + /* is there space for the character and the zero after it */ + if (limit > 0 && (i+1 >= limit || (size_t)(t-token)+1 >= limit)) { *t = '\0'; return -1; } @@ -326,8 +327,8 @@ sldns_bget_token_par(sldns_buffer *b, char *token, const char *delim, /* in parentheses */ /* do not write ' ' if we want to skip spaces */ if(!(skipw && (strchr(skipw, c)||strchr(skipw, ' ')))) { - /* check for space for the space character */ - if (limit > 0 && (i >= limit || (size_t)(t-token) >= limit)) { + /* check for space for the space character and a zero delimiter after that. */ + if (limit > 0 && (i+1 >= limit || (size_t)(t-token)+1 >= limit)) { *t = '\0'; return -1; } @@ -354,7 +355,7 @@ sldns_bget_token_par(sldns_buffer *b, char *token, const char *delim, } i++; - if (limit > 0 && (i >= limit || (size_t)(t-token) >= limit)) { + if (limit > 0 && (i+1 >= limit || (size_t)(t-token)+1 >= limit)) { *t = '\0'; return -1; } |