Просмотр исходного кода

don't crash on malformed response code

this would happen in the absurd corner case that the response code is
properly terminated with a closing bracket, but the atom itself is an
unterminated double-quoted string.

NOT found by coverity.
Oswald Buddenhagen 11 лет назад
Родитель
Сommit
ae49a37a3e
1 измененных файлов с 3 добавлено и 1 удалено
  1. 3 1
      src/drv_imap.c

+ 3 - 1
src/drv_imap.c

@@ -993,11 +993,13 @@ parse_response_code( imap_store_t *ctx, struct imap_cmd *cmd, char *s )
 		return RESP_OK;		/* no response code */
 	s++;
 	if (!(p = strchr( s, ']' ))) {
+	  bad_resp:
 		error( "IMAP error: malformed response code\n" );
 		return RESP_CANCEL;
 	}
 	*p++ = 0;
-	arg = next_arg( &s );
+	if (!(arg = next_arg( &s )))
+		goto bad_resp;
 	if (!strcmp( "UIDVALIDITY", arg )) {
 		if (!(arg = next_arg( &s )) ||
 		    (ctx->gen.uidvalidity = strtoll( arg, &earg, 10 ), *earg))