Alejandro Colomar
f39ac101ff
lib/, src/: str2*(): Rename functions and reorder parameters
...
This makes them compatible with liba2i's functions.
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2024-03-29 14:29:13 -05:00
Alejandro Colomar
27e236ca79
lib/, src/, po/: get[u]long(): Move functions to lib/atoi/str2i.h
...
And make them inline.
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2024-03-29 14:29:13 -05:00
Alejandro Colomar
2a9b6d80e7
lib/, src/: getulong(): Use the usual -1 as an error code
...
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2024-01-05 16:54:55 -06:00
Alejandro Colomar
2d581cb337
lib/, src/: getlong(): Use the usual -1 as an error code
...
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2024-01-05 16:54:55 -06:00
Alejandro Colomar
1c464d9a2d
lib/, src/: Fix error handling after strto[u]l[l](3)
...
- Set errno = 0 before the call. Otherwise, it may contain anything.
- ERANGE is not the only possible errno value of these functions. They
can also set it to EINVAL.
- Any errno value after these calls is bad; just compare against 0.
- Don't check for the return value; just errno. This function is
guaranteed to not modify errno on success (POSIX).
- Check endptr == str, which may or may not set EINVAL.
Suggested-by: Iker Pedrosa <ipedrosa@redhat.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2023-12-04 12:21:55 +01:00
Alejandro Colomar
5e0c61cce3
lib/limits.c: Check for overflow without invoking UB
...
The multiplication was already invoking UB. The test was flawed.
Use __builtin_mul_overflow() instead.
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2023-12-04 11:45:09 +01:00
Alejandro Colomar
9b798b584a
lib/limits.c: Fix wrong error check
...
strtol(3) doesn't specify a return value if (value == endptr).
It is always an error, if (value==endptr).
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2023-12-04 11:45:09 +01:00
Alejandro Colomar
4f16458b6c
lib/, src/: Say 'long' instead of 'long int'
...
We were using 'long' in most places, so be consistent and use it
everywhere.
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2023-12-03 09:58:19 -06:00
Alejandro Colomar
f3ee47fe3f
Use MEMZERO() instead of its pattern
...
This patch implicitly adds the safety of SIZEOF_ARRAY(), since the calls
were using sizeof() instead.
Cc: Christian Göttsche <cgzones@googlemail.com >
Cc: Serge Hallyn <serge@hallyn.com >
Cc: Iker Pedrosa <ipedrosa@redhat.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2023-09-01 09:39:23 +02:00
Alejandro Colomar
6b11077f09
memzero.h: Move memzero() and strzero() to their own header
...
Cc: Christian Göttsche <cgzones@googlemail.com >
Cc: Serge Hallyn <serge@hallyn.com >
Cc: Iker Pedrosa <ipedrosa@redhat.com >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2023-09-01 09:39:23 +02:00
Alejandro Colomar
093fb605f9
lib: Merge libmisc into libshadow
...
The separation was unnecessary, and caused build problems. Let's go
wild and obliterate the library. The files are moved to libshadow.
Scripted change:
$ find libmisc/ -type f \
| grep '\.[chy]$' \
| xargs mv -t lib;
Plus updating the Makefile and other references. While at it, I've
sorted the sources lists.
Link: <https://github.com/shadow-maint/shadow/pull/792 >
Reported-by: David Seifert <soap@gentoo.org >
Cc: Sam James <sam@gentoo.org >
Cc: Christian Bricart <christian@bricart.de >
Cc: Michael Vetter <jubalh@iodoru.org >
Cc: Robert Förster <Dessa@gmake.de >
[ soap tested the Gentoo package ]
Tested-by: David Seifert <soap@gentoo.org >
Acked-by: David Seifert <soap@gentoo.org >
Acked-by: Serge Hallyn <serge@hallyn.com >
Acked-by: Iker Pedrosa <ipedrosa@redhat.com >
Acked-by: <lslebodn@fedoraproject.org >
Signed-off-by: Alejandro Colomar <alx@kernel.org >
2023-08-31 08:55:26 +02:00