sacc

sacc (saccomys): simple gopher client.
Log | Files | Refs | LICENSE

commit 9041f6140da12aadc5c08ff33f6a67b2c5a1bfd9
parent 02b786ac6c63da345c297bf47563d00985dedcb6
Author: Quentin Rameau <quinq@fifth.space>
Date:   Fri, 23 Jun 2017 20:56:47 +0200

Fix potential underflow in item counting

Diffstat:
sacc.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sacc.c b/sacc.c @@ -261,9 +261,11 @@ molddiritem(char *raw) for (crlf = raw, nitems = 0; p = strstr(crlf, "\r\n"); ++nitems) crlf = p+2; - if (--nitems < 1) + if (nitems <= 1) return NULL; - if (strcmp(crlf-3, ".\r\n")) + if (!strcmp(crlf-3, ".\r\n")) + --nitems; + else fprintf(stderr, "Parsing error: missing .\\r\\n last line\n"); dir = xmalloc(sizeof(Dir));