static int name_type = 0x20;
static int max_protocol = PROTOCOL_NT1;
-static int process_tok(fstring tok);
+static int process_tok(pstring tok);
static int cmd_help(void);
/* 30 second timeout on most commands */
static int cmd_cd(void)
{
- fstring buf;
+ pstring buf;
int rc = 0;
if (next_token_nr(NULL,buf,NULL,sizeof(buf)))
{
uint16 attribute = aDIR | aSYSTEM | aHIDDEN;
pstring mask;
- fstring buf;
+ pstring buf;
char *p=buf;
int rc;
{
uint16 attribute = aDIR | aSYSTEM | aHIDDEN;
pstring mask;
- fstring buf;
+ pstring buf;
char *p=buf;
int rc;
static int cmd_more(void)
{
- fstring rname,lname,pager_cmd;
+ pstring rname,lname,pager_cmd;
char *pager;
int fd;
int rc = 0;
- fstrcpy(rname,cur_dir);
- fstrcat(rname,"\\");
+ pstrcpy(rname,cur_dir);
+ pstrcat(rname,"\\");
slprintf(lname,sizeof(lname)-1, "%s/smbmore.XXXXXX",tmpdir());
fd = smb_mkstemp(lname);
{
uint16 attribute = aSYSTEM | aHIDDEN;
pstring mget_mask;
- fstring buf;
+ pstring buf;
char *p=buf;
*mget_mask = 0;
static BOOL do_altname(char *name)
{
- fstring altname;
+ pstring altname;
if (!NT_STATUS_IS_OK(cli_qpathinfo_alt_name(cli, name, altname))) {
d_printf("%s getting alt name for %s\n",
cli_errstr(cli),name);
static int cmd_mkdir(void)
{
pstring mask;
- fstring buf;
+ pstring buf;
char *p=buf;
pstrcpy(mask,cur_dir);
static int cmd_altname(void)
{
pstring name;
- fstring buf;
+ pstring buf;
char *p=buf;
pstrcpy(name,cur_dir);
{
pstring lname;
pstring rname;
- fstring buf;
+ pstring buf;
char *p=buf;
pstrcpy(rname,cur_dir);
static int cmd_mput(void)
{
- fstring buf;
+ pstring buf;
char *p=buf;
while (next_token_nr(NULL,p,NULL,sizeof(buf))) {
static int cmd_cancel(void)
{
- fstring buf;
+ pstring buf;
int job;
if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
static int cmd_del(void)
{
pstring mask;
- fstring buf;
+ pstring buf;
uint16 attribute = aSYSTEM | aHIDDEN;
if (recurse)
static int cmd_open(void)
{
pstring mask;
- fstring buf;
+ pstring buf;
pstrcpy(mask,cur_dir);
static int cmd_rmdir(void)
{
pstring mask;
- fstring buf;
+ pstring buf;
pstrcpy(mask,cur_dir);
static int cmd_link(void)
{
pstring src,dest;
- fstring buf,buf2;
+ pstring buf,buf2;
if (!SERVER_HAS_UNIX_CIFS(cli)) {
d_printf("Server doesn't support UNIX CIFS calls.\n");
static int cmd_symlink(void)
{
pstring src,dest;
- fstring buf,buf2;
+ pstring buf,buf2;
if (!SERVER_HAS_UNIX_CIFS(cli)) {
d_printf("Server doesn't support UNIX CIFS calls.\n");
{
pstring src;
mode_t mode;
- fstring buf, buf2;
+ pstring buf, buf2;
if (!SERVER_HAS_UNIX_CIFS(cli)) {
d_printf("Server doesn't support UNIX CIFS calls.\n");
pstring src;
uid_t uid;
gid_t gid;
- fstring buf, buf2, buf3;
+ pstring buf, buf2, buf3;
if (!SERVER_HAS_UNIX_CIFS(cli)) {
d_printf("Server doesn't support UNIX CIFS calls.\n");
static int cmd_rename(void)
{
pstring src,dest;
- fstring buf,buf2;
+ pstring buf,buf2;
pstrcpy(src,cur_dir);
pstrcpy(dest,cur_dir);
static int cmd_hardlink(void)
{
pstring src,dest;
- fstring buf,buf2;
+ pstring buf,buf2;
pstrcpy(src,cur_dir);
pstrcpy(dest,cur_dir);
static int cmd_newer(void)
{
- fstring buf;
+ pstring buf;
BOOL ok;
SMB_STRUCT_STAT sbuf;
static int cmd_archive(void)
{
- fstring buf;
+ pstring buf;
if (next_token_nr(NULL,buf,NULL,sizeof(buf))) {
archive_level = atoi(buf);
static int cmd_lcd(void)
{
- fstring buf;
+ pstring buf;
pstring d;
if (next_token_nr(NULL,buf,NULL,sizeof(buf)))
{
pstring local_name;
pstring remote_name;
- fstring buf;
+ pstring buf;
char *p = buf;
SMB_STRUCT_STAT st;
static int cmd_logon(void)
{
pstring l_username, l_password;
- fstring buf,buf2;
+ pstring buf,buf2;
if (!next_token_nr(NULL,buf,NULL,sizeof(buf))) {
d_printf("logon <username> [<password>]\n");
abbreviations.
******************************************************************/
-static int process_tok(fstring tok)
+static int process_tok(pstring tok)
{
int i = 0, matches = 0;
int cmd=0;
static int cmd_help(void)
{
int i=0,j;
- fstring buf;
+ pstring buf;
if (next_token_nr(NULL,buf,NULL,sizeof(buf))) {
if ((i = process_tok(buf)) >= 0)
while (cmd[0] != '\0') {
char *p;
- fstring tok;
+ pstring tok;
int i;
if ((p = strchr_m(cmd, ';')) == 0) {
const char *ptr;
while (1) {
- fstring tok;
- fstring the_prompt;
+ pstring tok;
+ pstring the_prompt;
char *cline;
pstring line;
int i;
struct nmb_name called, calling;
const char *server_n;
struct in_addr ip;
- fstring servicename;
+ pstring servicename;
char *sharename;
/* make a copy so we don't modify the global string 'service' */
- fstrcpy(servicename, share);
+ pstrcpy(servicename, share);
sharename = servicename;
if (*sharename == '\\') {
server = sharename+2;
int main(int argc,char *argv[])
{
extern BOOL AllowDebugChange;
- fstring base_directory;
+ pstring base_directory;
int opt;
pstring query_host;
BOOL message = False;
}
break;
case 'D':
- fstrcpy(base_directory,poptGetOptArg(pc));
+ pstrcpy(base_directory,poptGetOptArg(pc));
break;
case 'g':
grepable=True;
/*******************************************************************
Resolve wildcards in a filename rename.
+ Note that name is in UNIX charset and thus potentially can be more
+ than fstring buffer (255 bytes) especially in default UTF-8 case.
+ Therefore, we use pstring inside and all calls should ensure that
+ name2 is at least pstring-long (they do already)
********************************************************************/
static BOOL resolve_wildcards(const char *name1, char *name2)
{
- fstring root1,root2;
- fstring ext1,ext2;
+ pstring root1,root2;
+ pstring ext1,ext2;
char *p,*p2, *pname1, *pname2;
- int available_space;
+ int available_space, actual_space;
pname1 = strrchr_m(name1,'/');
if (!pname1 || !pname2)
return(False);
- fstrcpy(root1,pname1);
- fstrcpy(root2,pname2);
+ pstrcpy(root1,pname1);
+ pstrcpy(root2,pname2);
p = strrchr_m(root1,'.');
if (p) {
*p = 0;
- fstrcpy(ext1,p+1);
+ pstrcpy(ext1,p+1);
} else {
- fstrcpy(ext1,"");
+ pstrcpy(ext1,"");
}
p = strrchr_m(root2,'.');
if (p) {
*p = 0;
- fstrcpy(ext2,p+1);
+ pstrcpy(ext2,p+1);
} else {
- fstrcpy(ext2,"");
+ pstrcpy(ext2,"");
}
p = root1;
available_space = sizeof(pstring) - PTR_DIFF(pname2, name2);
if (ext2[0]) {
- snprintf(pname2, available_space - 1, "%s.%s", root2, ext2);
+ actual_space = snprintf(pname2, available_space - 1, "%s.%s", root2, ext2);
+ if (actual_space >= available_space - 1) {
+ DEBUG(1,("resolve_wildcards: can't fit resolved name into specified buffer (overrun by %d bytes)\n",
+ actual_space - available_space));
+ }
} else {
pstrcpy_base(pname2, root2, name2);
}