Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove strtou[l]l_noneg(), replacing them by a2i() calls #895

Merged
merged 4 commits into from
May 27, 2024

Commits on May 27, 2024

  1. lib/gettime.c: gettime(): Call a2i() instead of strtoull_noneg()

    time_t isn't necessarily unsigned (in fact, it's likely to be signed.
    Therefore, parse the number as the right type, via a2i(time_t, ...).
    
    Still, reject negative numbers, just to be cautious.  It was done
    before (strtoull_noneg()), so it shouldn't be a problem.  (However,
    strtoull_noneg() was only introduced recently, and before that we called
    strtoull(3), which silently accepted negative values.)
    
    Remove the limitation of ULONG_MAX, which seems arbitrary.  It probably
    was written in times where 'time_t' had the same length of 'long', and
    this was thus a test that the value didn't overflow 'time_t'.  Such a
    test is implicit in the a2i() call, so forget about it.
    
    Unify the error messages into a single one that provides all the info
    (except the value of 'fallback').
    
    Link: <shadow-maint@cb610d5#r136407772>
    Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
    Cc: Chris Lamb <lamby@debian.org>
    Cc: Serge Hallyn <serge@hallyn.com>
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    9bb6397 View commit details
    Browse the repository at this point in the history
  2. lib/atoi/strtou_noneg.[ch], tests/: strtoull_noneg(): Remove unused f…

    …unction
    
    All call sites were replaced by a2i() recently.
    
    Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    19cc0df View commit details
    Browse the repository at this point in the history
  3. src/check_subid_range.c: Call str2ul() instead of strtoul_noneg()

    It is a simpler call, with more type safety.
    
    A consequence of this change is that the program now accepts numbers in
    bases 8 and 16.  That's not a problem here, I think.
    
    Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    e189b6e View commit details
    Browse the repository at this point in the history
  4. lib/atoi/strtou_noneg.[ch], tests/: strtoul_noneg(): Remove unused fu…

    …nction
    
    All call sites have been replaced by functions from "atoi/a2i.h" and
    "atoi/str2i.h" recently.
    
    Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    15af2f3 View commit details
    Browse the repository at this point in the history