summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2003-03-06 07:55:48 +0000
committerAndrew Bartlett <abartlet@samba.org>2003-03-06 07:55:48 +0000
commit192148bab352697e625e78e7f2444e00453f35ff (patch)
treedfe53aeadc911f961ee146cb5af7ba6d1f370246
parent7a3cc345e0508848b0e2bd492789973bcf2d5841 (diff)
downloadsamba-192148bab352697e625e78e7f2444e00453f35ff.tar.gz
samba-192148bab352697e625e78e7f2444e00453f35ff.tar.bz2
samba-192148bab352697e625e78e7f2444e00453f35ff.zip
More safe_strcpy() off-by-one bug fixes. (mostly moves to pstrcpy()/fstrcpy())
Andrew Bartlett (This used to be commit 42b5514404bc7e33306c11344c6c934a1f83d295)
-rw-r--r--source3/client/client.c6
-rw-r--r--source3/client/clitar.c48
-rw-r--r--source3/utils/net.c2
-rw-r--r--source3/utils/net_rap.c4
4 files changed, 30 insertions, 30 deletions
diff --git a/source3/client/client.c b/source3/client/client.c
index 5da12fd984..065cd2fcc9 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -2346,7 +2346,7 @@ static struct cli_state *do_connect(const char *server, const char *share)
char *sharename;
/* make a copy so we don't modify the global string 'service' */
- safe_strcpy(servicename, share, sizeof(servicename)-1);
+ fstrcpy(servicename, share);
sharename = servicename;
if (*sharename == '\\') {
server = sharename+2;
@@ -2621,9 +2621,9 @@ static int do_message_op(void)
make_nmb_name(&calling, global_myname(), 0x0);
make_nmb_name(&called , desthost, name_type);
- safe_strcpy(server_name, desthost, sizeof(server_name));
+ fstrcpy(server_name, desthost);
snprintf(name_type_hex, sizeof(name_type_hex), "#%X", name_type);
- safe_strcat(server_name, name_type_hex, sizeof(server_name));
+ fstrcat(server_name, name_type_hex);
zero_ip(&ip);
if (have_ip) ip = dest_ip;
diff --git a/source3/client/clitar.c b/source3/client/clitar.c
index 74d901a2ca..dfda997ca2 100644
--- a/source3/client/clitar.c
+++ b/source3/client/clitar.c
@@ -202,7 +202,7 @@ static void writetarheader(int f, const char *aname, SMB_BIG_UINT size, time_t m
/* write out a "standard" tar format header */
hb.dbuf.name[NAMSIZ-1]='\0';
- safe_strcpy(hb.dbuf.mode, amode, strlen(amode));
+ safe_strcpy(hb.dbuf.mode, amode, sizeof(hb.dbuf.mode)-1);
oct_it((SMB_BIG_UINT)0, 8, hb.dbuf.uid);
oct_it((SMB_BIG_UINT)0, 8, hb.dbuf.gid);
oct_it((SMB_BIG_UINT) size, 13, hb.dbuf.size);
@@ -796,11 +796,11 @@ static void do_tar(file_info *finfo)
DEBUG(5, ("Excl: strlen(cur_dir) = %d\n", (int)strlen(cur_dir)));
- safe_strcpy(exclaim, cur_dir, sizeof(pstring));
+ pstrcpy(exclaim, cur_dir);
*(exclaim+strlen(exclaim)-1)='\0';
- safe_strcat(exclaim, "\\", sizeof(pstring));
- safe_strcat(exclaim, finfo->name, sizeof(exclaim));
+ pstrcat(exclaim, "\\");
+ pstrcat(exclaim, finfo->name);
DEBUG(5, ("...tar_re_search: %d\n", tar_re_search));
@@ -820,12 +820,12 @@ static void do_tar(file_info *finfo)
pstring saved_curdir;
pstring mtar_mask;
- safe_strcpy(saved_curdir, cur_dir, sizeof(saved_curdir));
+ pstrcpy(saved_curdir, cur_dir);
DEBUG(5, ("Sizeof(cur_dir)=%d, strlen(cur_dir)=%d, strlen(finfo->name)=%d\nname=%s,cur_dir=%s\n", (int)sizeof(cur_dir), (int)strlen(cur_dir), (int)strlen(finfo->name), finfo->name, cur_dir));
- safe_strcat(cur_dir,finfo->name, sizeof(cur_dir));
- safe_strcat(cur_dir,"\\", sizeof(cur_dir));
+ pstrcat(cur_dir,finfo->name);
+ pstrcat(cur_dir,"\\");
DEBUG(5, ("Writing a dir, Name = %s\n", cur_dir));
@@ -836,16 +836,16 @@ static void do_tar(file_info *finfo)
DEBUG(0,(" directory %s\n", cur_dir));
}
ntarf++; /* Make sure we have a file on there */
- safe_strcpy(mtar_mask,cur_dir, sizeof(pstring));
- safe_strcat(mtar_mask,"*", sizeof(pstring));
+ pstrcpy(mtar_mask,cur_dir);
+ pstrcat(mtar_mask,"*");
DEBUG(5, ("Doing list with mtar_mask: %s\n", mtar_mask));
do_list(mtar_mask, attribute, do_tar, False, True);
- safe_strcpy(cur_dir,saved_curdir, sizeof(pstring));
+ pstrcpy(cur_dir,saved_curdir);
}
else
{
- safe_strcpy(rname,cur_dir, sizeof(pstring));
- safe_strcat(rname,finfo->name, sizeof(pstring));
+ pstrcpy(rname,cur_dir);
+ pstrcat(rname,finfo->name);
do_atar(rname,finfo->name,finfo);
}
}
@@ -1362,8 +1362,8 @@ int cmd_setmode(void)
return 1;
}
- safe_strcpy(fname, cur_dir, sizeof(pstring));
- safe_strcat(fname, buf, sizeof(pstring));
+ pstrcpy(fname, cur_dir);
+ pstrcat(fname, buf);
while (next_token_nr(NULL,buf,NULL,sizeof(buf))) {
q=buf;
@@ -1459,32 +1459,32 @@ int process_tar(void)
if (strrchr_m(cliplist[i], '\\')) {
pstring saved_dir;
- safe_strcpy(saved_dir, cur_dir, sizeof(pstring));
+ pstrcpy(saved_dir, cur_dir);
if (*cliplist[i]=='\\') {
- safe_strcpy(tarmac, cliplist[i], sizeof(pstring));
+ pstrcpy(tarmac, cliplist[i]);
} else {
- safe_strcpy(tarmac, cur_dir, sizeof(pstring));
- safe_strcat(tarmac, cliplist[i], sizeof(pstring));
+ pstrcpy(tarmac, cur_dir);
+ pstrcat(tarmac, cliplist[i]);
}
- safe_strcpy(cur_dir, tarmac, sizeof(pstring));
+ pstrcpy(cur_dir, tarmac);
*(strrchr_m(cur_dir, '\\')+1)='\0';
DEBUG(5, ("process_tar, do_list with tarmac: %s\n", tarmac));
do_list(tarmac,attribute,do_tar, False, True);
- safe_strcpy(cur_dir,saved_dir, sizeof(pstring));
+ pstrcpy(cur_dir,saved_dir);
} else {
- safe_strcpy(tarmac, cur_dir, sizeof(pstring));
- safe_strcat(tarmac, cliplist[i], sizeof(pstring));
+ pstrcpy(tarmac, cur_dir);
+ pstrcat(tarmac, cliplist[i]);
DEBUG(5, ("process_tar, do_list with tarmac: %s\n", tarmac));
do_list(tarmac,attribute,do_tar, False, True);
}
}
} else {
pstring mask;
- safe_strcpy(mask,cur_dir, sizeof(pstring));
+ pstrcpy(mask,cur_dir);
DEBUG(5, ("process_tar, do_list with mask: %s\n", mask));
- safe_strcat(mask,"\\*", sizeof(pstring));
+ pstrcat(mask,"\\*");
do_list(mask,attribute,do_tar,False, True);
}
diff --git a/source3/utils/net.c b/source3/utils/net.c
index c1285bc64b..f6b3c5c84c 100644
--- a/source3/utils/net.c
+++ b/source3/utils/net.c
@@ -241,7 +241,7 @@ BOOL net_find_dc(struct in_addr *server_ip, fstring server_name, const char *dom
if (!lookup_dc_name(global_myname(), domain_name, server_ip, dc_name))
return False;
- safe_strcpy(server_name, dc_name, FSTRING_LEN);
+ fstrcpy(server_name, dc_name);
return True;
} else
return False;
diff --git a/source3/utils/net_rap.c b/source3/utils/net_rap.c
index 8f3dd53fa6..f52eabf494 100644
--- a/source3/utils/net_rap.c
+++ b/source3/utils/net_rap.c
@@ -638,7 +638,7 @@ static int rap_user_add(int argc, const char **argv)
if (!(cli = net_make_ipc_connection(0)))
return -1;
- safe_strcpy(userinfo.user_name, argv[0], sizeof(userinfo.user_name));
+ safe_strcpy(userinfo.user_name, argv[0], sizeof(userinfo.user_name)-1);
if (opt_flags == -1)
opt_flags = 0x21;
@@ -755,7 +755,7 @@ static int rap_group_add(int argc, const char **argv)
return -1;
/* BB check for length 21 or smaller explicitly ? BB */
- safe_strcpy(grinfo.group_name, argv[0], sizeof(grinfo.group_name));
+ safe_strcpy(grinfo.group_name, argv[0], sizeof(grinfo.group_name)-1);
grinfo.reserved1 = '\0';
grinfo.comment = smb_xstrdup(opt_comment);