Compare commits
5 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7b972e2360 | ||
|
|
5880f6b115 | ||
|
|
adcfaf9792 | ||
|
|
4efbb3b544 | ||
|
|
cbbad87e5b |
6 changed files with 200 additions and 18 deletions
|
|
@ -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 <lennart@poettering.net>
|
||||
+.br
|
||||
+William Cohen <wcohen@redhat.com>
|
||||
|
|
|
|||
83
memstomp-quietmode.patch
Normal file
83
memstomp-quietmode.patch
Normal file
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
-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 <<EOF
|
||||
@@ -51,6 +55,7 @@ COMMANDS:
|
||||
OPTIONS:
|
||||
-d, --debug-info Make use of debug information in stack traces
|
||||
-k, --kill Kill application when problem memcpy occurs
|
||||
+ -q, --quiet Be less verbose
|
||||
EOF
|
||||
exit 0
|
||||
;;
|
||||
diff -Nrup a/memstomp.man b/memstomp.man
|
||||
--- a/memstomp.man 2013-05-30 06:02:56.577486392 -0600
|
||||
+++ b/memstomp.man 2013-05-30 06:06:18.531812637 -0600
|
||||
@@ -47,6 +47,9 @@ Kill the analyzed application when a pro
|
||||
.TP
|
||||
.BR \-h ", " \-\-help
|
||||
Display usage information and exit.
|
||||
+.TP
|
||||
+.BR \-q ", " \-\-quiet
|
||||
+Be less verbose
|
||||
.SH SEE ALSO
|
||||
.BR memcpy (3),
|
||||
.BR memccpy (3),
|
||||
12
memstomp-rh961495.patch
Normal file
12
memstomp-rh961495.patch
Normal file
|
|
@ -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());
|
||||
}
|
||||
|
||||
15
memstomp-rh962763.patch
Normal file
15
memstomp-rh962763.patch
Normal file
|
|
@ -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. ####
|
||||
|
||||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
%global githash 38573e7d
|
||||
Name: memstomp
|
||||
Version: 0.1.4
|
||||
Release: 4%{?dist}
|
||||
Release: 9%{?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
|
||||
|
|
@ -20,6 +20,9 @@ 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
|
||||
|
||||
|
||||
%description
|
||||
|
|
@ -34,6 +37,9 @@ overlapping memory arguments to certain library calls.
|
|||
%setup -q -n %{name}-%{version}-%{githash}
|
||||
%patch0 -p1
|
||||
%patch1 -p1
|
||||
%patch2 -p1
|
||||
%patch3 -p1
|
||||
%patch4 -p1
|
||||
|
||||
|
||||
%build
|
||||
|
|
@ -53,6 +59,21 @@ make install DESTDIR=$RPM_BUILD_ROOT
|
|||
%{_mandir}/man1/memstomp.1.gz
|
||||
|
||||
%changelog
|
||||
* Thu May 30 2013 Jeff Law <law@redhat.com> 0.1.4-9
|
||||
- Add -q/--quiet options for quiet mode.
|
||||
|
||||
* Tue May 14 2013 Jeff Law <law@redhat.com> 0.1.4-8
|
||||
- Link in libiberty too (#962763)
|
||||
|
||||
* Fri May 10 2013 Jeff Law <law@redhat.com> 0.1.4-7
|
||||
- Improve man page (#961518)
|
||||
|
||||
* Thu May 09 2013 Jeff Law <law@redhat.com> 0.1.4-5
|
||||
- Fix typo in initialization message (#961495)
|
||||
|
||||
* Fri Mar 15 2013 Jeff Law <law@redhat.com> 0.1.4-4
|
||||
- Build tests with -fno-builtin
|
||||
|
||||
* Mon Mar 11 2013 Jeff Law <law@redhat.com> 0.1.4-4
|
||||
- Add manpage
|
||||
- Add initial testsuite
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue