Subject: [PATCH v4 0/3] parse: replace atoi() with strtoul_ui() and strtol_i()

From: "Usman Akinyemi via GitGitGadget" <[email-masked]>
Date: Tue, 22 Oct 2024 22:08:54 +0000

Changes from Version 3:

 * Mark the error message strings as translate-able.

Usman Akinyemi (3):
  daemon: replace atoi() with strtoul_ui() and strtol_i()
  merge: replace atoi() with strtol_i() for marker size validation
  imap: replace atoi() with strtol_i() for UIDVALIDITY and UIDNEXT
    parsing

 daemon.c              | 12 ++++++++----
 imap-send.c           | 13 ++++++++-----
 merge-ll.c            | 11 +++++++++--
 t/t5570-git-daemon.sh | 26 ++++++++++++++++++++++++++
 t/t6406-merge-attr.sh |  6 ++++++
 5 files changed, 57 insertions(+), 11 deletions(-)

base-commit: 90fe3800b92a49173530828c0a17951abd30f0e1
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1810%2FUnique-Usman%2Fr_atoi-v4
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1810/Unique-Usman/r_atoi-v4
Pull-Request: https://github.com/git/git/pull/1810

Range-diff vs v3:

 1:  e292b82d6a1 ! 1:  d9c997d7a9c daemon: replace atoi() with strtoul_ui() and strtol_i()
     @@ Commit message
          Signed-off-by: Usman Akinyemi <[email-masked]>
      
       ## daemon.c ##
     +@@
     + #include "abspath.h"
     + #include "config.h"
     + #include "environment.h"
     ++#include "gettext.h"
     + #include "path.h"
     + #include "pkt-line.h"
     + #include "protocol.h"
      @@ daemon.c: int cmd_main(int argc, const char **argv)
       			continue;
       		}
       		if (skip_prefix(arg, "--timeout=", &v)) {
      -			timeout = atoi(v);
      +			if (strtoul_ui(v, 10, &timeout))
     -+				die("invalid timeout '%s', expecting a non-negative integer", v);
     ++				die(_("invalid timeout '%s', expecting a non-negative integer"), v);
       			continue;
       		}
       		if (skip_prefix(arg, "--init-timeout=", &v)) {
      -			init_timeout = atoi(v);
      +			if (strtoul_ui(v, 10, &init_timeout))
     -+				die("invalid init-timeout '%s', expecting a non-negative integer", v);
     ++				die(_("invalid init-timeout '%s', expecting a non-negative integer"), v);
       			continue;
       		}
       		if (skip_prefix(arg, "--max-connections=", &v)) {
      -			max_connections = atoi(v);
      +			if (strtol_i(v, 10, &max_connections))
     -+				die("invalid max-connections '%s', expecting an integer", v);
     ++				die(_("invalid max-connections '%s', expecting an integer"), v);
       			if (max_connections < 0)
      -				max_connections = 0;	        /* unlimited */
      +				max_connections = 0;  /* unlimited */
 2:  2ad3b0faa05 = 2:  da9ea10e4e1 merge: replace atoi() with strtol_i() for marker size validation
 3:  d0aa756d2d0 = 3:  8982dca646d imap: replace atoi() with strtol_i() for UIDVALIDITY and UIDNEXT parsing

-- 
gitgitgadget