Re: [PATCH v4 3/3] imap: replace atoi() with strtol_i() for UIDVALIDITY and UIDNEXT parsing
From: Usman Akinyemi <hidden>
Date: 2024-10-23 07:40:59
On Wed, Oct 23, 2024 at 6:05 AM Patrick Steinhardt [off-list ref] wrote:
On Tue, Oct 22, 2024 at 10:08:57PM +0000, Usman Akinyemi via GitGitGadget wrote:quoted
@@ -686,8 +686,8 @@ static int parse_response_code(struct imap_store *ctx, struct imap_cmd_cb *cb, for (; isspace((unsigned char)*p); p++); fprintf(stderr, "*** IMAP ALERT *** %s\n", p); } else if (cb && cb->ctx && !strcmp("APPENDUID", arg)) { - if (!(arg = next_arg(&s)) || !(ctx->uidvalidity = atoi(arg)) || - !(arg = next_arg(&s)) || !(*(int *)cb->ctx = atoi(arg))) { + if (!(arg = next_arg(&s)) || (strtol_i(arg, 10, &ctx->uidvalidity) || !ctx->uidvalidity) || + !(arg = next_arg(&s)) || (strtol_i(arg, 10, (int *)cb->ctx) || !cb->ctx)) { fprintf(stderr, "IMAP error: malformed APPENDUID status\n"); return RESP_BAD; }Two last nits from my side, sorry that I didn't spot these earlier: - The second line is indented incorrectly. When you have a multi-line condition, subsequent lines should align with the opening brace like this: if (something_something || something_else) frobnicate(); - The braces around `(strtol_i() || !ctx->uidvalidity)` are a bit confusing and unnecessary.
Thank you Patrick for bringing my attention to this. I fixed it now. Usman
Other than that I'm happy with this series, thanks! Patrick