summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/safe_string.h9
-rw-r--r--source3/libsmb/clirap.c16
2 files changed, 17 insertions, 8 deletions
diff --git a/source3/include/safe_string.h b/source3/include/safe_string.h
index 26bf6cdd6f..431dc400aa 100644
--- a/source3/include/safe_string.h
+++ b/source3/include/safe_string.h
@@ -87,4 +87,13 @@ char * __unsafe_string_function_usage_here__(void);
#define strlower(s) strlower_m(s)
#define strupper(s) strupper_m(s)
+/* the addition of the DEVELOPER checks in safe_strcpy means we must
+ * update a lot of code. To make this a little easier here are some
+ * functions that provide the lengths with less pain */
+#define pstrcpy_base(dest, src, pstring_base) \
+ safe_strcpy(dest, src, sizeof(pstring)-PTR_DIFF(dest,pstring_base)-1)
+
+#define push_pstring_base(dest, src, pstring_base) \
+ push_ascii(dest, src, sizeof(pstring)-PTR_DIFF(dest,pstring_base)-1, STR_TERMINATE)
+
#endif
diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c
index f8f840abaa..b6fbb3880a 100644
--- a/source3/libsmb/clirap.c
+++ b/source3/libsmb/clirap.c
@@ -85,19 +85,19 @@ BOOL cli_NetWkstaUserLogon(struct cli_state *cli,char *user, char *workstation)
p = param;
SSVAL(p,0,132); /* api number */
p += 2;
- pstrcpy(p,"OOWb54WrLh");
+ pstrcpy_base(p,"OOWb54WrLh",param);
p = skip_string(p,1);
- pstrcpy(p,"WB21BWDWWDDDDDDDzzzD");
+ pstrcpy_base(p,"WB21BWDWWDDDDDDDzzzD",param);
p = skip_string(p,1);
SSVAL(p,0,1);
p += 2;
- pstrcpy(p,user);
+ pstrcpy_base(p,user,param);
strupper(p);
p += 21;
p++;
p += 15;
p++;
- pstrcpy(p, workstation);
+ pstrcpy_base(p, workstation, param);
strupper(p);
p += 16;
SSVAL(p, 0, CLI_BUFFER_SIZE);
@@ -145,9 +145,9 @@ int cli_RNetShareEnum(struct cli_state *cli, void (*fn)(const char *, uint32, co
p = param;
SSVAL(p,0,0); /* api number */
p += 2;
- pstrcpy(p,"WrLeh");
+ pstrcpy_base(p,"WrLeh",param);
p = skip_string(p,1);
- pstrcpy(p,"B13BWz");
+ pstrcpy_base(p,"B13BWz",param);
p = skip_string(p,1);
SSVAL(p,0,1);
/*
@@ -221,10 +221,10 @@ BOOL cli_NetServerEnum(struct cli_state *cli, char *workgroup, uint32 stype,
p = param;
SSVAL(p,0,0x68); /* api number */
p += 2;
- pstrcpy(p,"WrLehDz");
+ pstrcpy_base(p,"WrLehDz",param);
p = skip_string(p,1);
- pstrcpy(p,"B16BBDz");
+ pstrcpy_base(p,"B16BBDz",param);
p = skip_string(p,1);
SSVAL(p,0,uLevel);