On Fri, May 13, 2011 at 12:32:45PM +0200, Jiri Olsa wrote:
On Thu, May 12, 2011 at 11:22:23AM +0200, Jiri Olsa wrote:
> On Thu, May 12, 2011 at 10:13:49AM +0100, David Gilbert wrote:
> > On 12 May 2011 10:07, Jiri Olsa <jolsa(a)redhat.com> wrote:
> > > On Wed, May 11, 2011 at 02:27:42PM +0100, David Gilbert wrote:
> > >> Hi,
> > >> On library functions like strcpy() where there is a destination
> > >> string, latrace -A ends up trying to print out the
> > >> destination buffer which may be completely invalid.
> > >>
> > > yep, it's just taking the pointer and prints it out
> > >
> > >> Maybe it's worth doing the same trick that ltrace does, and
just
> > >> declare the destination parameters as void*
> > >
> > > hm, I wonder we could check on that string and handle bad
> > > characters somehow... display as byte values/finish the output
> > >
> > > I guess it might be worth for someone to see what the strcpy
> > > is actually changing
> >
> > Yes you could use isprint() - but you don't know how big the destination
> > buffer is and thus you could just seg running off the end of a buffer
> > that doesn't as yet have a Nil terminator.
>
> we could use the size of the src parameter and scan that amount of the
> string.. if it segfaults it'd fail anyway when the function is called ;)
>
> but having some parameters connected just for some functions
> seems like bigger change
>
> I'll check on that, but we can probably go with the dest parameters
> being changed to void* as you suggested
still checking another solution.. however, if you'd think about other
functions that need same treatment, please let me know , since I probably
missed some
almost forgot..
I'll put this in with the signal handlers change, so early next week..
jirka
jirka
---
etc/latrace.d/headers/stdio.h | 8 ++++----
etc/latrace.d/headers/string.h | 16 ++++++++--------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/etc/latrace.d/headers/stdio.h b/etc/latrace.d/headers/stdio.h
index c0f37b8..eac2228 100644
--- a/etc/latrace.d/headers/stdio.h
+++ b/etc/latrace.d/headers/stdio.h
@@ -39,12 +39,12 @@ void setlinebuf(FILE *stream);
int fprintf(FILE *stream, char *format);
int printf(char *format);
-int sprintf(char *s, char *format);
+int sprintf(void *s, char *format);
int vfprintf(FILE *s, char *format);
int vprintf(char *format);
-int vsprintf(char *s, char *format);
-int snprintf(char *s, size_t maxlen, char *format);
-int vsnprintf(char *s, size_t maxlen, char *format);
+int vsprintf(void *s, char *format);
+int snprintf(void *s, size_t maxlen, char *format);
+int vsnprintf(void *s, size_t maxlen, char *format);
int vasprintf(void *ptr, char *f);
int __asprintf(void *ptr, char *fmt);
int asprintf(void *ptr, char *fmt);
diff --git a/etc/latrace.d/headers/string.h b/etc/latrace.d/headers/string.h
index 98c2cb3..1f8a448 100644
--- a/etc/latrace.d/headers/string.h
+++ b/etc/latrace.d/headers/string.h
@@ -12,10 +12,10 @@ void* rawmemchr(void *s, int c);
void* memrchr(void *s, int c, size_t n);
-char* strcpy(char *dest, char *src);
-char* strncpy(char *dest, char *src, size_t n);
-char* strcat(char *dest, char *src);
-char* strncat(char *dest, char *src, size_t n);
+char* strcpy(void *dest, char *src);
+char* strncpy(void *dest, char *src, size_t n);
+char* strcat(void *dest, char *src);
+char* strncat(void *dest, char *src, size_t n);
int strcmp(char *s1, char *s2);
int strncmp(char *s1, char *s2, size_t n);
int strcoll(char *s1, char *s2);
@@ -76,10 +76,10 @@ int strncasecmp_l(char *s1, char *s2, size_t n, __locale_t loc);
char* strsep(void *stringp, char *delim);
int strverscmp(char *s1, char *s2);
char* strsignal(int sig);
-char* __stpcpy(char *dest, char *src);
-char* stpcpy(char *dest, char *src);
-char* __stpncpy(char *dest, char *src, size_t n);
-char* stpncpy(char *dest, char *src, size_t n);
+char* __stpcpy(void *dest, char *src);
+char* stpcpy(void *dest, char *src);
+char* __stpncpy(void *dest, char *src, size_t n);
+char* stpncpy(void *dest, char *src, size_t n);
char* strfry(char *string);
void* memfrob(void *s, size_t n);
char* basename(char *filename);
--
1.7.4.4
_______________________________________________
latrace mailing list
latrace(a)lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/latrace