Skip to content

pr-1646/mohit-marathe/update-strtol_i-v5

Hello,

This patch series replaces atoi() with an updated version of strtol_i()
called strtoi_with_tail (Credits: Junio C Hamano). The reasoning behind this
is to improve error handling by not allowing non-numerical characters in the
hunk header (which might happen in case of a corrupt patch, although
rarely).

There is still a change to be made, as Junio says: "A corrupt patch may be
getting a nonsense patch-ID with the current code and hopefully is not
matching other patches that are not corrupt, but with such a change, a
corrupt patch may not be getting any patch-ID and a loop that computes
patch-ID for many files and try to match them up might need to be rewritten
to take the new failure case into account." I'm not sure where this change
needs to me made (maybe get_one_patchid()?). It would be great if anyone
could point me to the correct place.

Thanks, Mohit Marathe

Mohit Marathe (2):
  git-compat-util: add strtoi_with_tail()
  patch-id: replace `atoi()` with `strtoi_with_tail`

 builtin/patch-id.c | 12 ++++++++----
 git-compat-util.h  | 23 +++++++++++++++++++++++
 2 files changed, 31 insertions(+), 4 deletions(-)

base-commit: b50a608ba20348cb3dfc16a696816d51780e3f0f

Submitted-As: https://lore.kernel.org/git/pull.1646.v5.git.1706416952.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.1646.git.1705913519.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.1646.v2.git.1706077977.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.1646.v3.git.1706078885.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.1646.v4.git.1706079304.gitgitgadget@gmail.com
Assets 2