1 --- libsafe-2.0-16-orig/src/intercept.c 2003-03-15 16:02:12.000000000 +0100
2 +++ libsafe-2.0-16/src/intercept.c 2003-03-15 16:12:22.000000000 +0100
5 char *strcpy(char *dest, const char *src)
7 - size_t max_size, len;
12 real_memcpy = (memcpy_t) getLibraryFunction("memcpy");
15 char *strncpy(char *dest, const char *src, size_t n)
17 - size_t max_size, len;
22 real_strncpy = (strncpy_t) getLibraryFunction("strncpy");
25 char *stpcpy(char *dest, const char *src)
27 - size_t max_size, len;
32 real_memcpy = (memcpy_t) getLibraryFunction("memcpy");
34 #ifndef MISSING_WCSNLEN
35 wchar_t *wcscpy(wchar_t *dest, const wchar_t *src)
37 - size_t max_bytes, max_wchars, len;
38 + size_t max_wchars, len;
42 real_wcscpy = (wcscpy_t) getLibraryFunction("wcscpy");
45 wchar_t *wcpcpy(wchar_t *dest, const wchar_t *src)
47 - size_t max_bytes, max_wchars, len;
48 + size_t max_wchars, len;
52 real_wcpcpy = (wcpcpy_t) getLibraryFunction("wcpcpy");
55 * This is needed! See the strcpy() for the reason. -ab.
57 -void *memcpy(void *dest, const void *src, size_t n)
58 +void *memcpy(void *dest, const void *src, size_t hack)
62 + * a size_t IS an unsigned long everywhere, though it sometimes
63 + * doesn't state so, making printf misinterpret it.
65 + unsigned long n = hack;
70 real_memcpy = (memcpy_t) getLibraryFunction("memcpy");
72 return real_memcpy(dest, src, n);
74 if ((max_size = _libsafe_stackVariableP(dest)) == 0) {
75 - LOG(5, "memcpy(<heap var> , <src>, %d)\n", n);
76 + LOG(5, "memcpy(<heap var> , <src>, %ld)\n", n);
77 return real_memcpy(dest, src, n);
80 - LOG(4, "memcpy(<stack var> , <src>, %d) stack limit=%d)\n", n, max_size);
81 + LOG(4, "memcpy(<stack var> , <src>, %ld) stack limit=%d)\n", n, max_size);
83 _libsafe_die("Overflow caused by memcpy()");
84 return real_memcpy(dest, src, n);
87 char *strcat(char *dest, const char *src)
91 uint dest_len, src_len;
96 char *strncat(char *dest, const char *src, size_t n)
100 uint dest_len, src_len;
103 @@ -1008,12 +1019,31 @@
104 if (is_printf_convspec[(int)*p]) {
109 + * cannot add va_list (ap here) with a number on alpha.
110 + * this is faster than the other method, and might be
111 + * a good idea to enable this on !alpha arch.
114 addr = *((caddr_t*)(ap + (atoi(pnum)-1)*sizeof(char*)));
117 addr = *((caddr_t*)(ap + c*sizeof(char*)));
129 + addr = va_arg(apc, caddr_t);
133 if (_libsafe_raVariableP((void *)(addr))) {
134 _libsafe_die("printf(\"%%n\")");
135 @@ -1172,12 +1202,32 @@
136 if (is_printf_convspec[(int)*p]) {
141 + * cannot add va_list (ap here) with a number on alpha.
142 + * this is faster than the other method, and might be
143 + * a good idea to enable this on !alpha arch.
147 addr = *((caddr_t*)(ap + (atoi(pnum)-1)*sizeof(char*)));
150 addr = *((caddr_t*)(ap + c*sizeof(char*)));
162 + addr = va_arg(apc, caddr_t);
166 if (_libsafe_raVariableP((void *)(addr))) {
167 _libsafe_die("printf(\"%%n\")");
168 @@ -1194,7 +1244,7 @@
170 int sprintf(char *str, const char *format, ...)
177 @@ -1242,7 +1292,7 @@
179 int snprintf(char *str, size_t size, const char *format, ...)
186 @@ -1288,7 +1338,7 @@
188 int vsprintf(char *str, const char *format, va_list ap)
195 @@ -1325,7 +1375,7 @@
197 int vsnprintf(char *str, size_t size, const char *format, va_list ap)
204 @@ -1360,7 +1410,7 @@
206 char *getwd(char *buf)
213 @@ -1384,7 +1434,8 @@
217 - size_t max_size, len;
222 real_gets = (gets_t) getLibraryFunction("gets");
223 @@ -1409,7 +1460,8 @@
225 char *realpath(char *path, char resolved_path[])
227 - size_t max_size, len;
231 char buf[MAXPATHLEN + 1];