OBS User unknown 2008-11-11 15:12:00 +00:00 committed by Git OBS Bridge
parent 7505eed37a
commit 0fdf3d84d9
3 changed files with 213 additions and 10 deletions

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Tue Nov 11 10:14:53 CET 2008 - schwab@suse.de
- Fix corner cases in printstr and printpathn.
-------------------------------------------------------------------
Thu Oct 30 12:34:56 CET 2008 - olh@suse.de

View File

@ -31,10 +31,11 @@ Obsoletes: strace-32bit
%endif
#
Version: 4.5.18
Release: 7
Release: 8
Summary: A utility to trace the system calls of a program
Source: http://dl.sourceforge.net/strace/strace-%{version}.tar.bz2
Patch: strace-%{version}.diff
Patch1: string-quote.diff
Url: http://sourceforge.net/projects/strace/
BuildRoot: %{_tmppath}/%{name}-%{version}-build
@ -54,6 +55,7 @@ Authors:
%prep
%setup -q
%patch
%patch1
%build
export CFLAGS="$RPM_OPT_FLAGS"
@ -77,6 +79,8 @@ rm -rf $RPM_BUILD_ROOT
%doc %{_mandir}/man1/strace.1.gz
%changelog
* Tue Nov 11 2008 schwab@suse.de
- Fix corner cases in printstr and printpathn.
* Thu Oct 30 2008 olh@suse.de
- obsolete old -XXbit packages (bnc#437293)
* Tue Sep 02 2008 schwab@suse.de
@ -127,7 +131,7 @@ rm -rf $RPM_BUILD_ROOT
- Fix compilation with 2.6.18 kernel headers.
* Fri Sep 29 2006 schwab@suse.de
- Fix use of PT_GETSIGINFO.
* Sat Sep 09 2006 schwab@suse.de
* Fri Sep 08 2006 schwab@suse.de
- Fix last change.
* Thu Sep 07 2006 schwab@suse.de
- Add fixes from repository.
@ -135,7 +139,7 @@ rm -rf $RPM_BUILD_ROOT
- Fix missing arguments.
* Sat Apr 29 2006 schwab@suse.de
- Add *at syscalls on ppc.
* Thu Apr 27 2006 schwab@suse.de
* Wed Apr 26 2006 schwab@suse.de
- Fix socket/ipc subcall decoding.
- Fix ioctl decoding.
* Wed Apr 05 2006 schwab@suse.de
@ -186,11 +190,11 @@ rm -rf $RPM_BUILD_ROOT
- Update to strace 4.5.5.
* Sat Jun 05 2004 schwab@suse.de
- Update to strace 4.5.4.
* Thu May 06 2004 schwab@suse.de
* Wed May 05 2004 schwab@suse.de
- Fix handing of execve [#38479].
* Sat Apr 17 2004 schwab@suse.de
- Update to strace 4.5.3.
* Tue Apr 06 2004 schwab@suse.de
* Mon Apr 05 2004 schwab@suse.de
- Sign extend pid in sys_kill [#38433].
* Mon Mar 08 2004 schwab@suse.de
- Update to strace 4.5.2, incorporates all recent changes.
@ -267,7 +271,7 @@ rm -rf $RPM_BUILD_ROOT
- Fix for ppc and sparc.
* Fri Jun 08 2001 schwab@suse.de
- Update to strace 4.3.
* Tue May 15 2001 bk@suse.de
* Mon May 14 2001 bk@suse.de
- fix long shifts to create long long logs for llseek, pread and pwrite.
(for 2147483748[2GB+100], strace logged 18446744071562068068 which is wrong)
* Wed Mar 07 2001 schwab@suse.de
@ -291,7 +295,7 @@ rm -rf $RPM_BUILD_ROOT
- Update ia64 patches.
* Tue Jun 20 2000 schwab@suse.de
- Update ia64 patches.
* Mon Jun 19 2000 ro@suse.de
* Sun Jun 18 2000 ro@suse.de
- prevent inclusion of linux/time.h
* Thu May 18 2000 schwab@suse.de
- Fixed to build with 2.3.99 kernels.
@ -324,11 +328,11 @@ rm -rf $RPM_BUILD_ROOT
- adapt to sysctl-changes
* Fri Jul 09 1999 ro@suse.de
- update to 4.0 using jurix diff
* Tue Apr 13 1999 ro@suse.de
* Mon Apr 12 1999 ro@suse.de
- update 3.1.0.1 / merge patches
* Tue Apr 13 1999 ro@suse.de
* Mon Apr 12 1999 ro@suse.de
- fixed for alpha
* Wed Mar 31 1999 ro@suse.de
* Tue Mar 30 1999 ro@suse.de
- merged path from Stanislav Brabec and Massimiliano Ghilardi
* Tue Mar 09 1999 ro@suse.de
- back to SYS_vfork

194
string-quote.diff Normal file
View File

@ -0,0 +1,194 @@
2008-11-09 Dmitry V. Levin <ldv@altlinux.org>
* util.c (string_quote): Fix support for NUL-terminated string.
Add comments.
(printpathn): Fix the case when "..." was appended to the output
but no truncation was actually made. Add comments.
(printstr): Fix memory allocation. Fix two cases when "..." was
appended to the output but no truncation was actually made.
Add comments.
Index: util.c
===================================================================
RCS file: /cvsroot/strace/strace/util.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -a -p -u -p -a -r1.80 -r1.81
--- util.c 10 Nov 2008 22:21:41 -0000 1.80
+++ util.c 10 Nov 2008 23:19:13 -0000 1.81
@@ -407,6 +407,12 @@ unsigned long uid;
static char path[MAXPATHLEN + 1];
+/*
+ * Quote string `instr' of length `size'
+ * Write up to (3 + `size' * 4) bytes to `outstr' buffer.
+ * If `len' < 0, treat `instr' as a NUL-terminated string
+ * and quote at most (`size' - 1) bytes.
+ */
static int
string_quote(const char *instr, char *outstr, int len, int size)
{
@@ -417,12 +423,18 @@ string_quote(const char *instr, char *ou
if (xflag > 1)
usehex = 1;
else if (xflag) {
+ /* Check for presence of symbol which require
+ to hex-quote the whole string. */
for (i = 0; i < size; ++i) {
c = ustr[i];
- if (len < 0 && i == size - 2 && c != '\0')
- ++i;
- if (len < 0 && c == '\0')
- break;
+ /* Check for NUL-terminated string. */
+ if (len < 0) {
+ if (c == '\0')
+ break;
+ /* Quote at most size - 1 bytes. */
+ if (i == size - 1)
+ continue;
+ }
if (!isprint(c) && !isspace(c)) {
usehex = 1;
break;
@@ -433,20 +445,31 @@ string_quote(const char *instr, char *ou
*s++ = '\"';
if (usehex) {
+ /* Hex-quote the whole string. */
for (i = 0; i < size; ++i) {
c = ustr[i];
- if (len < 0 && c == '\0')
- break;
+ /* Check for NUL-terminated string. */
+ if (len < 0) {
+ if (c == '\0')
+ break;
+ /* Quote at most size - 1 bytes. */
+ if (i == size - 1)
+ continue;
+ }
sprintf(s, "\\x%02x", c);
s += 4;
}
} else {
for (i = 0; i < size; ++i) {
c = ustr[i];
- if (len < 0 && i == size - 2 && c != '\0')
- ++i;
- if (len < 0 && c == '\0')
- break;
+ /* Check for NUL-terminated string. */
+ if (len < 0) {
+ if (c == '\0')
+ break;
+ /* Quote at most size - 1 bytes. */
+ if (i == size - 1)
+ continue;
+ }
switch (c) {
case '\"': case '\\':
*s++ = '\\';
@@ -495,18 +518,25 @@ string_quote(const char *instr, char *ou
return i == size;
}
+/*
+ * Print path string specified by address `addr' and length `n'.
+ * If path length exceeds `n', append `...' to the output.
+ */
void
printpathn(struct tcb *tcp, long addr, int n)
{
- if (n > sizeof path - 1)
- n = sizeof path - 1;
-
- if (addr == 0) {
+ if (!addr) {
tprintf("NULL");
return;
}
+ /* Cap path length to the path buffer size,
+ and NUL-terminate the buffer. */
+ if (n > sizeof path - 1)
+ n = sizeof path - 1;
path[n] = '\0';
+
+ /* Fetch one byte more to find out whether path length > n. */
if (umovestr(tcp, addr, n + 1, path) < 0)
tprintf("%#lx", addr);
else {
@@ -515,7 +545,8 @@ printpathn(struct tcb *tcp, long addr, i
if (trunc)
path[n] = '\0';
- if (string_quote(path, outstr, -1, n + 1) || trunc)
+ (void) string_quote(path, outstr, -1, n + 1);
+ if (trunc)
strcat(outstr, "...");
tprintf("%s", outstr);
}
@@ -527,6 +558,11 @@ printpath(struct tcb *tcp, long addr)
printpathn(tcp, addr, sizeof path - 1);
}
+/*
+ * Print string specified by address `addr' and length `len'.
+ * If `len' < 0, treat the string as a NUL-terminated string.
+ * If string length exceeds `max_strlen', append `...' to the output.
+ */
void
printstr(struct tcb *tcp, long addr, int len)
{
@@ -538,32 +574,39 @@ printstr(struct tcb *tcp, long addr, int
tprintf("NULL");
return;
}
- if (!str) {
- if ((str = malloc(max_strlen + 1)) == NULL
- || (outstr = malloc(4*max_strlen
- + sizeof "\"\"...")) == NULL) {
- fprintf(stderr, "out of memory\n");
- tprintf("%#lx", addr);
- return;
- }
+ /* Allocate static buffers if they are not allocated yet. */
+ if (!str)
+ str = malloc(max_strlen + 1);
+ if (!outstr)
+ outstr = malloc(4 * max_strlen + sizeof "\"...\"");
+ if (!str || !outstr) {
+ fprintf(stderr, "out of memory\n");
+ tprintf("%#lx", addr);
+ return;
}
if (len < 0) {
+ /*
+ * Treat as a NUL-terminated string: fetch one byte more
+ * because string_quote() quotes one byte less.
+ */
size = max_strlen + 1;
+ str[max_strlen] = '\0';
if (umovestr(tcp, addr, size, str) < 0) {
tprintf("%#lx", addr);
return;
}
}
else {
- size = MIN(len, max_strlen + 1);
+ size = MIN(len, max_strlen);
if (umoven(tcp, addr, size, str) < 0) {
tprintf("%#lx", addr);
return;
}
}
- if (string_quote(str, outstr, len, size))
+ if (string_quote(str, outstr, len, size) &&
+ (len < 0 || len > max_strlen))
strcat(outstr, "...");
tprintf("%s", outstr);