imap-send: handle missing response codes gracefully
Response codes are optional. Exit parse_response_code() early if it's passed a NULL string, indicating that we reached the end of the reply. This avoids dereferencing said NULL pointer. Noticed-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Nov 2, 2017 at 18:27 UTC
618ec81abbda91d867ac43320c7fd3e8fcc23e78
1 file changed
+1
-1
imap-send.c
+1
-1
@@ -683,7 +683,7 @@ static int parse_response_code(struct imap_store *ctx, struct imap_cmd_cb *cb,
683
struct imap *imap = ctx->imap;
684
char *arg, *p;
685
686
- if (*s != '[')
686
+ if (!s || *s != '[')
687
return RESP_OK; /* no response code */
688
s++;
689
if (!(p = strchr(s, ']'))) {