summaryrefslogtreecommitdiff
path: root/source3/include
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2003-01-14 06:53:35 +0000
committerAndrew Bartlett <abartlet@samba.org>2003-01-14 06:53:35 +0000
commit5c076b62d789b7682be7b04b6f4593bcaa9fe77a (patch)
tree407f404e9b4f3c8870c6ddd1fffbf2711f5aef9e /source3/include
parent1fdaca33422243062fd2954813e746213340fa08 (diff)
downloadsamba-5c076b62d789b7682be7b04b6f4593bcaa9fe77a.tar.gz
samba-5c076b62d789b7682be7b04b6f4593bcaa9fe77a.tar.bz2
samba-5c076b62d789b7682be7b04b6f4593bcaa9fe77a.zip
Commit my (disabled) fstring/pstring mixup detection code.
We need to fix some 'overmalloc' cases before it can be enabled by default. Andrew Bartlett (This used to be commit 2c2c52a18be1bd0a5ae1f4a48b1d9e18f4887dda)
Diffstat (limited to 'source3/include')
-rw-r--r--source3/include/safe_string.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/source3/include/safe_string.h b/source3/include/safe_string.h
index 118c2302bd..26bf6cdd6f 100644
--- a/source3/include/safe_string.h
+++ b/source3/include/safe_string.h
@@ -48,6 +48,25 @@
#endif /* !_SPLINT_ */
+char * __unsafe_string_function_usage_here__(void);
+
+#if 0 && defined __GNUC__ && __GNUC__ >= 2 && defined __OPTIMIZE__
+
+#define pstrcpy(d,s) ((sizeof(d) != sizeof(pstring) && sizeof(d) != sizeof(char *)) ? __unsafe_string_function_usage_here__() : safe_strcpy((d), (s),sizeof(pstring)-1))
+#define pstrcat(d,s) ((sizeof(d) != sizeof(pstring) && sizeof(d) != sizeof(char *)) ? __unsafe_string_function_usage_here__() : safe_strcat((d), (s),sizeof(pstring)-1))
+#define fstrcpy(d,s) ((sizeof(d) != sizeof(fstring) && sizeof(d) != sizeof(char *)) ? __unsafe_string_function_usage_here__() : safe_strcpy((d),(s),sizeof(fstring)-1))
+#define fstrcat(d,s) ((sizeof(d) != sizeof(fstring) && sizeof(d) != sizeof(char *)) ? __unsafe_string_function_usage_here__() : safe_strcat((d),(s),sizeof(fstring)-1))
+
+#define fstrterminate(d) ((sizeof(d) != sizeof(fstring) && sizeof(d) != sizeof(char *)) ? __unsafe_string_function_usage_here__() : (((d)[sizeof(fstring)-1]) = '\0'))
+#define pstrterminate(d) ((sizeof(d) != sizeof(pstring) && sizeof(d) != sizeof(char *)) ? __unsafe_string_function_usage_here__() : (((d)[sizeof(pstring)-1]) = '\0'))
+
+#define wpstrcpy(d,s) ((sizeof(d) != sizeof(wpstring) && sizeof(d) != sizeof(smb_ucs2_t *)) ? __unsafe_string_function_usage_here__() : safe_strcpy_w((d),(s),sizeof(wpstring)))
+#define wpstrcat(d,s) ((sizeof(d) != sizeof(wpstring) && sizeof(d) != sizeof(smb_ucs2_t *)) ? __unsafe_string_function_usage_here__() : safe_strcat_w((d),(s),sizeof(wpstring)))
+#define wfstrcpy(d,s) ((sizeof(d) != sizeof(wfstring) && sizeof(d) != sizeof(smb_ucs2_t *)) ? __unsafe_string_function_usage_here__() : safe_strcpy_w((d),(s),sizeof(wfstring)))
+#define wfstrcat(d,s) ((sizeof(d) != sizeof(wfstring) && sizeof(d) != sizeof(smb_ucs2_t *)) ? __unsafe_string_function_usage_here__() : safe_strcat_w((d),(s),sizeof(wfstring)))
+
+#else
+
#define pstrcpy(d,s) safe_strcpy((d), (s),sizeof(pstring)-1)
#define pstrcat(d,s) safe_strcat((d), (s),sizeof(pstring)-1)
#define fstrcpy(d,s) safe_strcpy((d),(s),sizeof(fstring)-1)
@@ -61,6 +80,8 @@
#define wfstrcpy(d,s) safe_strcpy_w((d),(s),sizeof(wfstring))
#define wfstrcat(d,s) safe_strcat_w((d),(s),sizeof(wfstring))
+#endif
+
/* replace some string functions with multi-byte
versions */
#define strlower(s) strlower_m(s)