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

Buffer overflow in string_test #208

Closed
yugr opened this issue Mar 20, 2017 · 5 comments
Closed

Buffer overflow in string_test #208

yugr opened this issue Mar 20, 2017 · 5 comments
Milestone

Comments

@yugr
Copy link

yugr commented Mar 20, 2017

The following code in tests/string_test.c will fail to zero-terminate sfname on first iteration which may cause read overflow in psf_store_string:

for (k = 0 ; k < 50 ; k++)
{	const char *result ;
	...
	snprintf (sfname, MIN (k, sizeof (sfname)), "%s", "abcdefghijklmnopqrestvwxyz0123456789abcdefghijklmnopqrestvwxyz") ;
	exit_if_true (sf_set_string (file, SF_STR_SOFTWARE, sfname),

Valgrind report is

==23799== Conditional jump or move depends on uninitialised value(s)
==23799==    at 0x4C30F69: strlen (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) 
==23799==    by 0x52808C1: psf_store_string (/build/libsndfile-1.0.25/src/strings.c:42)
==23799==    by 0x401A6B: software_string_test (/build/libsndfile-1.0.25/tests/string_test.c:646)
==23799==    by 0x401A6B: main (/build/libsndfile-1.0.25/tests/string_test.c:81)

The issue has been found using Valgrind (obviously) and debian_pkg_test.

@erikd
Copy link
Member

erikd commented Mar 21, 2017

libsndfile-1.0.25 is one release old (1.0.26 was released some time ago) and I cannot reproduce this issue on git HEAD.

@yugr
Copy link
Author

yugr commented Mar 21, 2017

True but I've checked that offending code is still there (https://github.com/erikd/libsndfile/blob/master/tests/string_test.c#L684).

@erikd
Copy link
Member

erikd commented Mar 21, 2017

Why do you think that code is the problem?

@erikd
Copy link
Member

erikd commented Mar 21, 2017

I'm pretty sure commit 8868115 is the one that fixed it.

@yugr yugr closed this as completed Mar 21, 2017
@yugr
Copy link
Author

yugr commented Mar 21, 2017

Got it, sorry for noise.

@evpobr evpobr added this to the v1.0.28 milestone Mar 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants