mailing list of musl libc
 help / color / mirror / code / Atom feed
* musl regression tests
@ 2013-07-18 23:20 Kirill Ternosvky
  2013-07-18 23:49 ` Szabolcs Nagy
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Kirill Ternosvky @ 2013-07-18 23:20 UTC (permalink / raw)
  To: musl

/* FILE: scanf-nullbyte-char.c
/*
  Commit: ef5507867b59d19f21437970e87b5d0415c07b2e
  scanf should not append null byte after scanning %c
*/
#include <stdio.h>
#include "test.h"

int main(void)
{
	char target_buffer[2] = { 'a', 'a' };
	char source_buffer = 'b';

	sscanf(&source_buffer, "%c", &target_buffer);

	if(target_buffer[1] != 'a' && !target_buffer[1])
	{
		t_error("scanf stored null byte for %%c conversion\n");
	}

	return 0;
}


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: musl regression tests
  2013-07-18 23:20 musl regression tests Kirill Ternosvky
@ 2013-07-18 23:49 ` Szabolcs Nagy
  2013-07-19 15:40 ` Kirill Ternosvky
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Szabolcs Nagy @ 2013-07-18 23:49 UTC (permalink / raw)
  To: musl

thanks for the test case, i will add it once i get the repo up

* Kirill Ternosvky <kternovsky@yandex.ru> [2013-07-18 19:20:23 -0400]:
> 	char target_buffer[2] = { 'a', 'a' };
> 	char source_buffer = 'b';
> 
> 	sscanf(&source_buffer, "%c", &target_buffer);
> 
> 	if(target_buffer[1] != 'a' && !target_buffer[1])

target_buffer[1] != 'a' is enough in this case
any corruption is a corruption not just 0

> 	{
> 		t_error("scanf stored null byte for %%c conversion\n");
> 	}
> 
> 	return 0;
> }


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: musl regression tests
  2013-07-18 23:20 musl regression tests Kirill Ternosvky
  2013-07-18 23:49 ` Szabolcs Nagy
@ 2013-07-19 15:40 ` Kirill Ternosvky
  2013-07-19 16:45 ` Kirill Ternosvky
  2013-07-19 19:37 ` Kirill Ternosvky
  3 siblings, 0 replies; 5+ messages in thread
From: Kirill Ternosvky @ 2013-07-19 15:40 UTC (permalink / raw)
  To: musl

/* FILE: wcsncpy-read-overflow.c */
/*
  Commit: e98136207ad1a6df1cdc1578e4ad56f8f0db4047
  */
#include <wchar.h>
#include "test.h"

int main(void)
{
	wchar_t dest[] = { 'a', 'a', };
	wchar_t src[] = { 0, 'b', };

	wcsncpy(dest, src, 1);

	if(dest[1] != 'a')
	{
		t_error("wcsncpy copied more than N\n");
	}

	return 0;
}


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: musl regression tests
  2013-07-18 23:20 musl regression tests Kirill Ternosvky
  2013-07-18 23:49 ` Szabolcs Nagy
  2013-07-19 15:40 ` Kirill Ternosvky
@ 2013-07-19 16:45 ` Kirill Ternosvky
  2013-07-19 19:37 ` Kirill Ternosvky
  3 siblings, 0 replies; 5+ messages in thread
From: Kirill Ternosvky @ 2013-07-19 16:45 UTC (permalink / raw)
  To: musl

/* FILE: scanf-bytes-consumed.c */
/*
  * Commit: 5efc6af4ebb9d50eb978d0338835544fdfea0396
  * scanf misreports bytes consumed when EOF is hit (or null for sscanf)
  */

#include <stdio.h>
#include "test.h"

int main(void)
{
	char buf[] = { 'a', 'a', 0 };
	char dest[3];
	int read_count;

	sscanf(buf, "%s%n", dest, &read_count);

	if(read_count != 2)
	{
		t_error("sscanf consumed 2 bytes but reported %d\n", read_count);
	}
}


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: musl regression tests
  2013-07-18 23:20 musl regression tests Kirill Ternosvky
                   ` (2 preceding siblings ...)
  2013-07-19 16:45 ` Kirill Ternosvky
@ 2013-07-19 19:37 ` Kirill Ternosvky
  3 siblings, 0 replies; 5+ messages in thread
From: Kirill Ternosvky @ 2013-07-19 19:37 UTC (permalink / raw)
  To: musl

/* FILE: scanf-match-literal-eof.c */
/*
  * Commit: 5efc6af4ebb9d50eb978d0338835544fdfea0396
  * scanf misreports literal match as input failure when reading EOF (null  
for sscanf)
  */

#include <stdio.h>
#include "test.h"

int main(void)
{
	char buf[] = { 0 };
	int match_count;

	match_count = sscanf(buf, "a");

	if(match_count != EOF)
	{
		t_error("scanf reported match failure instead of input failure on  
literal EOF match\n");
	}

	return t_status;
}


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-07-19 19:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-18 23:20 musl regression tests Kirill Ternosvky
2013-07-18 23:49 ` Szabolcs Nagy
2013-07-19 15:40 ` Kirill Ternosvky
2013-07-19 16:45 ` Kirill Ternosvky
2013-07-19 19:37 ` Kirill Ternosvky

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).