[patch] Fix BZ 23400 -- stdlib/test-bz22786.c creates temporary files in glibc source tree
Stefan Liebler
stli@linux.ibm.com
Wed Aug 29 13:25:00 GMT 2018
Hi Paul,
If I run the test on s390 (31bit), the test fails with:
malloc: unable to allocate 2147483675 bytes: Cannot allocate memory
warning: could not remove temporary file: /tmp/bz22786.iaoLYS: Directory
not empty
This test tries to allocate a little bit too much bytes for 31bit. Thus
the former implementation returned EXIT_UNSUPPORTED. Now the test is
failing due to xmalloc.
As the symlink was created within the temporary directory
/tmp/bz22786.XXXXXX, but was not unlinked by the test,
support_delete_temp_files() fails to remove it.
Can we just return EXIT_UNSUPPORTED on 31bit as done with the attached
patch?
Bye
Stefan
On 08/06/2018 05:12 PM, Paul Pluzhnikov wrote:
> Thanks for review!
>
> On Mon, Jul 30, 2018 at 1:13 PM Adhemerval Zanella
> <adhemerval.zanella@linaro.org> wrote:
>
>>> + strcpy (lnk, dir);
>>> + strcat (lnk, "/symlink");
>>
>> Maybe just 'char *lnk = xasprintf ("%s/symlink", dir);' instead?
>
> Done.
>
>>> + if (symlink (".", lnk) != 0)
>>> {
>>> printf ("symlink (%s, %s): %m\n", dir, lnk);
>>> return EXIT_FAILURE;
>>
>> Use FAIL_EXIT1 or just TEST_VERIFY_EXIT.
>
> Done.
>
>>> memset (p, 'a', path_len - (path - p) - 2);
>>> p[path_len - (path - p) - 1] = '\0';
>>
>> Shouldn't it 'p - path' instead? The subtraction is clearly issuing a
>> overflow and I think it is not what the test meant here.
>
> Good catch. Turns out that this was a buffer overflow in the original
> test. Fixed.
>
> Thanks,
>
> 2018-08-06 Paul Pluzhnikov <ppluzhnikov@google.com>
>
> [BZ #23400]
> * stdlib/test-bz22786.c (do_test): Fix undefined behavior.
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 20180829_test-bz22786.patch
Type: text/x-patch
Size: 1802 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20180829/1890a2da/attachment.bin>
More information about the Libc-alpha
mailing list