blob: 9b8dba971e71a0f62cabf23ace06542b4b26fbbe [file] [log] [blame]
njn3e884182003-04-15 13:03:23 +00001
2/*--------------------------------------------------------------------*/
3/*--- Replacements for strcpy(), memcpy() et al, which run on the ---*/
4/*--- simulated CPU. ---*/
njn1d0825f2006-03-27 11:37:07 +00005/*--- mc_replace_strmem.c ---*/
njn3e884182003-04-15 13:03:23 +00006/*--------------------------------------------------------------------*/
7
8/*
nethercote137bc552003-11-14 17:47:54 +00009 This file is part of MemCheck, a heavyweight Valgrind tool for
njn0e1b5142003-04-15 14:58:06 +000010 detecting memory errors.
njn3e884182003-04-15 13:03:23 +000011
sewardj9eecbbb2010-05-03 21:37:12 +000012 Copyright (C) 2000-2010 Julian Seward
njn3e884182003-04-15 13:03:23 +000013 jseward@acm.org
14
15 This program is free software; you can redistribute it and/or
16 modify it under the terms of the GNU General Public License as
17 published by the Free Software Foundation; either version 2 of the
18 License, or (at your option) any later version.
19
20 This program is distributed in the hope that it will be useful, but
21 WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
28 02111-1307, USA.
29
30 The GNU General Public License is contained in the file COPYING.
31*/
32
njnc7561b92005-06-19 01:24:32 +000033#include "pub_tool_basics.h"
njnc7561b92005-06-19 01:24:32 +000034#include "pub_tool_hashtable.h"
njnc7561b92005-06-19 01:24:32 +000035#include "pub_tool_redir.h"
36#include "pub_tool_tooliface.h"
37#include "valgrind.h"
38
njn34419c12003-05-02 17:24:29 +000039#include "mc_include.h"
fitzhardinge98abfc72003-12-16 02:05:15 +000040#include "memcheck.h"
njn3e884182003-04-15 13:03:23 +000041
njn3e884182003-04-15 13:03:23 +000042/* ---------------------------------------------------------------------
njn1f8b3e72005-03-22 04:27:14 +000043 We have our own versions of these functions for two reasons:
44 (a) it allows us to do overlap checking
45 (b) some of the normal versions are hyper-optimised, which fools
46 Memcheck and cause spurious value warnings. Our versions are
47 simpler.
48
njn16eeb4e2005-06-16 03:56:58 +000049 Note that overenthusiastic use of PLT bypassing by the glibc people also
50 means that we need to patch multiple versions of some of the functions to
51 our own implementations.
52
njn1f8b3e72005-03-22 04:27:14 +000053 THEY RUN ON THE SIMD CPU!
njn3e884182003-04-15 13:03:23 +000054 ------------------------------------------------------------------ */
55
sewardjbd2cff22011-08-16 21:45:28 +000056/* Assignment of behavioural equivalence class tags: 2NNN is intended
57 to be reserved for Memcheck. Current usage:
58
59 2001 STRRCHR
60 2002 STRCHR
61 2003 STRCAT
62 2004 STRNCAT
63 2005 STRLCAT
64 2006 STRNLEN
65 2007 STRLEN
66 2008 STRCPY
67 2009 STRNCPY
68 2010 STRLCPY
69 2011 STRNCMP
70 2012 STRCASECMP
71 2013 STRNCASECMP
72 2014 STRCASECMP_L
73 2015 STRNCASECMP_L
74 2016 STRCMP
75 2017 MEMCHR
76 2018 MEMMOVE
77 2019 MEMCMP
78 2020 STPCPY
79 2021 MEMSET
80 2022 MEMCPY
81 2023 BCOPY
82 2024 GLIBC25___MEMMOVE_CHK
83 2025 GLIBC232_STRCHRNUL
84 2026 GLIBC232_RAWMEMCHR
85 2027 GLIBC25___STRCPY_CHK
86 2028 GLIBC25___STPCPY_CHK
87 2029 GLIBC25_MEMPCPY
88 2030 GLIBC26___MEMCPY_CHK
89 2031 STRSTR
90 2032 STRPBRK
91 2033 STRCSPN
92 2034 STRSPN
93*/
94
sewardj126e82d2011-07-12 13:33:00 +000095
sewardjdda830a2003-07-20 22:28:42 +000096/* Figure out if [dst .. dst+dstlen-1] overlaps with
97 [src .. src+srclen-1].
98 We assume that the address ranges do not wrap around
99 (which is safe since on Linux addresses >= 0xC0000000
100 are not accessible and the program will segfault in this
101 circumstance, presumably).
102*/
sewardj126e82d2011-07-12 13:33:00 +0000103static inline
njnc6168192004-11-29 13:54:10 +0000104Bool is_overlap ( void* dst, const void* src, SizeT dstlen, SizeT srclen )
njn3e884182003-04-15 13:03:23 +0000105{
sewardjdda830a2003-07-20 22:28:42 +0000106 Addr loS, hiS, loD, hiD;
107
108 if (dstlen == 0 || srclen == 0)
109 return False;
110
111 loS = (Addr)src;
112 loD = (Addr)dst;
113 hiS = loS + srclen - 1;
114 hiD = loD + dstlen - 1;
115
116 /* So figure out if [loS .. hiS] overlaps with [loD .. hiD]. */
117 if (loS < loD) {
118 return !(hiS < loD);
119 }
120 else if (loD < loS) {
121 return !(hiD < loS);
122 }
123 else {
124 /* They start at same place. Since we know neither of them has
125 zero length, they must overlap. */
126 return True;
127 }
njn3e884182003-04-15 13:03:23 +0000128}
129
sewardj126e82d2011-07-12 13:33:00 +0000130
131/* Call here to exit if we can't continue. On Android we can't call
132 _exit for some reason, so we have to blunt-instrument it. */
133__attribute__ ((__noreturn__))
134static inline void my_exit ( int x )
135{
136# if defined(VGPV_arm_linux_android)
137 __asm__ __volatile__(".word 0xFFFFFFFF");
138 while (1) {}
139# else
140 extern void _exit(int status);
sewardj49665422011-07-12 13:50:59 +0000141 _exit(x);
sewardj126e82d2011-07-12 13:33:00 +0000142# endif
143}
144
145
njn1f8b3e72005-03-22 04:27:14 +0000146// This is a macro rather than a function because we don't want to have an
147// extra function in the stack trace.
bart575ce8e2011-05-15 07:04:03 +0000148#define RECORD_OVERLAP_ERROR(s, src, dst, len) \
149 VALGRIND_DO_CLIENT_REQUEST_EXPR(0, \
150 _VG_USERREQ__MEMCHECK_RECORD_OVERLAP_ERROR, \
151 s, src, dst, len, 0)
njn3e884182003-04-15 13:03:23 +0000152
njn16eeb4e2005-06-16 03:56:58 +0000153
154#define STRRCHR(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000155 char* VG_REPLACE_FUNCTION_EZU(2001,soname,fnname)( const char* s, int c ); \
156 char* VG_REPLACE_FUNCTION_EZU(2001,soname,fnname)( const char* s, int c ) \
njn16eeb4e2005-06-16 03:56:58 +0000157 { \
158 UChar ch = (UChar)((UInt)c); \
159 UChar* p = (UChar*)s; \
160 UChar* last = NULL; \
161 while (True) { \
162 if (*p == ch) last = p; \
163 if (*p == 0) return last; \
164 p++; \
165 } \
njn3e884182003-04-15 13:03:23 +0000166 }
njn3e884182003-04-15 13:03:23 +0000167
njn16eeb4e2005-06-16 03:56:58 +0000168// Apparently rindex() is the same thing as strrchr()
njne6154662009-02-10 04:23:41 +0000169STRRCHR(VG_Z_LIBC_SONAME, strrchr)
170STRRCHR(VG_Z_LIBC_SONAME, rindex)
njnb4cfbc42009-05-04 04:20:02 +0000171#if defined(VGO_linux)
tomd2645142009-10-29 09:27:11 +0000172STRRCHR(VG_Z_LIBC_SONAME, __GI_strrchr)
njne6154662009-02-10 04:23:41 +0000173STRRCHR(VG_Z_LD_LINUX_SO_2, rindex)
njnf76d27a2009-05-28 01:53:07 +0000174#elif defined(VGO_darwin)
175STRRCHR(VG_Z_DYLD, strrchr)
176STRRCHR(VG_Z_DYLD, rindex)
njnb4cfbc42009-05-04 04:20:02 +0000177#endif
njn16eeb4e2005-06-16 03:56:58 +0000178
179
180#define STRCHR(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000181 char* VG_REPLACE_FUNCTION_EZU(2002,soname,fnname) ( const char* s, int c ); \
182 char* VG_REPLACE_FUNCTION_EZU(2002,soname,fnname) ( const char* s, int c ) \
njn16eeb4e2005-06-16 03:56:58 +0000183 { \
184 UChar ch = (UChar)((UInt)c); \
185 UChar* p = (UChar*)s; \
186 while (True) { \
187 if (*p == ch) return p; \
188 if (*p == 0) return NULL; \
189 p++; \
190 } \
njn3e884182003-04-15 13:03:23 +0000191 }
njn3e884182003-04-15 13:03:23 +0000192
njn16eeb4e2005-06-16 03:56:58 +0000193// Apparently index() is the same thing as strchr()
njne6154662009-02-10 04:23:41 +0000194STRCHR(VG_Z_LIBC_SONAME, strchr)
njne6154662009-02-10 04:23:41 +0000195STRCHR(VG_Z_LIBC_SONAME, index)
njnb4cfbc42009-05-04 04:20:02 +0000196#if defined(VGO_linux)
tomd2645142009-10-29 09:27:11 +0000197STRCHR(VG_Z_LIBC_SONAME, __GI_strchr)
njnb4cfbc42009-05-04 04:20:02 +0000198STRCHR(VG_Z_LD_LINUX_SO_2, strchr)
njne6154662009-02-10 04:23:41 +0000199STRCHR(VG_Z_LD_LINUX_SO_2, index)
njnb4cfbc42009-05-04 04:20:02 +0000200STRCHR(VG_Z_LD_LINUX_X86_64_SO_2, strchr)
njne6154662009-02-10 04:23:41 +0000201STRCHR(VG_Z_LD_LINUX_X86_64_SO_2, index)
njnf76d27a2009-05-28 01:53:07 +0000202#elif defined(VGO_darwin)
203STRCHR(VG_Z_DYLD, strchr)
204STRCHR(VG_Z_DYLD, index)
njnb4cfbc42009-05-04 04:20:02 +0000205#endif
njn3e884182003-04-15 13:03:23 +0000206
njn3e884182003-04-15 13:03:23 +0000207
njn16eeb4e2005-06-16 03:56:58 +0000208#define STRCAT(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000209 char* VG_REPLACE_FUNCTION_EZU(2003,soname,fnname) \
210 ( char* dst, const char* src ); \
211 char* VG_REPLACE_FUNCTION_EZU(2003,soname,fnname) \
212 ( char* dst, const char* src ) \
njn16eeb4e2005-06-16 03:56:58 +0000213 { \
214 const Char* src_orig = src; \
215 Char* dst_orig = dst; \
216 while (*dst) dst++; \
217 while (*src) *dst++ = *src++; \
218 *dst = 0; \
sewardjb6c04032007-11-13 20:52:29 +0000219 \
njn16eeb4e2005-06-16 03:56:58 +0000220 /* This is a bit redundant, I think; any overlap and the strcat will */ \
221 /* go forever... or until a seg fault occurs. */ \
222 if (is_overlap(dst_orig, \
223 src_orig, \
224 (Addr)dst-(Addr)dst_orig+1, \
225 (Addr)src-(Addr)src_orig+1)) \
njn718d3b12006-12-16 00:54:12 +0000226 RECORD_OVERLAP_ERROR("strcat", dst_orig, src_orig, 0); \
sewardjb6c04032007-11-13 20:52:29 +0000227 \
njn16eeb4e2005-06-16 03:56:58 +0000228 return dst_orig; \
njn3e884182003-04-15 13:03:23 +0000229 }
njn3e884182003-04-15 13:03:23 +0000230
njne6154662009-02-10 04:23:41 +0000231STRCAT(VG_Z_LIBC_SONAME, strcat)
tomd2645142009-10-29 09:27:11 +0000232#if defined(VGO_linux)
233STRCAT(VG_Z_LIBC_SONAME, __GI_strcat)
234#endif
njn16eeb4e2005-06-16 03:56:58 +0000235
236#define STRNCAT(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000237 char* VG_REPLACE_FUNCTION_EZU(2004,soname,fnname) \
sewardj0ec07f32006-01-12 12:32:32 +0000238 ( char* dst, const char* src, SizeT n ); \
sewardjbd2cff22011-08-16 21:45:28 +0000239 char* VG_REPLACE_FUNCTION_EZU(2004,soname,fnname) \
sewardj0ec07f32006-01-12 12:32:32 +0000240 ( char* dst, const char* src, SizeT n ) \
njn16eeb4e2005-06-16 03:56:58 +0000241 { \
242 const Char* src_orig = src; \
243 Char* dst_orig = dst; \
244 SizeT m = 0; \
sewardjb6c04032007-11-13 20:52:29 +0000245 \
njn16eeb4e2005-06-16 03:56:58 +0000246 while (*dst) dst++; \
247 while (m < n && *src) { m++; *dst++ = *src++; } /* concat <= n chars */ \
248 *dst = 0; /* always add null */ \
sewardjb6c04032007-11-13 20:52:29 +0000249 \
njn16eeb4e2005-06-16 03:56:58 +0000250 /* This checks for overlap after copying, unavoidable without */ \
251 /* pre-counting lengths... should be ok */ \
252 if (is_overlap(dst_orig, \
253 src_orig, \
sewardjbd2cff22011-08-16 21:45:28 +0000254 (Addr)dst-(Addr)dst_orig+1, \
njn16eeb4e2005-06-16 03:56:58 +0000255 (Addr)src-(Addr)src_orig+1)) \
njn718d3b12006-12-16 00:54:12 +0000256 RECORD_OVERLAP_ERROR("strncat", dst_orig, src_orig, n); \
sewardjb6c04032007-11-13 20:52:29 +0000257 \
njn16eeb4e2005-06-16 03:56:58 +0000258 return dst_orig; \
njn3e884182003-04-15 13:03:23 +0000259 }
njn3e884182003-04-15 13:03:23 +0000260
njne6154662009-02-10 04:23:41 +0000261STRNCAT(VG_Z_LIBC_SONAME, strncat)
njnf76d27a2009-05-28 01:53:07 +0000262#if defined(VGO_darwin)
263STRNCAT(VG_Z_DYLD, strncat)
264#endif
265
266
267/* Append src to dst. n is the size of dst's buffer. dst is guaranteed
268 to be nul-terminated after the copy, unless n <= strlen(dst_orig).
269 Returns min(n, strlen(dst_orig)) + strlen(src_orig).
270 Truncation occurred if retval >= n.
271*/
272#define STRLCAT(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000273 SizeT VG_REPLACE_FUNCTION_EZU(2005,soname,fnname) \
njnf76d27a2009-05-28 01:53:07 +0000274 ( char* dst, const char* src, SizeT n ); \
sewardjbd2cff22011-08-16 21:45:28 +0000275 SizeT VG_REPLACE_FUNCTION_EZU(2005,soname,fnname) \
njnf76d27a2009-05-28 01:53:07 +0000276 ( char* dst, const char* src, SizeT n ) \
277 { \
278 const Char* src_orig = src; \
279 Char* dst_orig = dst; \
280 SizeT m = 0; \
sewardjbd2cff22011-08-16 21:45:28 +0000281 \
njnf76d27a2009-05-28 01:53:07 +0000282 while (m < n && *dst) { m++; dst++; } \
283 if (m < n) { \
284 /* Fill as far as dst_orig[n-2], then nul-terminate. */ \
285 while (m < n-1 && *src) { m++; *dst++ = *src++; } \
286 *dst = 0; \
287 } else { \
288 /* No space to copy anything to dst. m == n */ \
289 } \
290 /* Finish counting min(n, strlen(dst_orig)) + strlen(src_orig) */ \
291 while (*src) { m++; src++; } \
292 /* This checks for overlap after copying, unavoidable without */ \
293 /* pre-counting lengths... should be ok */ \
294 if (is_overlap(dst_orig, \
295 src_orig, \
296 (Addr)dst-(Addr)dst_orig+1, \
297 (Addr)src-(Addr)src_orig+1)) \
298 RECORD_OVERLAP_ERROR("strlcat", dst_orig, src_orig, n); \
sewardjbd2cff22011-08-16 21:45:28 +0000299 \
njnf76d27a2009-05-28 01:53:07 +0000300 return m; \
301 }
302
303#if defined(VGO_darwin)
304STRLCAT(VG_Z_LIBC_SONAME, strlcat)
305STRLCAT(VG_Z_DYLD, strlcat)
306#endif
sewardj31b9ce12006-10-17 01:27:13 +0000307
njn3e884182003-04-15 13:03:23 +0000308
njn16eeb4e2005-06-16 03:56:58 +0000309#define STRNLEN(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000310 SizeT VG_REPLACE_FUNCTION_EZU(2006,soname,fnname) \
311 ( const char* str, SizeT n ); \
312 SizeT VG_REPLACE_FUNCTION_EZU(2006,soname,fnname) \
313 ( const char* str, SizeT n ) \
njn16eeb4e2005-06-16 03:56:58 +0000314 { \
315 SizeT i = 0; \
316 while (i < n && str[i] != 0) i++; \
317 return i; \
njn3e884182003-04-15 13:03:23 +0000318 }
njn3e884182003-04-15 13:03:23 +0000319
njne6154662009-02-10 04:23:41 +0000320STRNLEN(VG_Z_LIBC_SONAME, strnlen)
tomd2645142009-10-29 09:27:11 +0000321#if defined(VGO_linux)
322STRNLEN(VG_Z_LIBC_SONAME, __GI_strnlen)
323#endif
njn16eeb4e2005-06-16 03:56:58 +0000324
sewardj3ceec242003-07-30 21:24:25 +0000325
njn5ec15ed2005-08-24 19:55:51 +0000326// Note that this replacement often doesn't get used because gcc inlines
327// calls to strlen() with its own built-in version. This can be very
328// confusing if you aren't expecting it. Other small functions in this file
329// may also be inline by gcc.
njn16eeb4e2005-06-16 03:56:58 +0000330#define STRLEN(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000331 SizeT VG_REPLACE_FUNCTION_EZU(2007,soname,fnname) \
332 ( const char* str ); \
333 SizeT VG_REPLACE_FUNCTION_EZU(2007,soname,fnname) \
334 ( const char* str ) \
njn16eeb4e2005-06-16 03:56:58 +0000335 { \
336 SizeT i = 0; \
337 while (str[i] != 0) i++; \
338 return i; \
sewardj3ceec242003-07-30 21:24:25 +0000339 }
njn16eeb4e2005-06-16 03:56:58 +0000340
njnb4cfbc42009-05-04 04:20:02 +0000341STRLEN(VG_Z_LIBC_SONAME, strlen)
342#if defined(VGO_linux)
tomd2645142009-10-29 09:27:11 +0000343STRLEN(VG_Z_LIBC_SONAME, __GI_strlen)
njnb4cfbc42009-05-04 04:20:02 +0000344#endif
sewardj31b9ce12006-10-17 01:27:13 +0000345
njn16eeb4e2005-06-16 03:56:58 +0000346
347#define STRCPY(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000348 char* VG_REPLACE_FUNCTION_EZU(2008,soname,fnname) \
349 ( char* dst, const char* src ); \
350 char* VG_REPLACE_FUNCTION_EZU(2008,soname,fnname) \
351 ( char* dst, const char* src ) \
njn16eeb4e2005-06-16 03:56:58 +0000352 { \
353 const Char* src_orig = src; \
354 Char* dst_orig = dst; \
sewardjb6c04032007-11-13 20:52:29 +0000355 \
njn16eeb4e2005-06-16 03:56:58 +0000356 while (*src) *dst++ = *src++; \
357 *dst = 0; \
sewardjb6c04032007-11-13 20:52:29 +0000358 \
njn16eeb4e2005-06-16 03:56:58 +0000359 /* This checks for overlap after copying, unavoidable without */ \
360 /* pre-counting length... should be ok */ \
361 if (is_overlap(dst_orig, \
362 src_orig, \
sewardjbd2cff22011-08-16 21:45:28 +0000363 (Addr)dst-(Addr)dst_orig+1, \
njn16eeb4e2005-06-16 03:56:58 +0000364 (Addr)src-(Addr)src_orig+1)) \
njn718d3b12006-12-16 00:54:12 +0000365 RECORD_OVERLAP_ERROR("strcpy", dst_orig, src_orig, 0); \
sewardjb6c04032007-11-13 20:52:29 +0000366 \
njn16eeb4e2005-06-16 03:56:58 +0000367 return dst_orig; \
368 }
369
njne6154662009-02-10 04:23:41 +0000370STRCPY(VG_Z_LIBC_SONAME, strcpy)
tomd2645142009-10-29 09:27:11 +0000371#if defined(VGO_linux)
372STRCPY(VG_Z_LIBC_SONAME, __GI_strcpy)
373#elif defined(VGO_darwin)
njnf76d27a2009-05-28 01:53:07 +0000374STRCPY(VG_Z_DYLD, strcpy)
375#endif
njn16eeb4e2005-06-16 03:56:58 +0000376
377
378#define STRNCPY(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000379 char* VG_REPLACE_FUNCTION_EZU(2009,soname,fnname) \
sewardj0ec07f32006-01-12 12:32:32 +0000380 ( char* dst, const char* src, SizeT n ); \
sewardjbd2cff22011-08-16 21:45:28 +0000381 char* VG_REPLACE_FUNCTION_EZU(2009,soname,fnname) \
sewardj0ec07f32006-01-12 12:32:32 +0000382 ( char* dst, const char* src, SizeT n ) \
njn16eeb4e2005-06-16 03:56:58 +0000383 { \
384 const Char* src_orig = src; \
385 Char* dst_orig = dst; \
386 SizeT m = 0; \
sewardjb6c04032007-11-13 20:52:29 +0000387 \
njn16eeb4e2005-06-16 03:56:58 +0000388 while (m < n && *src) { m++; *dst++ = *src++; } \
389 /* Check for overlap after copying; all n bytes of dst are relevant, */ \
390 /* but only m+1 bytes of src if terminator was found */ \
391 if (is_overlap(dst_orig, src_orig, n, (m < n) ? m+1 : n)) \
njn718d3b12006-12-16 00:54:12 +0000392 RECORD_OVERLAP_ERROR("strncpy", dst, src, n); \
njn16eeb4e2005-06-16 03:56:58 +0000393 while (m++ < n) *dst++ = 0; /* must pad remainder with nulls */ \
394 \
395 return dst_orig; \
396 }
397
njne6154662009-02-10 04:23:41 +0000398STRNCPY(VG_Z_LIBC_SONAME, strncpy)
tomd2645142009-10-29 09:27:11 +0000399#if defined(VGO_linux)
400STRNCPY(VG_Z_LIBC_SONAME, __GI_strncpy)
401#elif defined(VGO_darwin)
njnf76d27a2009-05-28 01:53:07 +0000402STRNCPY(VG_Z_DYLD, strncpy)
403#endif
404
405
406/* Copy up to n-1 bytes from src to dst. Then nul-terminate dst if n > 0.
407 Returns strlen(src). Does not zero-fill the remainder of dst. */
408#define STRLCPY(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000409 SizeT VG_REPLACE_FUNCTION_EZU(2010,soname,fnname) \
njnf76d27a2009-05-28 01:53:07 +0000410 ( char* dst, const char* src, SizeT n ); \
sewardjbd2cff22011-08-16 21:45:28 +0000411 SizeT VG_REPLACE_FUNCTION_EZU(2010,soname,fnname) \
njnf76d27a2009-05-28 01:53:07 +0000412 ( char* dst, const char* src, SizeT n ) \
413 { \
414 const char* src_orig = src; \
415 char* dst_orig = dst; \
416 SizeT m = 0; \
sewardjbd2cff22011-08-16 21:45:28 +0000417 \
njnf76d27a2009-05-28 01:53:07 +0000418 while (m < n-1 && *src) { m++; *dst++ = *src++; } \
419 /* m non-nul bytes have now been copied, and m <= n-1. */ \
420 /* Check for overlap after copying; all n bytes of dst are relevant, */ \
421 /* but only m+1 bytes of src if terminator was found */ \
422 if (is_overlap(dst_orig, src_orig, n, (m < n) ? m+1 : n)) \
423 RECORD_OVERLAP_ERROR("strlcpy", dst, src, n); \
424 /* Nul-terminate dst. */ \
425 if (n > 0) *dst = 0; \
426 /* Finish counting strlen(src). */ \
427 while (*src) src++; \
428 return src - src_orig; \
429 }
430
431#if defined(VGO_darwin)
432STRLCPY(VG_Z_LIBC_SONAME, strlcpy)
433STRLCPY(VG_Z_DYLD, strlcpy)
434#endif
njn16eeb4e2005-06-16 03:56:58 +0000435
436
437#define STRNCMP(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000438 int VG_REPLACE_FUNCTION_EZU(2011,soname,fnname) \
sewardj0ec07f32006-01-12 12:32:32 +0000439 ( const char* s1, const char* s2, SizeT nmax ); \
sewardjbd2cff22011-08-16 21:45:28 +0000440 int VG_REPLACE_FUNCTION_EZU(2011,soname,fnname) \
sewardj0ec07f32006-01-12 12:32:32 +0000441 ( const char* s1, const char* s2, SizeT nmax ) \
njn16eeb4e2005-06-16 03:56:58 +0000442 { \
443 SizeT n = 0; \
444 while (True) { \
445 if (n >= nmax) return 0; \
446 if (*s1 == 0 && *s2 == 0) return 0; \
447 if (*s1 == 0) return -1; \
448 if (*s2 == 0) return 1; \
sewardjb6c04032007-11-13 20:52:29 +0000449 \
njn16eeb4e2005-06-16 03:56:58 +0000450 if (*(unsigned char*)s1 < *(unsigned char*)s2) return -1; \
451 if (*(unsigned char*)s1 > *(unsigned char*)s2) return 1; \
sewardjb6c04032007-11-13 20:52:29 +0000452 \
njn16eeb4e2005-06-16 03:56:58 +0000453 s1++; s2++; n++; \
454 } \
455 }
456
njne6154662009-02-10 04:23:41 +0000457STRNCMP(VG_Z_LIBC_SONAME, strncmp)
tomd2645142009-10-29 09:27:11 +0000458#if defined(VGO_linux)
459STRNCMP(VG_Z_LIBC_SONAME, __GI_strncmp)
460#elif defined(VGO_darwin)
njnf76d27a2009-05-28 01:53:07 +0000461STRNCMP(VG_Z_DYLD, strncmp)
462#endif
njn16eeb4e2005-06-16 03:56:58 +0000463
464
tomce6d0ac2010-11-12 10:03:13 +0000465#define STRCASECMP(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000466 int VG_REPLACE_FUNCTION_EZU(2012,soname,fnname) \
tomce6d0ac2010-11-12 10:03:13 +0000467 ( const char* s1, const char* s2 ); \
sewardjbd2cff22011-08-16 21:45:28 +0000468 int VG_REPLACE_FUNCTION_EZU(2012,soname,fnname) \
tomce6d0ac2010-11-12 10:03:13 +0000469 ( const char* s1, const char* s2 ) \
470 { \
tome03c8c42010-11-12 10:40:20 +0000471 extern int tolower(int); \
tomce6d0ac2010-11-12 10:03:13 +0000472 register unsigned char c1; \
473 register unsigned char c2; \
474 while (True) { \
475 c1 = tolower(*(unsigned char *)s1); \
476 c2 = tolower(*(unsigned char *)s2); \
477 if (c1 != c2) break; \
478 if (c1 == 0) break; \
479 s1++; s2++; \
480 } \
481 if ((unsigned char)c1 < (unsigned char)c2) return -1; \
482 if ((unsigned char)c1 > (unsigned char)c2) return 1; \
483 return 0; \
484 }
485
sewardj126e82d2011-07-12 13:33:00 +0000486#if !defined(VGPV_arm_linux_android)
tomce6d0ac2010-11-12 10:03:13 +0000487STRCASECMP(VG_Z_LIBC_SONAME, strcasecmp)
sewardj126e82d2011-07-12 13:33:00 +0000488#endif
489#if defined(VGO_linux) && !defined(VGPV_arm_linux_android)
tomce6d0ac2010-11-12 10:03:13 +0000490STRCASECMP(VG_Z_LIBC_SONAME, __GI_strcasecmp)
491#endif
492
493
494#define STRNCASECMP(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000495 int VG_REPLACE_FUNCTION_EZU(2013,soname,fnname) \
tomce6d0ac2010-11-12 10:03:13 +0000496 ( const char* s1, const char* s2, SizeT nmax ); \
sewardjbd2cff22011-08-16 21:45:28 +0000497 int VG_REPLACE_FUNCTION_EZU(2013,soname,fnname) \
tomce6d0ac2010-11-12 10:03:13 +0000498 ( const char* s1, const char* s2, SizeT nmax ) \
499 { \
tome03c8c42010-11-12 10:40:20 +0000500 extern int tolower(int); \
tomce6d0ac2010-11-12 10:03:13 +0000501 SizeT n = 0; \
502 while (True) { \
503 if (n >= nmax) return 0; \
504 if (*s1 == 0 && *s2 == 0) return 0; \
505 if (*s1 == 0) return -1; \
506 if (*s2 == 0) return 1; \
507 \
sewardjbd2cff22011-08-16 21:45:28 +0000508 if (tolower(*(unsigned char*)s1) \
509 < tolower(*(unsigned char*)s2)) return -1; \
510 if (tolower(*(unsigned char*)s1) \
511 > tolower(*(unsigned char*)s2)) return 1; \
tomce6d0ac2010-11-12 10:03:13 +0000512 \
513 s1++; s2++; n++; \
514 } \
515 }
516
sewardj126e82d2011-07-12 13:33:00 +0000517#if !defined(VGPV_arm_linux_android)
tomce6d0ac2010-11-12 10:03:13 +0000518STRNCASECMP(VG_Z_LIBC_SONAME, strncasecmp)
sewardj126e82d2011-07-12 13:33:00 +0000519#endif
520#if defined(VGO_linux) && !defined(VGPV_arm_linux_android)
tomce6d0ac2010-11-12 10:03:13 +0000521STRNCASECMP(VG_Z_LIBC_SONAME, __GI_strncasecmp)
522#elif defined(VGO_darwin)
523STRNCASECMP(VG_Z_DYLD, strncasecmp)
524#endif
525
526
tomce6d0ac2010-11-12 10:03:13 +0000527#define STRCASECMP_L(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000528 int VG_REPLACE_FUNCTION_EZU(2014,soname,fnname) \
tome03c8c42010-11-12 10:40:20 +0000529 ( const char* s1, const char* s2, void* locale ); \
sewardjbd2cff22011-08-16 21:45:28 +0000530 int VG_REPLACE_FUNCTION_EZU(2014,soname,fnname) \
tome03c8c42010-11-12 10:40:20 +0000531 ( const char* s1, const char* s2, void* locale ) \
tomce6d0ac2010-11-12 10:03:13 +0000532 { \
tome03c8c42010-11-12 10:40:20 +0000533 extern int tolower_l(int, void*) __attribute__((weak)); \
tomce6d0ac2010-11-12 10:03:13 +0000534 register unsigned char c1; \
535 register unsigned char c2; \
536 while (True) { \
537 c1 = tolower_l(*(unsigned char *)s1, locale); \
538 c2 = tolower_l(*(unsigned char *)s2, locale); \
539 if (c1 != c2) break; \
540 if (c1 == 0) break; \
541 s1++; s2++; \
542 } \
543 if ((unsigned char)c1 < (unsigned char)c2) return -1; \
544 if ((unsigned char)c1 > (unsigned char)c2) return 1; \
545 return 0; \
546 }
547
548STRCASECMP_L(VG_Z_LIBC_SONAME, strcasecmp_l)
549#if defined(VGO_linux)
550STRCASECMP_L(VG_Z_LIBC_SONAME, __GI_strcasecmp_l)
sewardjbd2cff22011-08-16 21:45:28 +0000551STRCASECMP_L(VG_Z_LIBC_SONAME, __GI___strcasecmp_l)
tomce6d0ac2010-11-12 10:03:13 +0000552#endif
553
554
555#define STRNCASECMP_L(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000556 int VG_REPLACE_FUNCTION_EZU(2015,soname,fnname) \
tome03c8c42010-11-12 10:40:20 +0000557 ( const char* s1, const char* s2, SizeT nmax, void* locale ); \
sewardjbd2cff22011-08-16 21:45:28 +0000558 int VG_REPLACE_FUNCTION_EZU(2015,soname,fnname) \
tome03c8c42010-11-12 10:40:20 +0000559 ( const char* s1, const char* s2, SizeT nmax, void* locale ) \
tomce6d0ac2010-11-12 10:03:13 +0000560 { \
tome03c8c42010-11-12 10:40:20 +0000561 extern int tolower_l(int, void*) __attribute__((weak)); \
tomce6d0ac2010-11-12 10:03:13 +0000562 SizeT n = 0; \
563 while (True) { \
564 if (n >= nmax) return 0; \
565 if (*s1 == 0 && *s2 == 0) return 0; \
566 if (*s1 == 0) return -1; \
567 if (*s2 == 0) return 1; \
568 \
sewardjbd2cff22011-08-16 21:45:28 +0000569 if (tolower_l(*(unsigned char*)s1, locale) \
570 < tolower_l(*(unsigned char*)s2, locale)) return -1; \
571 if (tolower_l(*(unsigned char*)s1, locale) \
572 > tolower_l(*(unsigned char*)s2, locale)) return 1; \
tomce6d0ac2010-11-12 10:03:13 +0000573 \
574 s1++; s2++; n++; \
575 } \
576 }
577
578STRNCASECMP_L(VG_Z_LIBC_SONAME, strncasecmp_l)
579#if defined(VGO_linux)
580STRNCASECMP_L(VG_Z_LIBC_SONAME, __GI_strncasecmp_l)
581#elif defined(VGO_darwin)
582STRNCASECMP_L(VG_Z_DYLD, strncasecmp_l)
583#endif
584
585
njn16eeb4e2005-06-16 03:56:58 +0000586#define STRCMP(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000587 int VG_REPLACE_FUNCTION_EZU(2016,soname,fnname) \
sewardj0ec07f32006-01-12 12:32:32 +0000588 ( const char* s1, const char* s2 ); \
sewardjbd2cff22011-08-16 21:45:28 +0000589 int VG_REPLACE_FUNCTION_EZU(2016,soname,fnname) \
sewardj0ec07f32006-01-12 12:32:32 +0000590 ( const char* s1, const char* s2 ) \
njn16eeb4e2005-06-16 03:56:58 +0000591 { \
592 register unsigned char c1; \
593 register unsigned char c2; \
594 while (True) { \
595 c1 = *(unsigned char *)s1; \
596 c2 = *(unsigned char *)s2; \
597 if (c1 != c2) break; \
598 if (c1 == 0) break; \
599 s1++; s2++; \
600 } \
601 if ((unsigned char)c1 < (unsigned char)c2) return -1; \
602 if ((unsigned char)c1 > (unsigned char)c2) return 1; \
603 return 0; \
604 }
605
njne6154662009-02-10 04:23:41 +0000606STRCMP(VG_Z_LIBC_SONAME, strcmp)
njnb4cfbc42009-05-04 04:20:02 +0000607#if defined(VGO_linux)
tomd2645142009-10-29 09:27:11 +0000608STRCMP(VG_Z_LIBC_SONAME, __GI_strcmp)
njne6154662009-02-10 04:23:41 +0000609STRCMP(VG_Z_LD_LINUX_X86_64_SO_2, strcmp)
610STRCMP(VG_Z_LD64_SO_1, strcmp)
njnb4cfbc42009-05-04 04:20:02 +0000611#endif
njn16eeb4e2005-06-16 03:56:58 +0000612
613
614#define MEMCHR(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000615 void* VG_REPLACE_FUNCTION_EZU(2017,soname,fnname) \
616 (const void *s, int c, SizeT n); \
617 void* VG_REPLACE_FUNCTION_EZU(2017,soname,fnname) \
618 (const void *s, int c, SizeT n) \
njn16eeb4e2005-06-16 03:56:58 +0000619 { \
620 SizeT i; \
621 UChar c0 = (UChar)c; \
622 UChar* p = (UChar*)s; \
623 for (i = 0; i < n; i++) \
624 if (p[i] == c0) return (void*)(&p[i]); \
625 return NULL; \
626 }
627
njne6154662009-02-10 04:23:41 +0000628MEMCHR(VG_Z_LIBC_SONAME, memchr)
njnf76d27a2009-05-28 01:53:07 +0000629#if defined(VGO_darwin)
630MEMCHR(VG_Z_DYLD, memchr)
631#endif
njn16eeb4e2005-06-16 03:56:58 +0000632
633
sewardjbd2cff22011-08-16 21:45:28 +0000634#define MEMMOVE_OR_MEMCPY(becTag, soname, fnname, do_ol_check) \
635 void* VG_REPLACE_FUNCTION_EZU(becTag,soname,fnname) \
sewardj0ec07f32006-01-12 12:32:32 +0000636 ( void *dst, const void *src, SizeT len ); \
sewardjbd2cff22011-08-16 21:45:28 +0000637 void* VG_REPLACE_FUNCTION_EZU(becTag,soname,fnname) \
sewardj0ec07f32006-01-12 12:32:32 +0000638 ( void *dst, const void *src, SizeT len ) \
njn16eeb4e2005-06-16 03:56:58 +0000639 { \
sewardjbd2cff22011-08-16 21:45:28 +0000640 if (do_ol_check && is_overlap(dst, src, len, len)) \
njn718d3b12006-12-16 00:54:12 +0000641 RECORD_OVERLAP_ERROR("memcpy", dst, src, len); \
sewardjb6c04032007-11-13 20:52:29 +0000642 \
sewardj7b4e00b2010-08-24 09:05:52 +0000643 const Addr WS = sizeof(UWord); /* 8 or 4 */ \
644 const Addr WM = WS - 1; /* 7 or 3 */ \
645 \
646 if (dst < src) { \
647 \
648 /* Copying backwards. */ \
649 SizeT n = len; \
650 Addr d = (Addr)dst; \
651 Addr s = (Addr)src; \
652 \
653 if (((s^d) & WM) == 0) { \
654 /* s and d have same UWord alignment. */ \
655 /* Pull up to a UWord boundary. */ \
656 while ((s & WM) != 0 && n >= 1) \
657 { *(UChar*)d = *(UChar*)s; s += 1; d += 1; n -= 1; } \
658 /* Copy UWords. */ \
659 while (n >= WS) \
660 { *(UWord*)d = *(UWord*)s; s += WS; d += WS; n -= WS; } \
661 if (n == 0) \
662 return dst; \
njn16eeb4e2005-06-16 03:56:58 +0000663 } \
sewardj7b4e00b2010-08-24 09:05:52 +0000664 if (((s|d) & 1) == 0) { \
665 /* Both are 16-aligned; copy what we can thusly. */ \
666 while (n >= 2) \
667 { *(UShort*)d = *(UShort*)s; s += 2; d += 2; n -= 2; } \
njn16eeb4e2005-06-16 03:56:58 +0000668 } \
sewardj7b4e00b2010-08-24 09:05:52 +0000669 /* Copy leftovers, or everything if misaligned. */ \
670 while (n >= 1) \
671 { *(UChar*)d = *(UChar*)s; s += 1; d += 1; n -= 1; } \
672 \
673 } else if (dst > src) { \
674 \
675 SizeT n = len; \
676 Addr d = ((Addr)dst) + n; \
677 Addr s = ((Addr)src) + n; \
678 \
679 /* Copying forwards. */ \
680 if (((s^d) & WM) == 0) { \
681 /* s and d have same UWord alignment. */ \
682 /* Back down to a UWord boundary. */ \
683 while ((s & WM) != 0 && n >= 1) \
684 { s -= 1; d -= 1; *(UChar*)d = *(UChar*)s; n -= 1; } \
685 /* Copy UWords. */ \
686 while (n >= WS) \
687 { s -= WS; d -= WS; *(UWord*)d = *(UWord*)s; n -= WS; } \
688 if (n == 0) \
689 return dst; \
njn16eeb4e2005-06-16 03:56:58 +0000690 } \
sewardj7b4e00b2010-08-24 09:05:52 +0000691 if (((s|d) & 1) == 0) { \
692 /* Both are 16-aligned; copy what we can thusly. */ \
693 while (n >= 2) \
694 { s -= 2; d -= 2; *(UShort*)d = *(UShort*)s; n -= 2; } \
njn16eeb4e2005-06-16 03:56:58 +0000695 } \
sewardj7b4e00b2010-08-24 09:05:52 +0000696 /* Copy leftovers, or everything if misaligned. */ \
697 while (n >= 1) \
698 { s -= 1; d -= 1; *(UChar*)d = *(UChar*)s; n -= 1; } \
699 \
njn16eeb4e2005-06-16 03:56:58 +0000700 } \
sewardj7b4e00b2010-08-24 09:05:52 +0000701 \
njn16eeb4e2005-06-16 03:56:58 +0000702 return dst; \
703 }
704
sewardjbd2cff22011-08-16 21:45:28 +0000705#define MEMMOVE(soname, fnname) \
706 MEMMOVE_OR_MEMCPY(2018, soname, fnname, 0)
707
708#define MEMCPY(soname, fnname) \
709 MEMMOVE_OR_MEMCPY(2022, soname, fnname, 1)
710
njnb4cfbc42009-05-04 04:20:02 +0000711#if defined(VGO_linux)
sewardjbd2cff22011-08-16 21:45:28 +0000712/* For older memcpy we have to use memmove-like semantics and skip the
713 overlap check; sigh; see #275284. */
714MEMMOVE(VG_Z_LIBC_SONAME, memcpy)
715MEMMOVE(VG_Z_LD_SO_1, memcpy) /* ld.so.1 */
716MEMMOVE(VG_Z_LD64_SO_1, memcpy) /* ld64.so.1 */
njnf76d27a2009-05-28 01:53:07 +0000717#elif defined(VGO_darwin)
sewardjbd2cff22011-08-16 21:45:28 +0000718MEMCPY(VG_Z_LIBC_SONAME, memcpy)
njnf76d27a2009-05-28 01:53:07 +0000719MEMCPY(VG_Z_DYLD, memcpy)
njnb4cfbc42009-05-04 04:20:02 +0000720#endif
sewardjf0b34322007-01-16 21:42:28 +0000721/* icc9 blats these around all over the place. Not only in the main
722 executable but various .so's. They are highly tuned and read
723 memory beyond the source boundary (although work correctly and
724 never go across page boundaries), so give errors when run natively,
725 at least for misaligned source arg. Just intercepting in the exe
726 only until we understand more about the problem. See
727 http://bugs.kde.org/show_bug.cgi?id=139776
728 */
729MEMCPY(NONE, _intel_fast_memcpy)
sewardj31b9ce12006-10-17 01:27:13 +0000730
njn16eeb4e2005-06-16 03:56:58 +0000731
732#define MEMCMP(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000733 int VG_REPLACE_FUNCTION_EZU(2019,soname,fnname) \
sewardj0ec07f32006-01-12 12:32:32 +0000734 ( const void *s1V, const void *s2V, SizeT n ); \
sewardjbd2cff22011-08-16 21:45:28 +0000735 int VG_REPLACE_FUNCTION_EZU(2019,soname,fnname) \
736 ( const void *s1V, const void *s2V, SizeT n ) \
njn16eeb4e2005-06-16 03:56:58 +0000737 { \
738 int res; \
739 unsigned char a0; \
740 unsigned char b0; \
741 unsigned char* s1 = (unsigned char*)s1V; \
742 unsigned char* s2 = (unsigned char*)s2V; \
sewardjb6c04032007-11-13 20:52:29 +0000743 \
njn16eeb4e2005-06-16 03:56:58 +0000744 while (n != 0) { \
745 a0 = s1[0]; \
746 b0 = s2[0]; \
747 s1 += 1; \
748 s2 += 1; \
749 res = ((int)a0) - ((int)b0); \
750 if (res != 0) \
751 return res; \
752 n -= 1; \
753 } \
754 return 0; \
755 }
756
njne6154662009-02-10 04:23:41 +0000757MEMCMP(VG_Z_LIBC_SONAME, memcmp)
758MEMCMP(VG_Z_LIBC_SONAME, bcmp)
njnb4cfbc42009-05-04 04:20:02 +0000759#if defined(VGO_linux)
njne6154662009-02-10 04:23:41 +0000760MEMCMP(VG_Z_LD_SO_1, bcmp)
njnf76d27a2009-05-28 01:53:07 +0000761#elif defined(VGO_darwin)
762MEMCMP(VG_Z_DYLD, memcmp)
763MEMCMP(VG_Z_DYLD, bcmp)
njnb4cfbc42009-05-04 04:20:02 +0000764#endif
njn3e884182003-04-15 13:03:23 +0000765
jseward0845ef82003-12-22 22:31:27 +0000766
767/* Copy SRC to DEST, returning the address of the terminating '\0' in
768 DEST. (minor variant of strcpy) */
njn16eeb4e2005-06-16 03:56:58 +0000769#define STPCPY(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000770 char* VG_REPLACE_FUNCTION_EZU(2020,soname,fnname) \
771 ( char* dst, const char* src ); \
772 char* VG_REPLACE_FUNCTION_EZU(2020,soname,fnname) \
773 ( char* dst, const char* src ) \
njn16eeb4e2005-06-16 03:56:58 +0000774 { \
775 const Char* src_orig = src; \
776 Char* dst_orig = dst; \
sewardjb6c04032007-11-13 20:52:29 +0000777 \
njn16eeb4e2005-06-16 03:56:58 +0000778 while (*src) *dst++ = *src++; \
779 *dst = 0; \
sewardjb6c04032007-11-13 20:52:29 +0000780 \
njn16eeb4e2005-06-16 03:56:58 +0000781 /* This checks for overlap after copying, unavoidable without */ \
782 /* pre-counting length... should be ok */ \
783 if (is_overlap(dst_orig, \
784 src_orig, \
785 (Addr)dst-(Addr)dst_orig+1, \
786 (Addr)src-(Addr)src_orig+1)) \
njn718d3b12006-12-16 00:54:12 +0000787 RECORD_OVERLAP_ERROR("stpcpy", dst_orig, src_orig, 0); \
sewardjb6c04032007-11-13 20:52:29 +0000788 \
njn16eeb4e2005-06-16 03:56:58 +0000789 return dst; \
sewardj44e495f2005-05-12 17:58:28 +0000790 }
njn16eeb4e2005-06-16 03:56:58 +0000791
njne6154662009-02-10 04:23:41 +0000792STPCPY(VG_Z_LIBC_SONAME, stpcpy)
njnb4cfbc42009-05-04 04:20:02 +0000793#if defined(VGO_linux)
tomd2645142009-10-29 09:27:11 +0000794STPCPY(VG_Z_LIBC_SONAME, __GI_stpcpy)
njne6154662009-02-10 04:23:41 +0000795STPCPY(VG_Z_LD_LINUX_SO_2, stpcpy)
796STPCPY(VG_Z_LD_LINUX_X86_64_SO_2, stpcpy)
njnf76d27a2009-05-28 01:53:07 +0000797#elif defined(VGO_darwin)
798STPCPY(VG_Z_DYLD, stpcpy)
njnb4cfbc42009-05-04 04:20:02 +0000799#endif
800
njn16eeb4e2005-06-16 03:56:58 +0000801
802#define MEMSET(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000803 void* VG_REPLACE_FUNCTION_EZU(2021,soname,fnname) \
804 (void *s, Int c, SizeT n); \
805 void* VG_REPLACE_FUNCTION_EZU(2021,soname,fnname) \
806 (void *s, Int c, SizeT n) \
njn16eeb4e2005-06-16 03:56:58 +0000807 { \
sewardj7b4e00b2010-08-24 09:05:52 +0000808 Addr a = (Addr)s; \
809 UInt c4 = (c & 0xFF); \
810 c4 = (c4 << 8) | c4; \
811 c4 = (c4 << 16) | c4; \
812 while ((a & 3) != 0 && n >= 1) \
813 { *(UChar*)a = (UChar)c; a += 1; n -= 1; } \
814 while (n >= 4) \
815 { *(UInt*)a = c4; a += 4; n -= 4; } \
816 while (n >= 1) \
817 { *(UChar*)a = (UChar)c; a += 1; n -= 1; } \
njn16eeb4e2005-06-16 03:56:58 +0000818 return s; \
sewardj44e495f2005-05-12 17:58:28 +0000819 }
njn16eeb4e2005-06-16 03:56:58 +0000820
njne6154662009-02-10 04:23:41 +0000821MEMSET(VG_Z_LIBC_SONAME, memset)
njnf76d27a2009-05-28 01:53:07 +0000822#if defined(VGO_darwin)
823MEMSET(VG_Z_DYLD, memset)
824#endif
njn16eeb4e2005-06-16 03:56:58 +0000825
826
sewardjbd2cff22011-08-16 21:45:28 +0000827/* memmove -- use the MEMMOVE defn which also serves for memcpy. */
njne6154662009-02-10 04:23:41 +0000828MEMMOVE(VG_Z_LIBC_SONAME, memmove)
njnf76d27a2009-05-28 01:53:07 +0000829#if defined(VGO_darwin)
830MEMMOVE(VG_Z_DYLD, memmove)
831#endif
832
833
834#define BCOPY(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000835 void VG_REPLACE_FUNCTION_EZU(2023,soname,fnname) \
njnf76d27a2009-05-28 01:53:07 +0000836 (const void *srcV, void *dstV, SizeT n); \
sewardjbd2cff22011-08-16 21:45:28 +0000837 void VG_REPLACE_FUNCTION_EZU(2023,soname,fnname) \
njnf76d27a2009-05-28 01:53:07 +0000838 (const void *srcV, void *dstV, SizeT n) \
839 { \
840 SizeT i; \
841 Char* dst = (Char*)dstV; \
842 Char* src = (Char*)srcV; \
843 if (dst < src) { \
844 for (i = 0; i < n; i++) \
845 dst[i] = src[i]; \
846 } \
847 else \
848 if (dst > src) { \
849 for (i = 0; i < n; i++) \
850 dst[n-i-1] = src[n-i-1]; \
851 } \
852 }
853
854#if defined(VGO_darwin)
855BCOPY(VG_Z_LIBC_SONAME, bcopy)
856BCOPY(VG_Z_DYLD, bcopy)
857#endif
sewardj44e495f2005-05-12 17:58:28 +0000858
jseward0845ef82003-12-22 22:31:27 +0000859
sewardj24cb2172007-02-23 09:03:26 +0000860/* glibc 2.5 variant of memmove which checks the dest is big enough.
861 There is no specific part of glibc that this is copied from. */
862#define GLIBC25___MEMMOVE_CHK(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000863 void* VG_REPLACE_FUNCTION_EZU(2024,soname,fnname) \
sewardj24cb2172007-02-23 09:03:26 +0000864 (void *dstV, const void *srcV, SizeT n, SizeT destlen); \
sewardjbd2cff22011-08-16 21:45:28 +0000865 void* VG_REPLACE_FUNCTION_EZU(2024,soname,fnname) \
sewardj24cb2172007-02-23 09:03:26 +0000866 (void *dstV, const void *srcV, SizeT n, SizeT destlen) \
867 { \
sewardj24cb2172007-02-23 09:03:26 +0000868 SizeT i; \
869 Char* dst = (Char*)dstV; \
870 Char* src = (Char*)srcV; \
871 if (destlen < n) \
872 goto badness; \
873 if (dst < src) { \
874 for (i = 0; i < n; i++) \
875 dst[i] = src[i]; \
876 } \
877 else \
878 if (dst > src) { \
879 for (i = 0; i < n; i++) \
880 dst[n-i-1] = src[n-i-1]; \
881 } \
882 return dst; \
883 badness: \
884 VALGRIND_PRINTF_BACKTRACE( \
885 "*** memmove_chk: buffer overflow detected ***: " \
njnd55f0d92009-08-03 01:38:56 +0000886 "program terminated\n"); \
sewardj126e82d2011-07-12 13:33:00 +0000887 my_exit(127); \
sewardjc271ec82007-02-27 22:36:14 +0000888 /*NOTREACHED*/ \
889 return NULL; \
sewardj24cb2172007-02-23 09:03:26 +0000890 }
891
njne6154662009-02-10 04:23:41 +0000892GLIBC25___MEMMOVE_CHK(VG_Z_LIBC_SONAME, __memmove_chk)
sewardj24cb2172007-02-23 09:03:26 +0000893
894
sewardj4e9a4b62004-11-23 00:20:17 +0000895/* Find the first occurrence of C in S or the final NUL byte. */
njn16eeb4e2005-06-16 03:56:58 +0000896#define GLIBC232_STRCHRNUL(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000897 char* VG_REPLACE_FUNCTION_EZU(2025,soname,fnname) \
898 (const char* s, int c_in); \
899 char* VG_REPLACE_FUNCTION_EZU(2025,soname,fnname) \
900 (const char* s, int c_in) \
njn16eeb4e2005-06-16 03:56:58 +0000901 { \
902 unsigned char c = (unsigned char) c_in; \
903 unsigned char* char_ptr = (unsigned char *)s; \
904 while (1) { \
905 if (*char_ptr == 0) return char_ptr; \
906 if (*char_ptr == c) return char_ptr; \
907 char_ptr++; \
908 } \
sewardj4e9a4b62004-11-23 00:20:17 +0000909 }
njn16eeb4e2005-06-16 03:56:58 +0000910
njne6154662009-02-10 04:23:41 +0000911GLIBC232_STRCHRNUL(VG_Z_LIBC_SONAME, strchrnul)
sewardj4e9a4b62004-11-23 00:20:17 +0000912
913
914/* Find the first occurrence of C in S. */
njn16eeb4e2005-06-16 03:56:58 +0000915#define GLIBC232_RAWMEMCHR(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000916 char* VG_REPLACE_FUNCTION_EZU(2026,soname,fnname) \
917 (const char* s, int c_in); \
918 char* VG_REPLACE_FUNCTION_EZU(2026,soname,fnname) \
919 (const char* s, int c_in) \
njn16eeb4e2005-06-16 03:56:58 +0000920 { \
921 unsigned char c = (unsigned char) c_in; \
922 unsigned char* char_ptr = (unsigned char *)s; \
923 while (1) { \
924 if (*char_ptr == c) return char_ptr; \
925 char_ptr++; \
926 } \
sewardj4e9a4b62004-11-23 00:20:17 +0000927 }
njn16eeb4e2005-06-16 03:56:58 +0000928
njne6154662009-02-10 04:23:41 +0000929GLIBC232_RAWMEMCHR(VG_Z_LIBC_SONAME, rawmemchr)
tomd2645142009-10-29 09:27:11 +0000930#if defined (VGO_linux)
931GLIBC232_RAWMEMCHR(VG_Z_LIBC_SONAME, __GI___rawmemchr)
932#endif
sewardj4e9a4b62004-11-23 00:20:17 +0000933
sewardjdc5d8322007-01-28 06:32:01 +0000934/* glibc variant of strcpy that checks the dest is big enough.
935 Copied from glibc-2.5/debug/test-strcpy_chk.c. */
sewardj620e5262006-12-31 00:22:30 +0000936#define GLIBC25___STRCPY_CHK(soname,fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000937 char* VG_REPLACE_FUNCTION_EZU(2027,soname,fnname) \
938 (char* dst, const char* src, SizeT len); \
939 char* VG_REPLACE_FUNCTION_EZU(2027,soname,fnname) \
940 (char* dst, const char* src, SizeT len) \
sewardj620e5262006-12-31 00:22:30 +0000941 { \
sewardj620e5262006-12-31 00:22:30 +0000942 char* ret = dst; \
943 if (! len) \
944 goto badness; \
945 while ((*dst++ = *src++) != '\0') \
946 if (--len == 0) \
947 goto badness; \
948 return ret; \
949 badness: \
950 VALGRIND_PRINTF_BACKTRACE( \
sewardj24cb2172007-02-23 09:03:26 +0000951 "*** strcpy_chk: buffer overflow detected ***: " \
njnd55f0d92009-08-03 01:38:56 +0000952 "program terminated\n"); \
sewardj126e82d2011-07-12 13:33:00 +0000953 my_exit(127); \
sewardj620e5262006-12-31 00:22:30 +0000954 /*NOTREACHED*/ \
955 return NULL; \
956 }
957
njne6154662009-02-10 04:23:41 +0000958GLIBC25___STRCPY_CHK(VG_Z_LIBC_SONAME, __strcpy_chk)
sewardj620e5262006-12-31 00:22:30 +0000959
960
sewardjdc5d8322007-01-28 06:32:01 +0000961/* glibc variant of stpcpy that checks the dest is big enough.
962 Copied from glibc-2.5/debug/test-stpcpy_chk.c. */
sewardjb8d03852007-01-27 00:49:44 +0000963#define GLIBC25___STPCPY_CHK(soname,fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000964 char* VG_REPLACE_FUNCTION_EZU(2028,soname,fnname) \
965 (char* dst, const char* src, SizeT len); \
966 char* VG_REPLACE_FUNCTION_EZU(2028,soname,fnname) \
967 (char* dst, const char* src, SizeT len) \
sewardjb8d03852007-01-27 00:49:44 +0000968 { \
sewardjdc5d8322007-01-28 06:32:01 +0000969 if (! len) \
970 goto badness; \
971 while ((*dst++ = *src++) != '\0') \
972 if (--len == 0) \
sewardjb8d03852007-01-27 00:49:44 +0000973 goto badness; \
sewardjb8d03852007-01-27 00:49:44 +0000974 return dst - 1; \
975 badness: \
976 VALGRIND_PRINTF_BACKTRACE( \
sewardj24cb2172007-02-23 09:03:26 +0000977 "*** stpcpy_chk: buffer overflow detected ***: " \
njnd55f0d92009-08-03 01:38:56 +0000978 "program terminated\n"); \
sewardj126e82d2011-07-12 13:33:00 +0000979 my_exit(127); \
sewardjb8d03852007-01-27 00:49:44 +0000980 /*NOTREACHED*/ \
981 return NULL; \
982 }
983
njne6154662009-02-10 04:23:41 +0000984GLIBC25___STPCPY_CHK(VG_Z_LIBC_SONAME, __stpcpy_chk)
sewardjb8d03852007-01-27 00:49:44 +0000985
986
sewardj841b72d2006-12-31 18:55:56 +0000987/* mempcpy */
988#define GLIBC25_MEMPCPY(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +0000989 void* VG_REPLACE_FUNCTION_EZU(2029,soname,fnname) \
sewardj841b72d2006-12-31 18:55:56 +0000990 ( void *dst, const void *src, SizeT len ); \
sewardjbd2cff22011-08-16 21:45:28 +0000991 void* VG_REPLACE_FUNCTION_EZU(2029,soname,fnname) \
sewardj841b72d2006-12-31 18:55:56 +0000992 ( void *dst, const void *src, SizeT len ) \
993 { \
994 register char *d; \
995 register char *s; \
996 SizeT len_saved = len; \
997 \
998 if (len == 0) \
999 return dst; \
1000 \
1001 if (is_overlap(dst, src, len, len)) \
1002 RECORD_OVERLAP_ERROR("mempcpy", dst, src, len); \
1003 \
1004 if ( dst > src ) { \
1005 d = (char *)dst + len - 1; \
1006 s = (char *)src + len - 1; \
1007 while ( len-- ) { \
1008 *d-- = *s--; \
1009 } \
1010 } else if ( dst < src ) { \
1011 d = (char *)dst; \
1012 s = (char *)src; \
1013 while ( len-- ) { \
1014 *d++ = *s++; \
1015 } \
1016 } \
1017 return (void*)( ((char*)dst) + len_saved ); \
1018 }
1019
njne6154662009-02-10 04:23:41 +00001020GLIBC25_MEMPCPY(VG_Z_LIBC_SONAME, mempcpy)
njnb4cfbc42009-05-04 04:20:02 +00001021#if defined(VGO_linux)
njne6154662009-02-10 04:23:41 +00001022GLIBC25_MEMPCPY(VG_Z_LD_SO_1, mempcpy) /* ld.so.1 */
njnb4cfbc42009-05-04 04:20:02 +00001023#endif
sewardj841b72d2006-12-31 18:55:56 +00001024
1025
sewardjb6c04032007-11-13 20:52:29 +00001026#define GLIBC26___MEMCPY_CHK(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +00001027 void* VG_REPLACE_FUNCTION_EZU(2030,soname,fnname) \
sewardjb6c04032007-11-13 20:52:29 +00001028 (void* dst, const void* src, SizeT len, SizeT dstlen ); \
sewardjbd2cff22011-08-16 21:45:28 +00001029 void* VG_REPLACE_FUNCTION_EZU(2030,soname,fnname) \
sewardjb6c04032007-11-13 20:52:29 +00001030 (void* dst, const void* src, SizeT len, SizeT dstlen ) \
1031 { \
sewardjb6c04032007-11-13 20:52:29 +00001032 register char *d; \
1033 register char *s; \
1034 \
1035 if (dstlen < len) goto badness; \
1036 \
1037 if (len == 0) \
1038 return dst; \
1039 \
1040 if (is_overlap(dst, src, len, len)) \
1041 RECORD_OVERLAP_ERROR("memcpy_chk", dst, src, len); \
1042 \
1043 if ( dst > src ) { \
1044 d = (char *)dst + len - 1; \
1045 s = (char *)src + len - 1; \
1046 while ( len-- ) { \
1047 *d-- = *s--; \
1048 } \
1049 } else if ( dst < src ) { \
1050 d = (char *)dst; \
1051 s = (char *)src; \
1052 while ( len-- ) { \
1053 *d++ = *s++; \
1054 } \
1055 } \
1056 return dst; \
1057 badness: \
1058 VALGRIND_PRINTF_BACKTRACE( \
1059 "*** memcpy_chk: buffer overflow detected ***: " \
njnd55f0d92009-08-03 01:38:56 +00001060 "program terminated\n"); \
sewardj126e82d2011-07-12 13:33:00 +00001061 my_exit(127); \
sewardjb6c04032007-11-13 20:52:29 +00001062 /*NOTREACHED*/ \
1063 return NULL; \
1064 }
1065
njne6154662009-02-10 04:23:41 +00001066GLIBC26___MEMCPY_CHK(VG_Z_LIBC_SONAME, __memcpy_chk)
sewardjb6c04032007-11-13 20:52:29 +00001067
1068
sewardja77687c2010-08-19 13:22:34 +00001069#define STRSTR(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +00001070 void* VG_REPLACE_FUNCTION_EZU(2031,soname,fnname) \
sewardja77687c2010-08-19 13:22:34 +00001071 (void* haystack, void* needle); \
sewardjbd2cff22011-08-16 21:45:28 +00001072 void* VG_REPLACE_FUNCTION_EZU(2031,soname,fnname) \
sewardja77687c2010-08-19 13:22:34 +00001073 (void* haystack, void* needle) \
1074 { \
1075 UChar* h = (UChar*)haystack; \
1076 UChar* n = (UChar*)needle; \
1077 \
1078 /* find the length of n, not including terminating zero */ \
1079 UWord nlen = 0; \
1080 while (n[nlen]) nlen++; \
1081 \
1082 /* if n is the empty string, match immediately. */ \
1083 if (nlen == 0) return h; \
1084 \
1085 /* assert(nlen >= 1); */ \
1086 UChar n0 = n[0]; \
1087 \
1088 while (1) { \
1089 UChar hh = *h; \
1090 if (hh == 0) return NULL; \
1091 if (hh != n0) { h++; continue; } \
1092 \
1093 UWord i; \
1094 for (i = 0; i < nlen; i++) { \
1095 if (n[i] != h[i]) \
1096 break; \
1097 } \
1098 /* assert(i >= 0 && i <= nlen); */ \
1099 if (i == nlen) \
1100 return h; \
1101 \
1102 h++; \
1103 } \
1104 }
1105
1106#if defined(VGO_linux)
1107STRSTR(VG_Z_LIBC_SONAME, strstr)
1108#endif
1109
1110
1111#define STRPBRK(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +00001112 void* VG_REPLACE_FUNCTION_EZU(2032,soname,fnname) \
sewardja77687c2010-08-19 13:22:34 +00001113 (void* sV, void* acceptV); \
sewardjbd2cff22011-08-16 21:45:28 +00001114 void* VG_REPLACE_FUNCTION_EZU(2032,soname,fnname) \
sewardja77687c2010-08-19 13:22:34 +00001115 (void* sV, void* acceptV) \
1116 { \
1117 UChar* s = (UChar*)sV; \
1118 UChar* accept = (UChar*)acceptV; \
1119 \
1120 /* find the length of 'accept', not including terminating zero */ \
1121 UWord nacc = 0; \
1122 while (accept[nacc]) nacc++; \
1123 \
1124 /* if n is the empty string, fail immediately. */ \
1125 if (nacc == 0) return NULL; \
1126 \
1127 /* assert(nacc >= 1); */ \
1128 while (1) { \
1129 UWord i; \
1130 UChar sc = *s; \
1131 if (sc == 0) \
1132 break; \
1133 for (i = 0; i < nacc; i++) { \
1134 if (sc == accept[i]) \
1135 return s; \
1136 } \
1137 s++; \
1138 } \
1139 \
1140 return NULL; \
1141 }
1142
1143#if defined(VGO_linux)
1144STRPBRK(VG_Z_LIBC_SONAME, strpbrk)
1145#endif
1146
1147
1148#define STRCSPN(soname, fnname) \
sewardjbd2cff22011-08-16 21:45:28 +00001149 SizeT VG_REPLACE_FUNCTION_EZU(2033,soname,fnname) \
sewardja77687c2010-08-19 13:22:34 +00001150 (void* sV, void* rejectV); \
sewardjbd2cff22011-08-16 21:45:28 +00001151 SizeT VG_REPLACE_FUNCTION_EZU(2033,soname,fnname) \
sewardja77687c2010-08-19 13:22:34 +00001152 (void* sV, void* rejectV) \
1153 { \
1154 UChar* s = (UChar*)sV; \
1155 UChar* reject = (UChar*)rejectV; \
1156 \
1157 /* find the length of 'reject', not including terminating zero */ \
1158 UWord nrej = 0; \
1159 while (reject[nrej]) nrej++; \
1160 \
1161 UWord len = 0; \
1162 while (1) { \
1163 UWord i; \
1164 UChar sc = *s; \
1165 if (sc == 0) \
1166 break; \
1167 for (i = 0; i < nrej; i++) { \
1168 if (sc == reject[i]) \
1169 break; \
1170 } \
1171 /* assert(i >= 0 && i <= nrej); */ \
1172 if (i < nrej) \
1173 break; \
1174 s++; \
1175 len++; \
1176 } \
1177 \
1178 return len; \
1179 }
1180
1181#if defined(VGO_linux)
1182STRCSPN(VG_Z_LIBC_SONAME, strcspn)
1183#endif
1184
1185
sewardjbd2cff22011-08-16 21:45:28 +00001186#define STRSPN(soname, fnname) \
1187 SizeT VG_REPLACE_FUNCTION_EZU(2034,soname,fnname) \
1188 (void* sV, void* acceptV); \
1189 SizeT VG_REPLACE_FUNCTION_EZU(2034,soname,fnname) \
1190 (void* sV, void* acceptV) \
1191 { \
1192 UChar* s = (UChar*)sV; \
1193 UChar* accept = (UChar*)acceptV; \
1194 \
1195 /* find the length of 'accept', not including terminating zero */ \
1196 UWord nacc = 0; \
1197 while (accept[nacc]) nacc++; \
1198 if (nacc == 0) return 0; \
1199 \
1200 UWord len = 0; \
1201 while (1) { \
1202 UWord i; \
1203 UChar sc = *s; \
1204 if (sc == 0) \
1205 break; \
1206 for (i = 0; i < nacc; i++) { \
1207 if (sc == accept[i]) \
1208 break; \
1209 } \
1210 /* assert(i >= 0 && i <= nacc); */ \
1211 if (i == nacc) \
1212 break; \
1213 s++; \
1214 len++; \
1215 } \
1216 \
1217 return len; \
1218 }
1219
1220#if defined(VGO_linux)
1221STRSPN(VG_Z_LIBC_SONAME, strspn)
1222#endif
sewardjba189352010-08-20 18:24:16 +00001223
1224
sewardj31b9ce12006-10-17 01:27:13 +00001225/*------------------------------------------------------------*/
dirk09beb9e2007-04-19 09:47:32 +00001226/*--- Improve definedness checking of process environment ---*/
1227/*------------------------------------------------------------*/
1228
sewardjddc00dd2007-11-27 11:42:47 +00001229#if defined(VGO_linux)
1230
sewardjbd2cff22011-08-16 21:45:28 +00001231/* If these wind up getting generated via a macro, so that multiple
1232 versions of each function exist (as above), use the _EZU variants
1233 to assign equivalance class tags. */
1234
dirk09beb9e2007-04-19 09:47:32 +00001235/* putenv */
njne6154662009-02-10 04:23:41 +00001236int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, putenv) (char* string);
1237int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, putenv) (char* string)
dirk09beb9e2007-04-19 09:47:32 +00001238{
1239 OrigFn fn;
1240 Word result;
1241 const char* p = string;
1242 VALGRIND_GET_ORIG_FN(fn);
1243 /* Now by walking over the string we magically produce
1244 traces when hitting undefined memory. */
1245 if (p)
1246 while (*p++)
1247 ;
1248 CALL_FN_W_W(result, fn, string);
1249 return result;
1250}
1251
1252/* unsetenv */
njne6154662009-02-10 04:23:41 +00001253int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, unsetenv) (const char* name);
1254int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, unsetenv) (const char* name)
dirk09beb9e2007-04-19 09:47:32 +00001255{
1256 OrigFn fn;
1257 Word result;
1258 const char* p = name;
1259 VALGRIND_GET_ORIG_FN(fn);
1260 /* Now by walking over the string we magically produce
1261 traces when hitting undefined memory. */
1262 if (p)
1263 while (*p++)
1264 ;
1265 CALL_FN_W_W(result, fn, name);
1266 return result;
1267}
1268
1269/* setenv */
njne6154662009-02-10 04:23:41 +00001270int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, setenv)
dirk09beb9e2007-04-19 09:47:32 +00001271 (const char* name, const char* value, int overwrite);
njne6154662009-02-10 04:23:41 +00001272int VG_WRAP_FUNCTION_ZU(VG_Z_LIBC_SONAME, setenv)
dirk09beb9e2007-04-19 09:47:32 +00001273 (const char* name, const char* value, int overwrite)
1274{
1275 OrigFn fn;
1276 Word result;
1277 const char* p;
1278 VALGRIND_GET_ORIG_FN(fn);
1279 /* Now by walking over the string we magically produce
1280 traces when hitting undefined memory. */
1281 if (name)
1282 for (p = name; *p; p++)
1283 ;
1284 if (value)
1285 for (p = value; *p; p++)
1286 ;
1287 VALGRIND_CHECK_VALUE_IS_DEFINED (overwrite);
1288 CALL_FN_W_WWW(result, fn, name, value, overwrite);
1289 return result;
1290}
1291
sewardjddc00dd2007-11-27 11:42:47 +00001292#endif /* defined(VGO_linux) */
1293
njn3e884182003-04-15 13:03:23 +00001294/*--------------------------------------------------------------------*/
njn46275862005-03-24 04:00:03 +00001295/*--- end ---*/
njn3e884182003-04-15 13:03:23 +00001296/*--------------------------------------------------------------------*/