From 618ec81abbda91d867ac43320c7fd3e8fcc23e78 Mon Sep 17 00:00:00 2001 From: René Scharfe Date: Thu, 2 Nov 2017 18:27:05 +0100 Subject: 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 Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- imap-send.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imap-send.c b/imap-send.c index ffbf266b2f..efa6af4b51 100644 --- a/imap-send.c +++ b/imap-send.c @@ -683,7 +683,7 @@ static int parse_response_code(struct imap_store *ctx, struct imap_cmd_cb *cb, struct imap *imap = ctx->imap; char *arg, *p; - if (*s != '[') + if (!s || *s != '[') return RESP_OK; /* no response code */ s++; if (!(p = strchr(s, ']'))) { -- cgit v1.2.3