Re: [PATCH] src/ext4_resize.c: set errno to 0 before the strtoull call

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



On Wed, Jan 19, 2022 at 4:20 AM xuyang2018.jy--- via Libc-alpha
<libc-alpha@xxxxxxxxxxxxxx> wrote:
>
> Hi Andrew
>
> errno doesn't be initialized to 0 when c program link with lcap since
> libcap-2.30 (commit f1f62a748d7c Refactor the way we do the psx linkage
> in libcap introduced this bug.)
>
> The c example code as below:
> -------------------------------------------
> #include <stdio.h>
> #include <errno.h>
>
> int main(int argc, char **argv)
> {
>         printf("errno %d\n", errno);
>         return 0;
> }
> ---------------------------------------
>
> #gcc test.c -lcap -o test
> #./test
> errno 1
>

Yes, that reproduces the problem, quite well. (link with
-Wl,--no-as-needed if it does not trigger the bug for you)

This is not a glibc problem though, looks like lcap is clobbering
errno. I'd bet good CLP on the code called in
__attribute__((constructor (300))) static void _initialize_libcap(void) .
I strongly suggest not to use constructors on shared libraries unless
all the components using the library are in your control and you are
sure constructors will not ruin some other application's day.



[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux