summaryrefslogtreecommitdiff
path: root/source3/client/clitar.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2003-03-18 11:22:52 +0000
committerAndrew Bartlett <abartlet@samba.org>2003-03-18 11:22:52 +0000
commitd5ee9b2f480ddbda0b8f69409698d27c99384f9c (patch)
tree2664e91ce8bbfedeaf34292fca1d5dcfb8039176 /source3/client/clitar.c
parent5452ecebc7d89fac6e1047b92b77be47fe85914c (diff)
downloadsamba-d5ee9b2f480ddbda0b8f69409698d27c99384f9c.tar.gz
samba-d5ee9b2f480ddbda0b8f69409698d27c99384f9c.tar.bz2
samba-d5ee9b2f480ddbda0b8f69409698d27c99384f9c.zip
Jeremy merged across my string parinoia fixes, but forgot to enable them! :-)
This patch catches up on the rest of the work - as much string checking as is possible is done at compile time, and the rest at runtime. Lots of code converted to pstrcpy() etc, and other code reworked to correctly call sizeof(). Andrew Bartlett (This used to be commit c5b604e2ee67d74241ae2fa07ae904647d35a2be)
Diffstat (limited to 'source3/client/clitar.c')
-rw-r--r--source3/client/clitar.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/source3/client/clitar.c b/source3/client/clitar.c
index 612a383ce0..579110f75f 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);
}