diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/bfd-api-change.patch b/bfd-api-change.patch new file mode 100644 index 0000000..7503183 --- /dev/null +++ b/bfd-api-change.patch @@ -0,0 +1,22 @@ +diff --git a/backtrace-symbols.c b/backtrace-symbols.c +index 0176e3f..5384e2e 100644 +--- a/backtrace-symbols.c ++++ b/backtrace-symbols.c +@@ -124,14 +124,14 @@ static void find_address_in_section( + if (arg->found) + return; + +- if ((bfd_get_section_flags(abfd, section) & SEC_ALLOC) == 0) ++ if ((bfd_section_flags(section) & SEC_ALLOC) == 0) + return; + +- bfd_vma const vma = bfd_get_section_vma(abfd, section); ++ bfd_vma const vma = bfd_section_vma(section); + if (arg->pc < vma) + return; + +- bfd_size_type const size = bfd_section_size(abfd, section); ++ bfd_size_type const size = bfd_section_size(section); + if (arg->pc >= vma + size) + return; + diff --git a/gating.yaml b/gating.yaml new file mode 100644 index 0000000..ce3cdc1 --- /dev/null +++ b/gating.yaml @@ -0,0 +1,19 @@ +--- !Policy +product_versions: + - fedora-* +decision_context: bodhi_update_push_stable +subject_type: koji_build +rules: + - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional} +--- !Policy +product_versions: + - rhel-8 +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1.functional} +--- !Policy +product_versions: + - rhel-9 +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1.functional} diff --git a/memstomp-PTR.patch b/memstomp-PTR.patch new file mode 100644 index 0000000..0afb7d8 --- /dev/null +++ b/memstomp-PTR.patch @@ -0,0 +1,17 @@ +diff --git a/backtrace-symbols.c b/backtrace-symbols.c +index 5384e2e..9fc464a 100644 +--- a/backtrace-symbols.c ++++ b/backtrace-symbols.c +@@ -90,10 +90,10 @@ static asymbol **slurp_symtab(bfd *const abfd) + return syms; + + unsigned int size; +- long symcount = bfd_read_minisymbols(abfd, false, (PTR) & syms, &size); ++ long symcount = bfd_read_minisymbols(abfd, false, (void *) & syms, &size); + if (symcount == 0) + symcount = bfd_read_minisymbols(abfd, true /* dynamic */ , +- (PTR) & syms, &size); ++ (void *) & syms, &size); + + if (symcount < 0) + bfd_fatal(bfd_get_filename(abfd)); diff --git a/memstomp-implicit-int.patch b/memstomp-implicit-int.patch new file mode 100644 index 0000000..340a75a --- /dev/null +++ b/memstomp-implicit-int.patch @@ -0,0 +1,372 @@ +diff -Nrup a/testsuite/memstomp.nooverlap/memccpy.c b/testsuite/memstomp.nooverlap/memccpy.c +--- a/testsuite/memstomp.nooverlap/memccpy.c 2015-05-26 19:20:36.001837645 -0600 ++++ b/testsuite/memstomp.nooverlap/memccpy.c 2015-05-26 19:21:12.500043292 -0600 +@@ -12,6 +12,8 @@ TYPE arr2[10] = {0}; + TYPE *p1 = &arr1[0]; + TYPE *p2 = &arr2[1]; + size_t count = 9; ++ ++int + main () + { + MEMCCPY (p1, p2, -1, count); +diff -Nrup a/testsuite/memstomp.nooverlap/memcpy.c b/testsuite/memstomp.nooverlap/memcpy.c +--- a/testsuite/memstomp.nooverlap/memcpy.c 2015-05-26 19:20:36.001837645 -0600 ++++ b/testsuite/memstomp.nooverlap/memcpy.c 2015-05-26 19:21:19.082900022 -0600 +@@ -12,6 +12,8 @@ TYPE arr2[10] = {0}; + TYPE *p1 = &arr1[0]; + TYPE *p2 = &arr2[1]; + size_t count = 9; ++ ++int + main () + { + MEMCPY (p1, p2, count); +diff -Nrup a/testsuite/memstomp.nooverlap/strcpy.c b/testsuite/memstomp.nooverlap/strcpy.c +--- a/testsuite/memstomp.nooverlap/strcpy.c 2015-05-26 19:20:36.001837645 -0600 ++++ b/testsuite/memstomp.nooverlap/strcpy.c 2015-05-26 19:21:50.617213704 -0600 +@@ -11,6 +11,8 @@ char arr1[32] = "this is a test"; + char arr2[32] = "this is a test"; + char *p1 = &arr1[0]; + char *p2 = &arr2[1]; ++ ++int + main () + { + STRCPY (p2, p1); +diff -Nrup a/testsuite/memstomp.nooverlap/strncpy.c b/testsuite/memstomp.nooverlap/strncpy.c +--- a/testsuite/memstomp.nooverlap/strncpy.c 2015-05-26 19:20:36.001837645 -0600 ++++ b/testsuite/memstomp.nooverlap/strncpy.c 2015-05-26 19:21:54.929119859 -0600 +@@ -11,6 +11,8 @@ char arr1[32] = "this is a test"; + char arr2[32] = "this is a test"; + char *p1 = &arr1[0]; + char *p2 = &arr2[1]; ++ ++int + main () + { + STRNCPY (p1, p2, strlen (p2)); +diff -Nrup a/testsuite/memstomp.nooverlap/wcscpy.c b/testsuite/memstomp.nooverlap/wcscpy.c +--- a/testsuite/memstomp.nooverlap/wcscpy.c 2015-05-26 19:20:36.002837623 -0600 ++++ b/testsuite/memstomp.nooverlap/wcscpy.c 2015-05-26 19:21:58.928032826 -0600 +@@ -11,6 +11,8 @@ wchar_t arr1[32] = L"this is a test"; + wchar_t arr2[32] = L"this is a test"; + wchar_t *p1 = &arr1[0]; + wchar_t *p2 = &arr2[1]; ++ ++int + main () + { + WCSCPY (p1, p2); +diff -Nrup a/testsuite/memstomp.nooverlap/wcsncpy.c b/testsuite/memstomp.nooverlap/wcsncpy.c +--- a/testsuite/memstomp.nooverlap/wcsncpy.c 2015-05-26 19:20:36.002837623 -0600 ++++ b/testsuite/memstomp.nooverlap/wcsncpy.c 2015-05-26 19:22:03.184940178 -0600 +@@ -11,6 +11,8 @@ wchar_t arr1[32] = L"this is a test"; + wchar_t arr2[32] = L"this is a test"; + wchar_t *p1 = &arr1[0]; + wchar_t *p2 = &arr2[1]; ++ ++int + main () + { + WCSNCPY (p1, p2, wcslen (p2)); +diff -Nrup a/testsuite/memstomp.null/memccpy.c b/testsuite/memstomp.null/memccpy.c +--- a/testsuite/memstomp.null/memccpy.c 2015-05-26 19:20:36.010837449 -0600 ++++ b/testsuite/memstomp.null/memccpy.c 2015-05-26 19:22:08.530823830 -0600 +@@ -12,6 +12,8 @@ TYPE arr2[10] = {0}; + TYPE *p1 = &arr1[0]; + TYPE *p2 = &arr2[1]; + size_t count = 9; ++ ++int + main () + { + MEMCCPY (NULL, NULL, -1, 0); +diff -Nrup a/testsuite/memstomp.null/memcpy.c b/testsuite/memstomp.null/memcpy.c +--- a/testsuite/memstomp.null/memcpy.c 2015-05-26 19:20:36.011837427 -0600 ++++ b/testsuite/memstomp.null/memcpy.c 2015-05-26 19:22:13.504715577 -0600 +@@ -12,6 +12,8 @@ TYPE arr2[10] = {0}; + TYPE *p1 = &arr1[0]; + TYPE *p2 = &arr2[1]; + size_t count = 9; ++ ++int + main () + { + return MEMCPY (NULL, NULL, 0) == 0 ; +diff -Nrup a/testsuite/memstomp.null/memmem.c b/testsuite/memstomp.null/memmem.c +--- a/testsuite/memstomp.null/memmem.c 2015-05-26 19:20:36.011837427 -0600 ++++ b/testsuite/memstomp.null/memmem.c 2015-05-26 19:22:16.232656205 -0600 +@@ -12,6 +12,8 @@ TYPE arr2[10] = {0}; + TYPE *p1 = &arr1[0]; + TYPE *p2 = &arr2[1]; + size_t count = 9; ++ ++int + main () + { + return MEMMEM (NULL, 0, NULL, 0) == 0 ; +diff -Nrup a/testsuite/memstomp.null/memset.c b/testsuite/memstomp.null/memset.c +--- a/testsuite/memstomp.null/memset.c 2015-05-26 19:20:36.011837427 -0600 ++++ b/testsuite/memstomp.null/memset.c 2015-05-26 19:22:22.800513262 -0600 +@@ -12,6 +12,8 @@ TYPE arr2[10] = {0}; + TYPE *p1 = &arr1[0]; + TYPE *p2 = &arr2[1]; + size_t count = 9; ++ ++int + main () + { + return MEMSET (NULL, -1, 0) == 0; +diff -Nrup a/testsuite/memstomp.null/rawmemchr.c b/testsuite/memstomp.null/rawmemchr.c +--- a/testsuite/memstomp.null/rawmemchr.c 2015-05-26 19:20:36.011837427 -0600 ++++ b/testsuite/memstomp.null/rawmemchr.c 2015-05-26 19:22:25.857446730 -0600 +@@ -12,6 +12,8 @@ TYPE arr2[10] = {0}; + TYPE *p1 = &arr1[0]; + TYPE *p2 = &arr2[1]; + size_t count = 9; ++ ++int + main () + { + return RAWMEMCHR (NULL, 0) == 0; +diff -Nrup a/testsuite/memstomp.null/strcmp.c b/testsuite/memstomp.null/strcmp.c +--- a/testsuite/memstomp.null/strcmp.c 2015-05-26 19:20:36.012837405 -0600 ++++ b/testsuite/memstomp.null/strcmp.c 2015-05-26 19:22:37.049203151 -0600 +@@ -11,6 +11,8 @@ char arr1[32] = "this is a test"; + char arr2[32] = "this is a test"; + char *p1 = &arr1[0]; + char *p2 = &arr2[1]; ++ ++int + main () + { + return STRCMP (NULL, NULL) == 0; +diff -Nrup a/testsuite/memstomp.null/strcoll_l.c b/testsuite/memstomp.null/strcoll_l.c +--- a/testsuite/memstomp.null/strcoll_l.c 2015-05-26 19:20:36.012837405 -0600 ++++ b/testsuite/memstomp.null/strcoll_l.c 2015-05-26 19:22:41.097115051 -0600 +@@ -11,6 +11,8 @@ char arr1[32] = "this is a test"; + char arr2[32] = "this is a test"; + char *p1 = &arr1[0]; + char *p2 = &arr2[1]; ++ ++int + main () + { + return STRCMP (NULL, NULL, NULL); +diff -Nrup a/testsuite/memstomp.null/strcpy.c b/testsuite/memstomp.null/strcpy.c +--- a/testsuite/memstomp.null/strcpy.c 2015-05-26 19:20:36.012837405 -0600 ++++ b/testsuite/memstomp.null/strcpy.c 2015-05-26 19:22:44.695036746 -0600 +@@ -11,6 +11,8 @@ char arr1[32] = "this is a test"; + char arr2[32] = "this is a test"; + char *p1 = &arr1[0]; + char *p2 = &arr2[1]; ++ ++int + main () + { + STRCPY (NULL, NULL); +diff -Nrup a/testsuite/memstomp.null/strlen.c b/testsuite/memstomp.null/strlen.c +--- a/testsuite/memstomp.null/strlen.c 2015-05-26 19:20:36.012837405 -0600 ++++ b/testsuite/memstomp.null/strlen.c 2015-05-26 19:22:49.456933107 -0600 +@@ -11,6 +11,8 @@ char arr1[32] = "this is a test"; + char arr2[32] = "this is a test"; + char *p1 = &arr1[0]; + char *p2 = &arr2[1]; ++ ++int + main () + { + return STRLEN (NULL) == 0; +diff -Nrup a/testsuite/memstomp.null/strncmp.c b/testsuite/memstomp.null/strncmp.c +--- a/testsuite/memstomp.null/strncmp.c 2015-05-26 19:20:36.012837405 -0600 ++++ b/testsuite/memstomp.null/strncmp.c 2015-05-26 19:22:53.383847641 -0600 +@@ -11,6 +11,8 @@ char arr1[32] = "this is a test"; + char arr2[32] = "this is a test"; + char *p1 = &arr1[0]; + char *p2 = &arr2[1]; ++ ++int + main () + { + return STRNCMP (NULL, NULL, 0); +diff -Nrup a/testsuite/memstomp.null/strncpy.c b/testsuite/memstomp.null/strncpy.c +--- a/testsuite/memstomp.null/strncpy.c 2015-05-26 19:20:36.012837405 -0600 ++++ b/testsuite/memstomp.null/strncpy.c 2015-05-26 19:22:56.135787748 -0600 +@@ -11,6 +11,8 @@ char arr1[32] = "this is a test"; + char arr2[32] = "this is a test"; + char *p1 = &arr1[0]; + char *p2 = &arr2[1]; ++ ++int + main () + { + STRNCPY (NULL, NULL, 0); +diff -Nrup a/testsuite/memstomp.null/strtok_r.c b/testsuite/memstomp.null/strtok_r.c +--- a/testsuite/memstomp.null/strtok_r.c 2015-05-26 19:20:36.013837384 -0600 ++++ b/testsuite/memstomp.null/strtok_r.c 2015-05-26 19:23:04.464606478 -0600 +@@ -12,6 +12,8 @@ TYPE arr2[10] = {0}; + TYPE *p1 = &arr1[0]; + TYPE *p2 = &arr2[1]; + size_t count = 9; ++ ++int + main () + { + return STRTOK_R (NULL, NULL, NULL) == 0 ; +diff -Nrup a/testsuite/memstomp.null/strxfrm_l.c b/testsuite/memstomp.null/strxfrm_l.c +--- a/testsuite/memstomp.null/strxfrm_l.c 2015-05-26 19:20:36.013837384 -0600 ++++ b/testsuite/memstomp.null/strxfrm_l.c 2015-05-26 19:23:10.319479051 -0600 +@@ -11,6 +11,8 @@ char arr1[32] = "this is a test"; + char arr2[32] = "this is a test"; + char *p1 = &arr1[0]; + char *p2 = &arr2[1]; ++ ++int + main () + { + return STRCMP (NULL, NULL, 0, NULL); +diff -Nrup a/testsuite/memstomp.overlap/memccpy-2.c b/testsuite/memstomp.overlap/memccpy-2.c +--- a/testsuite/memstomp.overlap/memccpy-2.c 2015-05-26 19:20:36.002837623 -0600 ++++ b/testsuite/memstomp.overlap/memccpy-2.c 2015-05-26 19:23:17.583320672 -0600 +@@ -11,6 +11,8 @@ TYPE arr[10] = {0}; + TYPE *p1 = &arr[0]; + TYPE *p2 = &arr[1]; + size_t count = 9; ++ ++int + main () + { + MEMCCPY (p2, p1, -1, count); +diff -Nrup a/testsuite/memstomp.overlap/memccpy.c b/testsuite/memstomp.overlap/memccpy.c +--- a/testsuite/memstomp.overlap/memccpy.c 2015-05-26 19:20:36.002837623 -0600 ++++ b/testsuite/memstomp.overlap/memccpy.c 2015-05-26 19:23:20.623254323 -0600 +@@ -11,6 +11,8 @@ TYPE arr[10] = {0}; + TYPE *p1 = &arr[0]; + TYPE *p2 = &arr[1]; + size_t count = 9; ++ ++int + main () + { + MEMCCPY (p1, p2, -1, count); +diff -Nrup a/testsuite/memstomp.overlap/memcpy-2.c b/testsuite/memstomp.overlap/memcpy-2.c +--- a/testsuite/memstomp.overlap/memcpy-2.c 2015-05-26 19:20:36.002837623 -0600 ++++ b/testsuite/memstomp.overlap/memcpy-2.c 2015-05-26 19:23:23.823184481 -0600 +@@ -11,6 +11,8 @@ TYPE arr[10] = {0}; + TYPE *p1 = &arr[0]; + TYPE *p2 = &arr[1]; + size_t count = 9; ++ ++int + main () + { + MEMCPY (p2, p1, count); +diff -Nrup a/testsuite/memstomp.overlap/memcpy.c b/testsuite/memstomp.overlap/memcpy.c +--- a/testsuite/memstomp.overlap/memcpy.c 2015-05-26 19:20:36.002837623 -0600 ++++ b/testsuite/memstomp.overlap/memcpy.c 2015-05-26 19:23:26.559124767 -0600 +@@ -11,6 +11,8 @@ TYPE arr[10] = {0}; + TYPE *p1 = &arr[0]; + TYPE *p2 = &arr[1]; + size_t count = 9; ++ ++int + main () + { + MEMCPY (p1, p2, count); +diff -Nrup a/testsuite/memstomp.overlap/strcpy-2.c b/testsuite/memstomp.overlap/strcpy-2.c +--- a/testsuite/memstomp.overlap/strcpy-2.c 2015-05-26 19:20:36.003837601 -0600 ++++ b/testsuite/memstomp.overlap/strcpy-2.c 2015-05-26 19:23:37.055895666 -0600 +@@ -10,6 +10,8 @@ + char arr[32] = "this is a test"; + char *p1 = &arr[0]; + char *p2 = &arr[1]; ++ ++int + main () + { + STRCPY (p1, p2); +diff -Nrup a/testsuite/memstomp.overlap/strcpy.c b/testsuite/memstomp.overlap/strcpy.c +--- a/testsuite/memstomp.overlap/strcpy.c 2015-05-26 19:20:36.003837601 -0600 ++++ b/testsuite/memstomp.overlap/strcpy.c 2015-05-26 19:23:40.231826349 -0600 +@@ -10,6 +10,8 @@ + char arr[32] = "this is a test"; + char *p1 = &arr[0]; + char *p2 = &arr[1]; ++ ++int + main () + { + STRCPY (p2, p1); +diff -Nrup a/testsuite/memstomp.overlap/strncpy-2.c b/testsuite/memstomp.overlap/strncpy-2.c +--- a/testsuite/memstomp.overlap/strncpy-2.c 2015-05-26 19:20:36.003837601 -0600 ++++ b/testsuite/memstomp.overlap/strncpy-2.c 2015-05-26 19:23:45.158718815 -0600 +@@ -10,6 +10,8 @@ + char arr[32] = "this is a test"; + char *p1 = &arr[0]; + char *p2 = &arr[1]; ++ ++int + main () + { + STRNCPY (p2, p1, strlen (p1)); +diff -Nrup a/testsuite/memstomp.overlap/strncpy.c b/testsuite/memstomp.overlap/strncpy.c +--- a/testsuite/memstomp.overlap/strncpy.c 2015-05-26 19:20:36.003837601 -0600 ++++ b/testsuite/memstomp.overlap/strncpy.c 2015-05-26 19:23:48.311650000 -0600 +@@ -10,6 +10,8 @@ + char arr[32] = "this is a test"; + char *p1 = &arr[0]; + char *p2 = &arr[1]; ++ ++int + main () + { + STRNCPY (p1, p2, strlen (p2)); +diff -Nrup a/testsuite/memstomp.overlap/wcscpy-2.c b/testsuite/memstomp.overlap/wcscpy-2.c +--- a/testsuite/memstomp.overlap/wcscpy-2.c 2015-05-26 19:20:36.003837601 -0600 ++++ b/testsuite/memstomp.overlap/wcscpy-2.c 2015-05-26 19:23:53.167544016 -0600 +@@ -10,6 +10,8 @@ + wchar_t arr[32] = L"this is a test"; + wchar_t *p1 = &arr[0]; + wchar_t *p2 = &arr[1]; ++ ++int + main () + { + WCSCPY (p2, p1); +diff -Nrup a/testsuite/memstomp.overlap/wcscpy.c b/testsuite/memstomp.overlap/wcscpy.c +--- a/testsuite/memstomp.overlap/wcscpy.c 2015-05-26 19:20:36.003837601 -0600 ++++ b/testsuite/memstomp.overlap/wcscpy.c 2015-05-26 19:23:56.070480657 -0600 +@@ -10,6 +10,8 @@ + wchar_t arr[32] = L"this is a test"; + wchar_t *p1 = &arr[0]; + wchar_t *p2 = &arr[1]; ++ ++int + main () + { + WCSCPY (p1, p2); +diff -Nrup a/testsuite/memstomp.overlap/wcsncpy-2.c b/testsuite/memstomp.overlap/wcsncpy-2.c +--- a/testsuite/memstomp.overlap/wcsncpy-2.c 2015-05-26 19:20:36.003837601 -0600 ++++ b/testsuite/memstomp.overlap/wcsncpy-2.c 2015-05-26 19:24:00.279388794 -0600 +@@ -10,6 +10,8 @@ + wchar_t arr[32] = L"this is a test"; + wchar_t *p1 = &arr[0]; + wchar_t *p2 = &arr[1]; ++ ++int + main () + { + WCSNCPY (p2, p1, wcslen (p2)); +diff -Nrup a/testsuite/memstomp.overlap/wcsncpy.c b/testsuite/memstomp.overlap/wcsncpy.c +--- a/testsuite/memstomp.overlap/wcsncpy.c 2015-05-26 19:20:36.003837601 -0600 ++++ b/testsuite/memstomp.overlap/wcsncpy.c 2015-05-26 19:24:03.222324562 -0600 +@@ -10,6 +10,8 @@ + wchar_t arr[32] = L"this is a test"; + wchar_t *p1 = &arr[0]; + wchar_t *p2 = &arr[1]; ++ ++int + main () + { + WCSNCPY (p1, p2, wcslen (p2)); diff --git a/memstomp-man.patch b/memstomp-man.patch index d06462f..b6839f6 100644 --- a/memstomp-man.patch +++ b/memstomp-man.patch @@ -9,25 +9,76 @@ CLEANFILES = \ memstomp ---- /dev/null 2013-02-26 15:11:24.372721019 -0700 -+++ b/memstomp.man 2013-03-11 21:54:06.847082615 -0600 -@@ -0,0 +1,19 @@ +diff -Nrup a/memstomp.man b/memstomp.man +--- a/memstomp.man 1969-12-31 17:00:00.000000000 -0700 ++++ b/memstomp.man 2013-05-10 17:53:37.767722170 -0600 +@@ -0,0 +1,69 @@ +.\" This is a comment +.\" Contact Owen@thelinuxblog.com -+.TH memstomp 1 "05 February 2013" ".1" "memstomp" ++.TH MEMSTOMP 1 "09 April 2013" "0.1.4" +.SH NAME -+memstomp ++memstomp \- detect function calls with overlapping memory regions +.SH SYNOPSIS -+memstomp [OPTIONS...] APPLICATION [ARGUMENTS...] ++.B memstomp ++.RB [ \-dk ] ++.I application ++.RI [ argument ...] ++.PP ++.B memstomp ++.B \-h +.SH DESCRIPTION -+memstomp can help detect memory argument overlaps to various mem* and str* functions. ++The ++.B memstomp ++utility identifies function calls that use overlapping memory regions in situations when such an overlap is not allowed by various standards. When a problem is detected, memstomp displays a backtrace to help you debug the problem, and if executed with the ++.B \-\-debug\-info ++command line option, it even uses the available debugging information. Since the backtrace code is not thread safe, memstomp also allows you to use the ++.B \-\-kill ++option to immediately terminate the analyzed program when an invalid function call is detected. ++.PP ++This version of memstomp inspects the following function calls: ++.BR memcpy (), ++.BR memccpy (), ++.BR mempcpy (), ++.BR strcpy (), ++.BR stpcpy (), ++.BR strncpy (), ++.BR stpncpy (), ++.BR strcat (), ++.BR strncat (), ++.BR wmemcpy (), ++.BR wmempcpy (), ++.BR wcscpy (), ++.BR wcsncpy (), ++.BR wcscat (), ++and ++.BR wcsncat (). +.SH OPTIONS -+-h, --help Show help -+ -+-d, --debug-info Make use of debug information in stack traces -+ -+-k, --kill Kill application when problem is detected -+ ++.TP ++.BR \-d ", " \-\-debug\-info ++Make use of debugging information to produce more detailed stack traces. ++.TP ++.BR \-k ", " \-\-kill ++Kill the analyzed application when a problem is detected. ++.TP ++.BR \-h ", " \-\-help ++Display usage information and exit. +.SH SEE ALSO -+.SH BUGS -+ ++.BR memcpy (3), ++.BR memccpy (3), ++.BR mempcpy (3), ++.BR strcpy (3), ++.BR stpcpy (3), ++.BR strncpy (3), ++.BR stpncpy (3), ++.BR strcat (3), ++.BR strncat (3), ++.BR wmemcpy (3), ++.BR wmempcpy (3), ++.BR wcscpy (3), ++.BR wcsncpy (3), ++.BR wcscat (3), ++.BR wcsncat (3) ++.SH AUTHORS ++Lennart Poettering ++.br ++William Cohen diff --git a/memstomp-quietmode.patch b/memstomp-quietmode.patch new file mode 100644 index 0000000..727ffed --- /dev/null +++ b/memstomp-quietmode.patch @@ -0,0 +1,83 @@ +diff -Nrup a/memstomp.c b/memstomp.c +--- a/memstomp.c 2013-05-30 06:02:56.578486389 -0600 ++++ b/memstomp.c 2013-05-30 06:06:42.648731070 -0600 +@@ -64,6 +64,8 @@ + + static bool abrt_trap = false; + ++static bool quiet_mode = false; ++ + #ifndef SCHED_RESET_ON_FORK + /* "Your libc lacks the definition of SCHED_RESET_ON_FORK. We'll now + * define it ourselves, however make sure your kernel is new +@@ -162,7 +164,10 @@ static void setup(void) { + if (LIKELY(initialized)) + return; + +- if (!dlsym(NULL, "main")) ++ if (getenv("MEMSTOMP_QUIET")) ++ quiet_mode = true; ++ ++ if (!dlsym(NULL, "main") && !quiet_mode) + fprintf(stderr, + "memstomp: Application appears to be compiled without -rdynamic. It might be a\n" + "memstomp: good idea to recompile with -rdynamic enabled since this produces more\n" +@@ -173,9 +178,11 @@ static void setup(void) { + + initialized = true; + +- char prname[17]; +- fprintf(stderr, "memstomp: "PACKAGE_VERSION" successfully initialized for process %s (pid %lu).\n", +- get_prname(prname), (unsigned long) getpid()); ++ if (!quiet_mode) { ++ char prname[17]; ++ fprintf(stderr, "memstomp: "PACKAGE_VERSION" successfully initialized for process %s (pid %lu).\n", ++ get_prname(prname), (unsigned long) getpid()); ++ } + } + + static void show_summary(void) { } +diff -Nrup a/memstomp.in b/memstomp.in +--- a/memstomp.in 2011-03-30 21:27:19.000000000 -0600 ++++ b/memstomp.in 2013-05-30 06:06:42.649731067 -0600 +@@ -18,7 +18,7 @@ + # You should have received a copy of the GNU Lesser General Public + # License along with memstomp. If not, see . + +-if ! TEMP=`getopt -o +dhk --long help,debug-info,kill -n memstomp -- "$@"` ; then ++if ! TEMP=`getopt -o +dqhk --long help,quiet,debug-info,kill -n memstomp -- "$@"` ; then + exit 1 + fi + +@@ -38,6 +38,10 @@ while : ; do + shift 1 + ;; + ++ -q|--quiet) ++ export MEMSTOMP_QUIET=1 ++ shift 1 ++ ;; + + -h|--help) + cat < ++#include ++ ++#ifndef MEMCCPY ++#define MEMCCPY memccpy ++#define TYPE char ++#endif ++ ++TYPE arr1[10] = {0}; ++TYPE arr2[10] = {0}; ++TYPE *p1 = &arr1[0]; ++TYPE *p2 = &arr2[1]; ++size_t count = 9; ++main () ++{ ++ MEMCCPY (NULL, NULL, -1, 0); ++} ++ ++ +diff -Nrup a/testsuite/memstomp.null/memchr.c b/testsuite/memstomp.null/memchr.c +--- a/testsuite/memstomp.null/memchr.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/memchr.c 2014-05-29 14:09:04.667841941 -0600 +@@ -0,0 +1,4 @@ ++#define MEMSET memchr ++#define TYPE char ++#include "memset.c" ++ +diff -Nrup a/testsuite/memstomp.null/memcmp.c b/testsuite/memstomp.null/memcmp.c +--- a/testsuite/memstomp.null/memcmp.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/memcmp.c 2014-05-29 13:57:53.098567650 -0600 +@@ -0,0 +1,3 @@ ++#define MEMCPY memcmp ++#define TYPE char ++#include "memcpy.c" +diff -Nrup a/testsuite/memstomp.null/memcpy.c b/testsuite/memstomp.null/memcpy.c +--- a/testsuite/memstomp.null/memcpy.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/memcpy.c 2014-05-29 14:01:34.002999896 -0600 +@@ -0,0 +1,20 @@ ++#define _GNU_SOURCE ++#include ++#include ++ ++#ifndef MEMCPY ++#define MEMCPY memcpy ++#define TYPE char ++#endif ++ ++TYPE arr1[10] = {0}; ++TYPE arr2[10] = {0}; ++TYPE *p1 = &arr1[0]; ++TYPE *p2 = &arr2[1]; ++size_t count = 9; ++main () ++{ ++ return MEMCPY (NULL, NULL, 0) == 0 ; ++} ++ ++ +diff -Nrup a/testsuite/memstomp.null/memmem.c b/testsuite/memstomp.null/memmem.c +--- a/testsuite/memstomp.null/memmem.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/memmem.c 2014-05-29 14:18:37.569363960 -0600 +@@ -0,0 +1,20 @@ ++#define _GNU_SOURCE ++#include ++#include ++ ++#ifndef MEMMEM ++#define MEMMEM memmem ++#define TYPE char ++#endif ++ ++TYPE arr1[10] = {0}; ++TYPE arr2[10] = {0}; ++TYPE *p1 = &arr1[0]; ++TYPE *p2 = &arr2[1]; ++size_t count = 9; ++main () ++{ ++ return MEMMEM (NULL, 0, NULL, 0) == 0 ; ++} ++ ++ +diff -Nrup a/testsuite/memstomp.null/memmove.c b/testsuite/memstomp.null/memmove.c +--- a/testsuite/memstomp.null/memmove.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/memmove.c 2014-05-29 13:57:29.563628151 -0600 +@@ -0,0 +1,3 @@ ++#define MEMCPY memmove ++#define TYPE char ++#include "memcpy.c" +diff -Nrup a/testsuite/memstomp.null/mempcpy.c b/testsuite/memstomp.null/mempcpy.c +--- a/testsuite/memstomp.null/mempcpy.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/mempcpy.c 2014-05-29 12:42:18.358166208 -0600 +@@ -0,0 +1,3 @@ ++#define MEMCPY mempcpy ++#define TYPE char ++#include "memcpy.c" +diff -Nrup a/testsuite/memstomp.null/memrchr.c b/testsuite/memstomp.null/memrchr.c +--- a/testsuite/memstomp.null/memrchr.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/memrchr.c 2014-05-29 14:09:22.122797099 -0600 +@@ -0,0 +1,4 @@ ++#define MEMSET memrchr ++#define TYPE char ++#include "memset.c" ++ +diff -Nrup a/testsuite/memstomp.null/memset.c b/testsuite/memstomp.null/memset.c +--- a/testsuite/memstomp.null/memset.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/memset.c 2014-05-29 14:08:06.411991603 -0600 +@@ -0,0 +1,20 @@ ++#define _GNU_SOURCE ++#include ++#include ++ ++#ifndef MEMSET ++#define MEMSET memset ++#define TYPE char ++#endif ++ ++TYPE arr1[10] = {0}; ++TYPE arr2[10] = {0}; ++TYPE *p1 = &arr1[0]; ++TYPE *p2 = &arr2[1]; ++size_t count = 9; ++main () ++{ ++ return MEMSET (NULL, -1, 0) == 0; ++} ++ ++ +diff -Nrup a/testsuite/memstomp.null/null.exp b/testsuite/memstomp.null/null.exp +--- a/testsuite/memstomp.null/null.exp 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/null.exp 2014-05-29 12:42:18.358166208 -0600 +@@ -0,0 +1,59 @@ ++# Copyright (C) 2013 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with GCC; see the file COPYING3. If not see ++# . ++# ++# This was originally copied from GCC's dejagnu testing framework ++# ++ ++load_lib memstomp.exp ++set memstomp [find_memstomp] ++set libmemstomp [find_libmemstomp] ++ ++if $tracelevel then { ++ strace $tracelevel ++} ++ ++# ++# main test loop ++# ++ ++proc compile-and-execute { sources } { ++ global memstomp ++ global libmemstomp ++ ++ set src [lindex $sources 0] ++ ++ if {[catch {exec gcc -fno-builtin $src} results]} { ++ fail "$src compilation $results" ++ } else { ++ pass "$src compilation $results" ++ } ++ ++ catch {exec /bin/bash -c "LD_PRELOAD=$libmemstomp $memstomp ./a.out"} results ++ if {[regexp "NULL pointer" $results]} { ++ pass "$src found NULL $results" ++ } else { ++ fail "$src found NULL $results" ++ } ++} ++ ++foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] { ++ # If we're only testing specific files and this isn't one of them, skip it. ++ if ![runtest_file_p $runtests $src] then { ++ continue ++ } ++ ++ compile-and-execute $src ++} +diff -Nrup a/testsuite/memstomp.null/rawmemchr.c b/testsuite/memstomp.null/rawmemchr.c +--- a/testsuite/memstomp.null/rawmemchr.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/rawmemchr.c 2014-05-29 14:10:36.610605748 -0600 +@@ -0,0 +1,20 @@ ++#define _GNU_SOURCE ++#include ++#include ++ ++#ifndef RAWMEMCHR ++#define RAWMEMCHR rawmemchr ++#define TYPE char ++#endif ++ ++TYPE arr1[10] = {0}; ++TYPE arr2[10] = {0}; ++TYPE *p1 = &arr1[0]; ++TYPE *p2 = &arr2[1]; ++size_t count = 9; ++main () ++{ ++ return RAWMEMCHR (NULL, 0) == 0; ++} ++ ++ +diff -Nrup a/testsuite/memstomp.null/stpcpy.c b/testsuite/memstomp.null/stpcpy.c +--- a/testsuite/memstomp.null/stpcpy.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/stpcpy.c 2014-05-29 12:42:18.358166208 -0600 +@@ -0,0 +1,2 @@ ++#define STRCPY stpcpy ++#include "strcpy.c" +diff -Nrup a/testsuite/memstomp.null/stpncpy.c b/testsuite/memstomp.null/stpncpy.c +--- a/testsuite/memstomp.null/stpncpy.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/stpncpy.c 2014-05-29 12:42:18.358166208 -0600 +@@ -0,0 +1,2 @@ ++#define STRNCPY stpncpy ++#include "strncpy.c" +diff -Nrup a/testsuite/memstomp.null/strcasestr.c b/testsuite/memstomp.null/strcasestr.c +--- a/testsuite/memstomp.null/strcasestr.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/strcasestr.c 2014-05-29 14:18:59.099308034 -0600 +@@ -0,0 +1,2 @@ ++#define STRCMP strstr ++#include "strcmp.c" +diff -Nrup a/testsuite/memstomp.null/strcat.c b/testsuite/memstomp.null/strcat.c +--- a/testsuite/memstomp.null/strcat.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/strcat.c 2014-05-29 12:42:18.359166205 -0600 +@@ -0,0 +1,2 @@ ++#define STRCPY strcat ++#include "strcpy.c" +diff -Nrup a/testsuite/memstomp.null/strchr.c b/testsuite/memstomp.null/strchr.c +--- a/testsuite/memstomp.null/strchr.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/strchr.c 2014-05-29 14:13:39.929134865 -0600 +@@ -0,0 +1,4 @@ ++#define RAWMEMCHR strchr ++#define TYPE char ++#include "rawmemchr.c" ++ +diff -Nrup a/testsuite/memstomp.null/strchrnul.c b/testsuite/memstomp.null/strchrnul.c +--- a/testsuite/memstomp.null/strchrnul.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/strchrnul.c 2014-05-29 14:15:17.983882584 -0600 +@@ -0,0 +1,4 @@ ++#define RAWMEMCHR strrchr ++#define TYPE char ++#include "rawmemchr.c" ++ +diff -Nrup a/testsuite/memstomp.null/strcmp.c b/testsuite/memstomp.null/strcmp.c +--- a/testsuite/memstomp.null/strcmp.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/strcmp.c 2014-05-29 14:17:21.903560538 -0600 +@@ -0,0 +1,19 @@ ++#define _GNU_SOURCE ++#include ++#include ++ ++#ifndef STRCMP ++#define STRCMP strcmp ++#endif ++ ++ ++char arr1[32] = "this is a test"; ++char arr2[32] = "this is a test"; ++char *p1 = &arr1[0]; ++char *p2 = &arr2[1]; ++main () ++{ ++ return STRCMP (NULL, NULL) == 0; ++} ++ ++ +diff -Nrup a/testsuite/memstomp.null/strcoll.c b/testsuite/memstomp.null/strcoll.c +--- a/testsuite/memstomp.null/strcoll.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/strcoll.c 2014-05-29 14:04:39.735522619 -0600 +@@ -0,0 +1,2 @@ ++#define STRNCPY strcoll ++#include "strcmp.c" +Binary files a/testsuite/memstomp.null/.strcoll.c.swp and b/testsuite/memstomp.null/.strcoll.c.swp differ +diff -Nrup a/testsuite/memstomp.null/strcoll_l.c b/testsuite/memstomp.null/strcoll_l.c +--- a/testsuite/memstomp.null/strcoll_l.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/strcoll_l.c 2014-05-29 14:05:22.181413555 -0600 +@@ -0,0 +1,19 @@ ++#define _GNU_SOURCE ++#include ++#include ++ ++#ifndef STRCMP ++#define STRCMP strcoll_l ++#endif ++ ++ ++char arr1[32] = "this is a test"; ++char arr2[32] = "this is a test"; ++char *p1 = &arr1[0]; ++char *p2 = &arr2[1]; ++main () ++{ ++ return STRCMP (NULL, NULL, NULL); ++} ++ ++ +diff -Nrup a/testsuite/memstomp.null/strcpy.c b/testsuite/memstomp.null/strcpy.c +--- a/testsuite/memstomp.null/strcpy.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/strcpy.c 2014-05-29 12:42:18.359166205 -0600 +@@ -0,0 +1,19 @@ ++#define _GNU_SOURCE ++#include ++#include ++ ++#ifndef STRCPY ++#define STRCPY strcpy ++#endif ++ ++ ++char arr1[32] = "this is a test"; ++char arr2[32] = "this is a test"; ++char *p1 = &arr1[0]; ++char *p2 = &arr2[1]; ++main () ++{ ++ STRCPY (NULL, NULL); ++} ++ ++ +diff -Nrup a/testsuite/memstomp.null/strcspn.c b/testsuite/memstomp.null/strcspn.c +--- a/testsuite/memstomp.null/strcspn.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/strcspn.c 2014-05-29 14:16:12.219741618 -0600 +@@ -0,0 +1,2 @@ ++#define STRCMP strcspn ++#include "strcmp.c" +diff -Nrup a/testsuite/memstomp.null/strdup.c b/testsuite/memstomp.null/strdup.c +--- a/testsuite/memstomp.null/strdup.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/strdup.c 2014-05-29 14:12:20.521338829 -0600 +@@ -0,0 +1,3 @@ ++#define STRLEN strdup ++#define TYPE char ++#include "strlen.c" +diff -Nrup a/testsuite/memstomp.null/strlen.c b/testsuite/memstomp.null/strlen.c +--- a/testsuite/memstomp.null/strlen.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/strlen.c 2014-05-29 14:12:28.969317129 -0600 +@@ -0,0 +1,19 @@ ++#define _GNU_SOURCE ++#include ++#include ++ ++#ifndef STRLEN ++#define STRLEN strlen ++#endif ++ ++ ++char arr1[32] = "this is a test"; ++char arr2[32] = "this is a test"; ++char *p1 = &arr1[0]; ++char *p2 = &arr2[1]; ++main () ++{ ++ return STRLEN (NULL) == 0; ++} ++ ++ +diff -Nrup a/testsuite/memstomp.null/strncat.c b/testsuite/memstomp.null/strncat.c +--- a/testsuite/memstomp.null/strncat.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/strncat.c 2014-05-29 12:42:18.359166205 -0600 +@@ -0,0 +1,2 @@ ++#define STRNCPY strncat ++#include "strncpy.c" +diff -Nrup a/testsuite/memstomp.null/strncmp.c b/testsuite/memstomp.null/strncmp.c +--- a/testsuite/memstomp.null/strncmp.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/strncmp.c 2014-05-29 14:03:31.222698668 -0600 +@@ -0,0 +1,19 @@ ++#define _GNU_SOURCE ++#include ++#include ++ ++#ifndef STRNCMP ++#define STRNCMP strncmp ++#endif ++ ++ ++char arr1[32] = "this is a test"; ++char arr2[32] = "this is a test"; ++char *p1 = &arr1[0]; ++char *p2 = &arr2[1]; ++main () ++{ ++ return STRNCMP (NULL, NULL, 0); ++} ++ ++ +diff -Nrup a/testsuite/memstomp.null/strncpy.c b/testsuite/memstomp.null/strncpy.c +--- a/testsuite/memstomp.null/strncpy.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/strncpy.c 2014-05-29 12:42:18.359166205 -0600 +@@ -0,0 +1,19 @@ ++#define _GNU_SOURCE ++#include ++#include ++ ++#ifndef STRNCPY ++#define STRNCPY strncpy ++#endif ++ ++ ++char arr1[32] = "this is a test"; ++char arr2[32] = "this is a test"; ++char *p1 = &arr1[0]; ++char *p2 = &arr2[1]; ++main () ++{ ++ STRNCPY (NULL, NULL, 0); ++} ++ ++ +diff -Nrup a/testsuite/memstomp.null/strndup.c b/testsuite/memstomp.null/strndup.c +--- a/testsuite/memstomp.null/strndup.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/strndup.c 2014-05-29 14:13:18.192190697 -0600 +@@ -0,0 +1,4 @@ ++#define RAWMEMCHR strndup ++#define TYPE char ++#include "rawmemchr.c" ++ +diff -Nrup a/testsuite/memstomp.null/strpbrk.c b/testsuite/memstomp.null/strpbrk.c +--- a/testsuite/memstomp.null/strpbrk.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/strpbrk.c 2014-05-29 14:17:09.970591544 -0600 +@@ -0,0 +1,2 @@ ++#define STRCMP strpbrk ++#include "strcmp.c" +diff -Nrup a/testsuite/memstomp.null/strrchr.c b/testsuite/memstomp.null/strrchr.c +--- a/testsuite/memstomp.null/strrchr.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/strrchr.c 2014-05-29 14:15:23.466868332 -0600 +@@ -0,0 +1,4 @@ ++#define RAWMEMCHR strchrnul ++#define TYPE char ++#include "rawmemchr.c" ++ +diff -Nrup a/testsuite/memstomp.null/strspn.c b/testsuite/memstomp.null/strspn.c +--- a/testsuite/memstomp.null/strspn.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/strspn.c 2014-05-29 14:16:33.880685326 -0600 +@@ -0,0 +1,2 @@ ++#define STRCMP strspn ++#include "strcmp.c" +diff -Nrup a/testsuite/memstomp.null/strstr.c b/testsuite/memstomp.null/strstr.c +--- a/testsuite/memstomp.null/strstr.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/strstr.c 2014-05-29 14:16:56.195627338 -0600 +@@ -0,0 +1,2 @@ ++#define STRCMP strstr ++#include "strcmp.c" +diff -Nrup a/testsuite/memstomp.null/strtok.c b/testsuite/memstomp.null/strtok.c +--- a/testsuite/memstomp.null/strtok.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/strtok.c 2014-05-29 14:19:10.868277465 -0600 +@@ -0,0 +1,2 @@ ++#define STRCMP strtok ++#include "strcmp.c" +diff -Nrup a/testsuite/memstomp.null/strtok_r.c b/testsuite/memstomp.null/strtok_r.c +--- a/testsuite/memstomp.null/strtok_r.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/strtok_r.c 2014-05-29 14:19:53.089167807 -0600 +@@ -0,0 +1,20 @@ ++#define _GNU_SOURCE ++#include ++#include ++ ++#ifndef STRTOK_R ++#define STRTOK_R strtok_r ++#define TYPE char ++#endif ++ ++TYPE arr1[10] = {0}; ++TYPE arr2[10] = {0}; ++TYPE *p1 = &arr1[0]; ++TYPE *p2 = &arr2[1]; ++size_t count = 9; ++main () ++{ ++ return STRTOK_R (NULL, NULL, NULL) == 0 ; ++} ++ ++ +diff -Nrup a/testsuite/memstomp.null/strxfrm.c b/testsuite/memstomp.null/strxfrm.c +--- a/testsuite/memstomp.null/strxfrm.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/strxfrm.c 2014-05-29 14:06:23.335256429 -0600 +@@ -0,0 +1,2 @@ ++#define STRNCPY strxfrm ++#include "strcmp.c" +diff -Nrup a/testsuite/memstomp.null/strxfrm_l.c b/testsuite/memstomp.null/strxfrm_l.c +--- a/testsuite/memstomp.null/strxfrm_l.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/strxfrm_l.c 2014-05-29 14:07:10.004136524 -0600 +@@ -0,0 +1,19 @@ ++#define _GNU_SOURCE ++#include ++#include ++ ++#ifndef STRCMP ++#define STRCMP strxfrm_l ++#endif ++ ++ ++char arr1[32] = "this is a test"; ++char arr2[32] = "this is a test"; ++char *p1 = &arr1[0]; ++char *p2 = &arr2[1]; ++main () ++{ ++ return STRCMP (NULL, NULL, 0, NULL); ++} ++ ++ +diff -Nrup a/testsuite/memstomp.null/wmemcpy.c b/testsuite/memstomp.null/wmemcpy.c +--- a/testsuite/memstomp.null/wmemcpy.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/wmemcpy.c 2014-05-29 12:42:18.359166205 -0600 +@@ -0,0 +1,3 @@ ++#define MEMCPY wmemcpy ++#define TYPE wchar_t ++#include "memcpy.c" +diff -Nrup a/testsuite/memstomp.null/wmempcpy.c b/testsuite/memstomp.null/wmempcpy.c +--- a/testsuite/memstomp.null/wmempcpy.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.null/wmempcpy.c 2014-05-29 12:42:18.359166205 -0600 +@@ -0,0 +1,3 @@ ++#define MEMCPY wmempcpy ++#define TYPE wchar_t ++#include "memcpy.c" diff --git a/memstomp-rh1133815.patch b/memstomp-rh1133815.patch new file mode 100644 index 0000000..5f05de9 --- /dev/null +++ b/memstomp-rh1133815.patch @@ -0,0 +1,158 @@ +diff -Nrup a/memstomp.c b/memstomp.c +--- a/memstomp.c 2014-08-26 13:13:30.004485804 -0600 ++++ b/memstomp.c 2014-08-26 13:17:00.450138891 -0600 +@@ -241,6 +241,16 @@ static char* generate_stacktrace(void) + int const n = real_backtrace(retaddr, frames_max); + assert(n >= 0); + ++ /* Adjust the frame addresses since they point to the next ++ instruction to execute, not the call site which may be ++ associated with different line numbers. ++ ++ For the cases we care about in memstomp, just subtracting ++ 1 works the vast majority of the time. It may not work for ++ a tail-call into an intercepted routine though. */ ++ for (int i = 0; i < n; i++) ++ retaddr[i]--; ++ + char **const strings = real_backtrace_symbols(retaddr, n); + assert(strings); + +diff -Nrup a/testsuite/lib/memstomp.exp b/testsuite/lib/memstomp.exp +--- a/testsuite/lib/memstomp.exp 2014-08-26 13:13:29.964485869 -0600 ++++ b/testsuite/lib/memstomp.exp 2014-08-26 14:29:37.334241044 -0600 +@@ -13,3 +13,11 @@ proc find_libmemstomp {} { + set file [findfile $base_dir/../.libs/libmemstomp.so $base_dir/../.libs/libmemstomp.so libmemstomp.so] + return $file + } ++ ++proc find_libmemstomp_backtrace_symbols {} { ++ global tool_root_dir ++ global base_dir ++ ++ set file [findfile $base_dir/../.libs/libmemstomp-backtrace-symbols.so $base_dir/../.libs/libmemstomp-backtrace-symbols.so libmemstomp-backtrace-symbols.so] ++ return $file ++} +diff -Nrup a/testsuite/memstomp.lineinfo/linenumber.c b/testsuite/memstomp.lineinfo/linenumber.c +--- a/testsuite/memstomp.lineinfo/linenumber.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.lineinfo/linenumber.c 2014-08-26 13:23:12.535518727 -0600 +@@ -0,0 +1,23 @@ ++#define __NO_STRING_INLINES ++#include ++ ++void ++something (void) ++{ ++ char a[20] = " hello"; ++ memcpy (a, a + 5, 6); ++} ++ ++void ++nothing (void) ++{ ++ something (); ++} ++ ++int ++main (void) ++{ ++ nothing (); ++ return 0; ++} ++ +diff -Nrup a/testsuite/memstomp.lineinfo/linenumber.exp b/testsuite/memstomp.lineinfo/linenumber.exp +--- a/testsuite/memstomp.lineinfo/linenumber.exp 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.lineinfo/linenumber.exp 2014-08-26 17:49:55.493353200 -0600 +@@ -0,0 +1,65 @@ ++# Copyright (C) 2014 Free Software Foundation, Inc. ++ ++# This program is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# This program is distributed in the hope that it will be useful, ++# but WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with GCC; see the file COPYING3. If not see ++# . ++# ++# This was originally copied from GCC's dejagnu testing framework ++# ++# This is a hack. If we need more of these tests we'll want to use ++# something like dj's framework so that we can mark the lines where ++# we want errors/warnings. ++# ++ ++load_lib memstomp.exp ++set libmemstomp [find_libmemstomp] ++set libmemstomp_backtrace_symbols [find_libmemstomp_backtrace_symbols] ++ ++if $tracelevel then { ++ strace $tracelevel ++} ++ ++# ++# main test loop ++# ++ ++proc compile-and-execute { sources } { ++ global libmemstomp ++ global libmemstomp_backtrace_symbols ++ ++ set src [lindex $sources 0] ++ ++ if {[catch {exec gcc -g -fno-builtin $src} results]} { ++ fail "$src compilation $results" ++ } else { ++ pass "$src compilation $results" ++ } ++ ++ # ARM's unwinder seems broken ++ setup_xfail arm*-*-* ++ catch {exec /bin/bash -c "LD_PRELOAD=$libmemstomp:$libmemstomp_backtrace_symbols ./a.out"} results ++ if {[regexp "linenumber.c:8" $results]} { ++ pass "$src found overlap on right line $results" ++ } else { ++ fail "$src found overlap on right line $results" ++ } ++} ++ ++foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] { ++ # If we're only testing specific files and this isn't one of them, skip it. ++ if ![runtest_file_p $runtests $src] then { ++ continue ++ } ++ ++ compile-and-execute $src ++} +diff -Nrup a/testsuite/memstomp.overlap/linenumber.c b/testsuite/memstomp.overlap/linenumber.c +--- a/testsuite/memstomp.overlap/linenumber.c 1969-12-31 17:00:00.000000000 -0700 ++++ b/testsuite/memstomp.overlap/linenumber.c 2014-08-26 13:17:30.057090085 -0600 +@@ -0,0 +1,23 @@ ++#define __NO_STRING_INLINES ++#include ++ ++void ++something (void) ++{ ++ char a[20] = " hello"; ++ memcpy (a, a + 5, 6); ++} ++ ++void ++nothing (void) ++{ ++ something (); ++} ++ ++int ++main (void) ++{ ++ nothing (); ++ return 0; ++} ++ diff --git a/memstomp-rh961495.patch b/memstomp-rh961495.patch new file mode 100644 index 0000000..49b7345 --- /dev/null +++ b/memstomp-rh961495.patch @@ -0,0 +1,12 @@ +diff -Nrup a/memstomp.c b/memstomp.c +--- a/memstomp.c 2011-03-30 21:27:19.000000000 -0600 ++++ b/memstomp.c 2013-05-09 22:23:39.210837345 -0600 +@@ -174,7 +174,7 @@ static void setup(void) { + initialized = true; + + char prname[17]; +- fprintf(stderr, "memstomp: "PACKAGE_VERSION" sucessfully initialized for process %s (pid %lu).\n", ++ fprintf(stderr, "memstomp: "PACKAGE_VERSION" successfully initialized for process %s (pid %lu).\n", + get_prname(prname), (unsigned long) getpid()); + } + diff --git a/memstomp-rh962763.patch b/memstomp-rh962763.patch new file mode 100644 index 0000000..9fce643 --- /dev/null +++ b/memstomp-rh962763.patch @@ -0,0 +1,15 @@ +diff -Nrup a/configure.ac b/configure.ac +--- a/configure.ac 2013-05-14 14:27:04.316530952 -0600 ++++ b/configure.ac 2013-05-14 14:27:37.854394379 -0600 +@@ -72,8 +72,10 @@ AC_CHECK_HEADERS([sys/poll.h]) + AC_CHECK_HEADERS([sys/ioctl.h]) + AC_CHECK_HEADERS([byteswap.h]) + ++AC_SEARCH_LIBS([htab_find_slot], [iberty], [], [AC_MSG_ERROR([*** libiberty not found])]) ++AC_CHECK_HEADERS([libiberty.h], [], [AC_MSG_ERROR([*** libiberty.h header not found])]) + AC_SEARCH_LIBS([bfd_init], [bfd], [], [AC_MSG_ERROR([*** libbfd not found])]) +-AC_CHECK_HEADERS([bfd.h], [], [AC_MSG_ERROR([*** POSIX caps headers not found])]) ++AC_CHECK_HEADERS([bfd.h], [], [AC_MSG_ERROR([*** bfd.h header not found])]) + + #### Typdefs, structures, etc. #### + diff --git a/memstomp-sframe.patch b/memstomp-sframe.patch new file mode 100644 index 0000000..b0091eb --- /dev/null +++ b/memstomp-sframe.patch @@ -0,0 +1,12 @@ +diff -up memstomp-0.1.4-38573e7d/configure.ac.orig memstomp-0.1.4-38573e7d/configure.ac +--- memstomp-0.1.4-38573e7d/configure.ac.orig 2023-03-06 14:07:57.086183046 -0500 ++++ memstomp-0.1.4-38573e7d/configure.ac 2023-03-06 14:16:31.513215306 -0500 +@@ -76,6 +76,8 @@ AC_SEARCH_LIBS([htab_find_slot], [iberty + AC_CHECK_HEADERS([libiberty.h], [], [AC_MSG_ERROR([*** libiberty.h header not found])]) + AC_SEARCH_LIBS([bfd_init], [bfd], [], [AC_MSG_ERROR([*** libbfd not found])]) + AC_CHECK_HEADERS([bfd.h], [], [AC_MSG_ERROR([*** bfd.h header not found])]) ++# Newer binutils-2.40 also need to link with sframe library ++AC_SEARCH_LIBS(sframe_decode, sframe) + + #### Typdefs, structures, etc. #### + diff --git a/memstomp-testsuite.patch b/memstomp-testsuite.patch index fbd9c12..7e63d12 100644 --- a/memstomp-testsuite.patch +++ b/memstomp-testsuite.patch @@ -669,7 +669,7 @@ diff -Nrup a/testsuite/memstomp.overlap/wmempcpy.c b/testsuite/memstomp.overlap/ + + set src [lindex $sources 0] + -+ if {[catch {exec gcc $src} results]} { ++ if {[catch {exec gcc -fno-builtin $src} results]} { + fail "$src compilation $results" + } else { + pass "$src compilation $results" @@ -728,7 +728,7 @@ diff -Nrup a/testsuite/memstomp.overlap/wmempcpy.c b/testsuite/memstomp.overlap/ + global memstomp + set src [lindex $sources 0] + -+ if {[catch {exec gcc $src} results]} { ++ if {[catch {exec gcc -fno-builtin $src} results]} { + fail "$src compilation $results" + } else { + pass "$src compilation $results" diff --git a/memstomp.spec b/memstomp.spec index d1b8bbe..9f47afa 100644 --- a/memstomp.spec +++ b/memstomp.spec @@ -1,13 +1,14 @@ %global githash 38573e7d + Name: memstomp Version: 0.1.4 -Release: 4%{?dist} +Release: 44%{?dist} Summary: Warns of memory argument overlaps to various functions -Group: Development/Debuggers # The entire source code is LGPLV3+ with the exception of backtrace-symbols.c which # is GPLv2+ by way of being a hacked up old version of binutils's addr2line. # backtrace-symbols.c is built into an independent .so to avoid license contamination -License: LGPLv3+ and GPLv2+ +# Automatically converted from old format: LGPLv3+ and GPLv2+ - review is highly recommended. +License: LGPL-3.0-or-later AND GPL-2.0-or-later URL: git://fedorapeople.org/home/fedora/wcohen/public_git/memstomp # The source for this package was pulled from upstream's vcs. Use the # following commands to generate the tarball: @@ -16,10 +17,21 @@ URL: git://fedorapeople.org/home/fedora/wcohen/public_git/memstomp # git archive --prefix memstomp-0.1.4-38573e7d/ master | gzip > memstomp-0.1.4-3867e37d.tar.gz Source0: %{name}-%{version}-%{githash}.tar.gz Requires: util-linux +BuildRequires: make +BuildRequires: gcc BuildRequires: binutils-devel autoconf automake dejagnu Patch0: memstomp-testsuite.patch Patch1: memstomp-man.patch +Patch2: memstomp-rh961495.patch +Patch3: memstomp-rh962763.patch +Patch4: memstomp-quietmode.patch +Patch5: memstomp-rh1093173.patch +Patch6: memstomp-rh1133815.patch +Patch7: memstomp-implicit-int.patch +Patch8: bfd-api-change.patch +Patch9: memstomp-PTR.patch +Patch10: memstomp-sframe.patch %description @@ -27,19 +39,32 @@ memstomp is a simple program that can be used to identify places in code which trigger undefined behavior due to overlapping memory arguments to certain library calls. -%post -p /sbin/ldconfig -%postun -p /sbin/ldconfig +%ldconfig_scriptlets %prep %setup -q -n %{name}-%{version}-%{githash} -%patch0 -p1 -%patch1 -p1 +%patch -P0 -p1 +%patch -P1 -p1 +%patch -P2 -p1 +%patch -P3 -p1 +%patch -P4 -p1 +%patch -P5 -p1 +%patch -P6 -p1 +%patch -P7 -p1 +%patch -P8 -p1 +%patch -P9 -p1 +%patch -P10 -p1 %build autoreconf %configure -make %{?_smp_mflags} CFLAGS+="-fno-strict-aliasing" +# We force -O0 here because memstomp essentially relies on GCC +# not removing any of its checks. GCC continues to get better +# and twarting its optimizer isn't something I have any interest +# in maintaining over time. So just force -O0 for stupid code +# generation. +make %{?_smp_mflags} CFLAGS+="-O0 -fno-strict-aliasing" make -k check %install @@ -53,6 +78,129 @@ make install DESTDIR=$RPM_BUILD_ROOT %{_mandir}/man1/memstomp.1.gz %changelog +* Thu Jul 24 2025 Fedora Release Engineering - 0.1.4-44 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild + +* Fri Jan 17 2025 Fedora Release Engineering - 0.1.4-43 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild + +* Wed Aug 07 2024 Miroslav Suchý - 0.1.4-42 +- convert license to SPDX + +* Thu Jul 18 2024 Fedora Release Engineering - 0.1.4-41 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild + +* Thu Jan 25 2024 Fedora Release Engineering - 0.1.4-40 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Sun Jan 21 2024 Fedora Release Engineering - 0.1.4-39 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + +* Thu Jul 20 2023 Fedora Release Engineering - 0.1.4-38 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + +* Mon Mar 6 2023 William Cohen - 0.1.4-37 +- Link in binutils sframe library when available to fix FTBFS. (rhbz#2171607) + +* Mon Feb 20 2023 Jeff Law - 0.1.4-36 +- Fix for libibery no longer providing PTR + (#2171607) + +* Thu Jan 19 2023 Fedora Release Engineering - 0.1.4-35 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild + +* Thu Jul 21 2022 Fedora Release Engineering - 0.1.4-34 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild + +* Thu Jan 20 2022 Fedora Release Engineering - 0.1.4-33 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild + +* Thu Jul 22 2021 Fedora Release Engineering - 0.1.4-32 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild + +* Tue Jan 26 2021 Fedora Release Engineering - 0.1.4-31 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild + +* Tue Jul 28 2020 Fedora Release Engineering - 0.1.4-30 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild + +* Mon May 18 2020 Jeff Law - 0.1.4-29 +- Various fixes for API changes in bfd + +* Wed Jan 29 2020 Fedora Release Engineering - 0.1.4-28 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild + +* Thu Jul 25 2019 Fedora Release Engineering - 0.1.4-27 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild + +* Fri Feb 01 2019 Fedora Release Engineering - 0.1.4-26 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild + +* Fri Jul 13 2018 Fedora Release Engineering - 0.1.4-25 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild + +* Thu Feb 08 2018 Fedora Release Engineering - 0.1.4-24 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Thu Aug 03 2017 Fedora Release Engineering - 0.1.4-23 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Wed Jul 26 2017 Fedora Release Engineering - 0.1.4-22 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Fri Feb 10 2017 Fedora Release Engineering - 0.1.4-21 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Mon May 9 2016 Jeff Law - 0.1.4-20 +- Remove xfail for aarch64 in testsuite (#1334124) + +* Wed Feb 17 2016 Jeff Law - 0.1.4-19 +- Build with -O0 to avoid GCC optimizing away checks we want to keep. + (#1307767) + +* Thu Feb 04 2016 Fedora Release Engineering - 0.1.4-18 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Wed Jun 17 2015 Fedora Release Engineering - 0.1.4-17 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Tue May 26 2015 Jeff Law 0.1.4-16 +- Fixup implicit return types in testsuite. + +* Tue Aug 26 2014 Jeff Law 0.1.4-15 +- Adjust PC values in saved frame addresses to get line number + associations correct (#1133815). + +* Sun Aug 17 2014 Fedora Release Engineering - 0.1.4-14 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild + +* Sat Jun 07 2014 Fedora Release Engineering - 0.1.4-13 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Wed Jun 4 2014 Jeff Law 0.1.4-12 +- Fix cut-n-paste bug in memmem + +* Thu May 29 2014 Jeff Law 0.1.4-11 +- Add checking of various str* and mem* for NULL arguments (#1093173) + +* Sat Aug 03 2013 Fedora Release Engineering - 0.1.4-10 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Thu May 30 2013 Jeff Law 0.1.4-9 +- Add -q/--quiet options for quiet mode. + +* Tue May 14 2013 Jeff Law 0.1.4-8 +- Link in libiberty too (#962763) + +* Fri May 10 2013 Jeff Law 0.1.4-7 +- Improve man page (#961518) + +* Thu May 09 2013 Jeff Law 0.1.4-5 +- Fix typo in initialization message (#961495) + +* Fri Mar 15 2013 Jeff Law 0.1.4-4 +- Build tests with -fno-builtin + * Mon Mar 11 2013 Jeff Law 0.1.4-4 - Add manpage - Add initial testsuite diff --git a/plans/ci.fmf b/plans/ci.fmf new file mode 100644 index 0000000..1ad2c12 --- /dev/null +++ b/plans/ci.fmf @@ -0,0 +1,6 @@ +summary: CI Gating Plan +discover: + how: fmf + directory: tests +execute: + how: beakerlib diff --git a/tests/Sanity/memstomp-testsuite/Makefile b/tests/Sanity/memstomp-testsuite/Makefile new file mode 100644 index 0000000..189fbe8 --- /dev/null +++ b/tests/Sanity/memstomp-testsuite/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/memstomp/Sanity/memstomp-testsuite +# Description: Runs memstomp testsuite on installed packages +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +export TEST=/tools/memstomp/Sanity/memstomp-testsuite +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE + +.PHONY: all install download clean + +run: $(FILES) build + ./runtest.sh + +build: $(BUILT_FILES) + test -x runtest.sh || chmod a+x runtest.sh + +clean: + rm -f *~ $(BUILT_FILES) + + +include /usr/share/rhts/lib/rhts-make.include + +$(METADATA): Makefile + @echo "Owner: Miroslav Franc " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Runs memstomp testsuite on installed packages" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: memstomp" >> $(METADATA) + @echo "Requires: autoconf automake binutils-devel dejagnu gcc gcc-c++ glibc-devel memstomp rpm-build" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Releases: -RHEL4 -RHELClient5 -RHELServer5 -RHEL8 -RHEL9" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Sanity/memstomp-testsuite/PURPOSE b/tests/Sanity/memstomp-testsuite/PURPOSE new file mode 100644 index 0000000..8be9f56 --- /dev/null +++ b/tests/Sanity/memstomp-testsuite/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /tools/memstomp/Sanity/memstomp-testsuite +Description: Runs memstomp testsuite on installed packages +Author: Miroslav Franc diff --git a/tests/Sanity/memstomp-testsuite/main.fmf b/tests/Sanity/memstomp-testsuite/main.fmf new file mode 100644 index 0000000..6388c8a --- /dev/null +++ b/tests/Sanity/memstomp-testsuite/main.fmf @@ -0,0 +1,20 @@ +summary: Runs memstomp testsuite on installed packages +description: '' +contact: Miroslav Franc +component: +- memstomp +test: ./runtest.sh +framework: beakerlib +recommend: +- autoconf +- automake +- binutils-devel +- dejagnu +- gcc +- gcc-c++ +- glibc-devel +- memstomp +- rpm-build +duration: 15m +extra-summary: /tools/memstomp/Sanity/memstomp-testsuite +extra-task: /tools/memstomp/Sanity/memstomp-testsuite diff --git a/tests/Sanity/memstomp-testsuite/runtest.sh b/tests/Sanity/memstomp-testsuite/runtest.sh new file mode 100755 index 0000000..ad1a6d6 --- /dev/null +++ b/tests/Sanity/memstomp-testsuite/runtest.sh @@ -0,0 +1,87 @@ +#!/bin/bash +# vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/memstomp/Sanity/memstomp-testsuite +# Description: Runs memstomp testsuite on installed packages +# Author: Miroslav Franc +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 Red Hat, Inc. All rights reserved. +# +# This copyrighted material is made available to anyone wishing +# to use, modify, copy, or redistribute it subject to the terms +# and conditions of the GNU General Public License version 2. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGES=(binutils-devel autoconf automake dejagnu) + +if [[ $(arch) == i686 ]] +then + ourlibdir=lib +else + ourlibdir=lib64 +fi + +PACKAGE=memstomp + +if scl_enabled +then + for p in ${X_SCLS} + do + [[ $p == devtoolset* ]] && PACKAGE=${p}-${PACKAGE} + done; unset p +fi + +rlJournalStart + rlPhaseStartSetup "testing $PACKAGE" + for p in "${PACKAGES[@]}"; do + rpm -q "$p" || yum -y install "$p" + rlAssertRpm "$p" + done; unset p + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlRun "echo '%_topdir /root/memstomp-rebuild' > ~/.rpmmacros" + rlRun "mkdir -p /root/memstomp-rebuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}" + rlFetchSrcForInstalled $PACKAGE + rlRun "rpm -Uvh *.src.rpm" + export CC=/usr/bin/gcc + rlRun "rpmbuild -bi /root/memstomp-rebuild/SPECS/memstomp.spec &> build_log" + rlFileSubmit build_log + rlRun "pushd /root/memstomp-rebuild/BUILD/memstomp-*/testsuite" + rlLog "We should run this on installed packages..." + rlRun "find /root/memstomp-rebuild/ -name libmemstomp.so -delete" + rlRun "find /root/memstomp-rebuild/ -name libmemstomp-backtrace-symbols.so -delete" + rlPhaseEnd + + rlPhaseStartTest + rlRun "runtest -v --tool memstomp --srcdir `pwd` > $TmpDir/log 2>&1" + rlAssertNotGrep 'unexpected failures' $TmpDir/log + rlLog "No testcases should disappear..." + rlRun "[[ $(grep '# of expected passes' $TmpDir/log | awk '{print $5}') -ge 88 ]]" + rlLog "$(sed -n '/=== memstomp Summary ===/,$p' $TmpDir/log)" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd"; rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlRun "rm -r /root/memstomp-rebuild" + rlRun "rm -r ~/.rpmmacros" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd