From 3b5bc93e9db4df6ded2eef7b32bda74328b04811 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 15 Mar 2003 07:14:55 +0000 Subject: String handling parinoia fixes. This patch enables the compile-time checking of strings assable by means of sizeof(). (Original code had the configure check reversed). This is extended to all safe_strcpy() users, push_string and pull_string, as well as the cli and srv derivitives. There is an attempt to cap strings at the end of the cli buffer, and clobber_region() of the speified length (when not -1 :-). Becouse of the way they are declared, the 'overmalloc a string' users of safe_strcpy() have been changed to use overmalloc_safe_strcpy() (which skips some of the checks). This whole ball of mud worked fine, until I pulled out my 'fix' for our statcache. When jeremy fixes that, we should be able to get back to testing this stuff. This patch also includes a 'marker' of the last caller to clobber_region (ie, the function that called pstrcpy() that called clobber_region) to assist in debugging problems that may have smashed the stack. This is printed at smb_panic() time. (Original idea and patch by metze). It also removes some unsused functions, and #if 0's some others that are unused but probably should be used in the near future. For now, this patch gives us some confidence on one class of trivial parsing error in our code. Andrew Bartlett (This used to be commit 31f4827acc2a2f00399a5528fc83a0dae5cebaf4) --- source3/include/srvstr.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 source3/include/srvstr.h (limited to 'source3/include/srvstr.h') diff --git a/source3/include/srvstr.h b/source3/include/srvstr.h new file mode 100644 index 0000000000..a433e0e3f9 --- /dev/null +++ b/source3/include/srvstr.h @@ -0,0 +1,36 @@ +/* + Unix SMB/CIFS implementation. + server specific string routines + Copyright (C) Andrew Tridgell 2001 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +#define srvstr_push(base_ptr, dest, src, dest_len, flags) \ + push_string(base_ptr, dest, src, dest_len, flags) + +#define srvstr_pull(base_ptr, dest, src, dest_len, src_len, flags) \ + pull_string(base_ptr, dest, src, dest_len, src_len, flags) + +/* pull a string from the smb_buf part of a packet. In this case the + string can either be null terminated or it can be terminated by the + end of the smbbuf area +*/ + +#define srvstr_pull_buf(inbuf, dest, src, dest_len, flags) \ + pull_string(inbuf, dest, src, dest_len, smb_bufrem(inbuf, src), flags) + -- cgit From 1f499a79f5468e87d26b60ffe3aa375b91cadbef Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Sat, 22 Mar 2003 13:47:42 +0000 Subject: (merge from HEAD) Small clenaup patches: - safe_string.h - don't assume that __FUNCTION__ is available - process.c - use new workaround from safe_string.h for the same - util.c - Show how many bytes we smb_panic()ed trying to smb_xmalloc() - gencache.c - Keep valgrind quiet by always null terminating. - clistr.c - Add copyright - srvstr.h - move srvstr_push into a .c file again, as a real function. - srvstr.c - revive, with 'safe' checked srvstr_push - loadparm.c - set a default for the display charset. - connection.c - use safe_strcpy() Andrew Bartlett (This used to be commit c91e76bddbe1244ddc8d12b092eba875834029ac) --- source3/include/srvstr.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'source3/include/srvstr.h') diff --git a/source3/include/srvstr.h b/source3/include/srvstr.h index a433e0e3f9..04db59cf01 100644 --- a/source3/include/srvstr.h +++ b/source3/include/srvstr.h @@ -20,9 +20,6 @@ #include "includes.h" -#define srvstr_push(base_ptr, dest, src, dest_len, flags) \ - push_string(base_ptr, dest, src, dest_len, flags) - #define srvstr_pull(base_ptr, dest, src, dest_len, src_len, flags) \ pull_string(base_ptr, dest, src, dest_len, src_len, flags) -- cgit From 54abd2aa66069e6baf7769c496f46d9dba18db39 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 30 Sep 2005 17:13:37 +0000 Subject: r10656: BIG merge from trunk. Features not copied over * \PIPE\unixinfo * winbindd's {group,alias}membership new functions * winbindd's lookupsids() functionality * swat (trunk changes to be reverted as per discussion with Deryck) (This used to be commit 939c3cb5d78e3a2236209b296aa8aba8bdce32d3) --- source3/include/srvstr.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/include/srvstr.h') diff --git a/source3/include/srvstr.h b/source3/include/srvstr.h index 04db59cf01..1029df53ae 100644 --- a/source3/include/srvstr.h +++ b/source3/include/srvstr.h @@ -18,8 +18,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "includes.h" - #define srvstr_pull(base_ptr, dest, src, dest_len, src_len, flags) \ pull_string(base_ptr, dest, src, dest_len, src_len, flags) -- cgit From fcda5b589633b96415890c569bf23e3e284e0916 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 5 Jul 2007 16:33:37 +0000 Subject: r23726: Explicitly pass down the FLAGS2 field to srvstr_pull_buf. The next checkin will pull this up to srvstr_get_path. At that point we can get more independent of the inbuf, the base_ptr in pull_string will only be used to satisfy UCS2 alignment constraints. (This used to be commit 836782b07bf133e9b2598c4a089f1c810e4c7754) --- source3/include/srvstr.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source3/include/srvstr.h') diff --git a/source3/include/srvstr.h b/source3/include/srvstr.h index 1029df53ae..99a7407a6a 100644 --- a/source3/include/srvstr.h +++ b/source3/include/srvstr.h @@ -18,14 +18,14 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define srvstr_pull(base_ptr, dest, src, dest_len, src_len, flags) \ - pull_string(base_ptr, dest, src, dest_len, src_len, flags) +#define srvstr_pull(base_ptr, smb_flags2, dest, src, dest_len, src_len, flags) \ + pull_string(base_ptr, smb_flags2, dest, src, dest_len, src_len, flags) /* pull a string from the smb_buf part of a packet. In this case the string can either be null terminated or it can be terminated by the end of the smbbuf area */ -#define srvstr_pull_buf(inbuf, dest, src, dest_len, flags) \ - pull_string(inbuf, dest, src, dest_len, smb_bufrem(inbuf, src), flags) +#define srvstr_pull_buf(inbuf, smb_flags2, dest, src, dest_len, flags) \ + pull_string(inbuf, smb_flags2, dest, src, dest_len, smb_bufrem(inbuf, src), flags) -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/include/srvstr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/include/srvstr.h') diff --git a/source3/include/srvstr.h b/source3/include/srvstr.h index 99a7407a6a..98b119e7cc 100644 --- a/source3/include/srvstr.h +++ b/source3/include/srvstr.h @@ -5,7 +5,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/include/srvstr.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/include/srvstr.h') diff --git a/source3/include/srvstr.h b/source3/include/srvstr.h index 98b119e7cc..c1bb5226e5 100644 --- a/source3/include/srvstr.h +++ b/source3/include/srvstr.h @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #define srvstr_pull(base_ptr, smb_flags2, dest, src, dest_len, src_len, flags) \ -- cgit From e8dc2ea03d212bc4b4facc2a900f6a443365c390 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 13 Jul 2007 01:22:09 +0000 Subject: r23858: Added srvstr_pull_buf_talloc() and srvstr_pull_talloc() calls and converted reply_tcon and reply_tconX to use them - to show the boilerplate usage (valgrind tested). In conjunction with Volker's srvstr_get_path_talloc() work this should allow us to start eliminating all pstrings/fstrings out of the main path processing code. I'll watch the build farm tonight... Jeremy. (This used to be commit b4eff3f68089f082781afcf90d43faa317949566) --- source3/include/srvstr.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source3/include/srvstr.h') diff --git a/source3/include/srvstr.h b/source3/include/srvstr.h index c1bb5226e5..588a807f64 100644 --- a/source3/include/srvstr.h +++ b/source3/include/srvstr.h @@ -20,6 +20,10 @@ #define srvstr_pull(base_ptr, smb_flags2, dest, src, dest_len, src_len, flags) \ pull_string(base_ptr, smb_flags2, dest, src, dest_len, src_len, flags) +/* talloc version of above. */ +#define srvstr_pull_talloc(ctx, base_ptr, smb_flags2, dest, src, src_len, flags) \ + pull_string_talloc(ctx, base_ptr, smb_flags2, dest, src, src_len, flags) + /* pull a string from the smb_buf part of a packet. In this case the string can either be null terminated or it can be terminated by the end of the smbbuf area @@ -28,3 +32,6 @@ #define srvstr_pull_buf(inbuf, smb_flags2, dest, src, dest_len, flags) \ pull_string(inbuf, smb_flags2, dest, src, dest_len, smb_bufrem(inbuf, src), flags) +/* talloc version of above. */ +#define srvstr_pull_buf_talloc(ctx, inbuf, smb_flags2, dest, src, flags) \ + pull_string_talloc(ctx, inbuf, smb_flags2, dest, src, smb_bufrem(inbuf, src), flags) -- cgit