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

Uh, get some more numbers #899

Draft
wants to merge 32 commits into
base: master
Choose a base branch
from

Commits on May 27, 2024

  1. lib/typetraits.h: Add macros that give information about a type

    In the case of is_unsigned() and is_signed(), the natural thing would be
    to compare to 0:
    
    	#define is_unsigned(x)  (((typeof(x)) -1) > 0)
    	#define is_signed(x)    (((typeof(x)) -1) < 0)
    
    However, that would trigger -Wtype-limits, so we compare against 1,
    which silences that, and does the same job.
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    d06c81f View commit details
    Browse the repository at this point in the history
  2. src/: Use str2[u]l() instead of atoi(3)

    atoi(3) easily triggers Undefined Behavior.  Replace it by str2[u]l(),
    which are safe from that, and add type safety too.
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    b8e914f View commit details
    Browse the repository at this point in the history
  3. lib/get_gid.c: get_gid(): Reimplement in terms of a2i()

    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    105697f View commit details
    Browse the repository at this point in the history
  4. lib/, libsubid/, po/, src/: get_gid(): Move function to "atoi/getnum.h"

    Implement it as an inline function, and add restrict and ATTR_STRING()
    and ATTR_ACCESS() as appropriate.
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    36db6c5 View commit details
    Browse the repository at this point in the history
  5. lib/: Don't open-code get_gid()

    These functions were open-coding get_gid().  Use the actual function.
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    310b3d8 View commit details
    Browse the repository at this point in the history
  6. lib/get_pid.c: get_pid(): Reimplement in terms of a2i()

    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    7b9fe7a View commit details
    Browse the repository at this point in the history
  7. lib/: get_pid(): Move function to "atoi/getnum.h"

    Implement it as an inline function, and add restrict and ATTR_STRING()
    and ATTR_ACCESS() as appropriate.
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    7914f14 View commit details
    Browse the repository at this point in the history
  8. lib/atoi/getnum.[ch]: get_fd(): Add function for parsing a file descr…

    …iptor from a string
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    7d00e66 View commit details
    Browse the repository at this point in the history
  9. lib/get_pid.c: get_pidfd_from_fd(): Don't open-code get_fd()

    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    044396c View commit details
    Browse the repository at this point in the history
  10. src/usermod.c: getulong_range(): Reimplement in terms of a2ul()

    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    0a81ae8 View commit details
    Browse the repository at this point in the history
  11. lib/get_uid.c: get_uid(): Reimplement in terms of a2i()

    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    d9e31c7 View commit details
    Browse the repository at this point in the history
  12. lib/, po/, src/: get_uid(): Move function to "atoi/getnum.h"

    Implement it as an inline function, and add restrict and ATTR_STRING()
    and ATTR_ACCESS() as appropriate.
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    5332860 View commit details
    Browse the repository at this point in the history
  13. lib/limits.c: setrlimit_value(): Reimplement in terms of a2i()

    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    4d4b471 View commit details
    Browse the repository at this point in the history
  14. src/usermod.c: Fix const correctness

    Now that we use liba2i's const-generic macros, we can (and must) use a
    'const char **' endp where the input string is 'const char *'.
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    b85ad7a View commit details
    Browse the repository at this point in the history
  15. lib/getdef.c: getdef_num(): Simplify, by calling a2si() instead of st…

    …r2sl()
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    451d07a View commit details
    Browse the repository at this point in the history
  16. lib/getdef.c: getdef_unum(): Fix wrong limit check

    The limit, since it's an unsigned int, should have been UINT_MAX, not
    INT_MAX.  By calling a2ui() we can fix that and simplify too.
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    6dee811 View commit details
    Browse the repository at this point in the history
  17. lib/getdef.c: getdef_long(): Simplify, by calling a2sl() instead of s…

    …tr2sl()
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    49c4471 View commit details
    Browse the repository at this point in the history
  18. lib/limits.c: set_prio(): Simplify, by calling str2si() instead of st…

    …r2sl()
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    cac5f74 View commit details
    Browse the repository at this point in the history
  19. lib/limits.c: set_umask(): Simplify, by calling str2i(mode_t, ) inste…

    …ad of str2ul()
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    d5ab3b8 View commit details
    Browse the repository at this point in the history
  20. lib/limits.c: setup_limits(): Simplify, by calling a2si() instead of …

    …str2sl()
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    4e89e52 View commit details
    Browse the repository at this point in the history
  21. lib/limits.c: setup_limits(): Simplify, by calling str2si() instead o…

    …f str2sl()
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    426ac24 View commit details
    Browse the repository at this point in the history
  22. lib/limits.c: setup_limits(): Simplify, by calling str2i(mode_t, ) in…

    …stead of str2ul()
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    2ef41f0 View commit details
    Browse the repository at this point in the history
  23. lib/sgetspent.c: sgetspent(): Simplify, by calling a2sl() instead of …

    …str2sl()
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    2b25ce9 View commit details
    Browse the repository at this point in the history
  24. lib/shadow.c: my_sgetspent(): Merge 'else {if}' into 'else if'

    This reduces indentation.
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    bca0f25 View commit details
    Browse the repository at this point in the history
  25. lib/shadow.c: my_sgetspent(): Remove dead code

    spwd.sp_flag is an unsigned long, which can never be negative.
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    482ce21 View commit details
    Browse the repository at this point in the history
  26. lib/shadow.c: my_sgetspent(): Simplify error handling

    Handle negative values as errors from a2sl(), and reuse its
    error-handling code.
    
    Cc: Iker Pedrosa <ipedrosa@redhat.com>
    Cc: "Serge E. Hallyn" <serge@hallyn.com>
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    f3dc975 View commit details
    Browse the repository at this point in the history
  27. src/check_subid_range.c: Call get_uid() instead of str2sl()

    This value represents a uid.
    
    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    68ee8b5 View commit details
    Browse the repository at this point in the history
  28. src/useradd.c: Simplify, by calling a2sl() instead of str2sl()

    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    e6cf1be View commit details
    Browse the repository at this point in the history
  29. src/passwd.c: Simplify, by calling a2sl() instead of str2sl()

    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    dc887b5 View commit details
    Browse the repository at this point in the history
  30. src/usermod.c: Simplify, by calling a2sl() instead of str2sl()

    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    2f08f7e View commit details
    Browse the repository at this point in the history
  31. src/faillog.c: Simplify, by calling str2sh() instead of str2sl()

    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    2fb41cd View commit details
    Browse the repository at this point in the history
  32. src/chage.c: Simplify, by calling a2sl() instead of str2sl()

    Signed-off-by: Alejandro Colomar <alx@kernel.org>
    alejandro-colomar committed May 27, 2024
    Configuration menu
    Copy the full SHA
    07497fb View commit details
    Browse the repository at this point in the history