summaryrefslogtreecommitdiff
path: root/source3/client
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-03-13 22:49:56 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:15:26 -0500
commit8f96b1bf0f03e05fbf2ded0856a03bd522549d7b (patch)
tree0d860f8c31b7cff49a7254796a357c9b22120a57 /source3/client
parentf6071a90c723e95ed040231aa84b30e87e41e726 (diff)
downloadsamba-8f96b1bf0f03e05fbf2ded0856a03bd522549d7b.tar.gz
samba-8f96b1bf0f03e05fbf2ded0856a03bd522549d7b.tar.bz2
samba-8f96b1bf0f03e05fbf2ded0856a03bd522549d7b.zip
r14351: Ensure we use the minimum of PATH_MAX and sizeof(pstring).
Fix Coverity #59. Jeremy. (This used to be commit d793e1550cc8c79a2764609cddec082470d226e4)
Diffstat (limited to 'source3/client')
-rw-r--r--source3/client/client.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/source3/client/client.c b/source3/client/client.c
index 0126e17c5b..1d42fd2995 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -2919,16 +2919,22 @@ static char **remote_completion(const char *text, int len)
info.text = text;
info.len = len;
- if (len >= PATH_MAX)
+ if (len >= MIN(PATH_MAX,sizeof(pstring))) {
return(NULL);
+ }
info.matches = SMB_MALLOC_ARRAY(char *,MAX_COMPLETIONS);
- if (!info.matches) return NULL;
+ if (!info.matches) {
+ return NULL;
+ }
info.matches[0] = NULL;
- for (i = len-1; i >= 0; i--)
- if ((text[i] == '/') || (text[i] == '\\'))
+ for (i = len-1; i >= 0; i--) {
+ if ((text[i] == '/') || (text[i] == '\\')) {
break;
+ }
+ }
+
info.text = text+i+1;
info.samelen = info.len = len-i-1;
@@ -2936,8 +2942,9 @@ static char **remote_completion(const char *text, int len)
strncpy(info.dirmask, text, i+1);
info.dirmask[i+1] = 0;
pstr_sprintf(dirmask, "%s%*s*", cur_dir, i-1, text);
- } else
+ } else {
pstr_sprintf(dirmask, "%s*", cur_dir);
+ }
if (cli_list(cli, dirmask, aDIR | aSYSTEM | aHIDDEN, completion_remote_filter, &info) < 0)
goto cleanup;