summaryrefslogtreecommitdiff
path: root/source3/libsmb/libsmb_path.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/libsmb/libsmb_path.c')
-rw-r--r--source3/libsmb/libsmb_path.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/source3/libsmb/libsmb_path.c b/source3/libsmb/libsmb_path.c
index 1dcf2dd516..b286691a21 100644
--- a/source3/libsmb/libsmb_path.c
+++ b/source3/libsmb/libsmb_path.c
@@ -224,6 +224,7 @@ SMBC_parse_path(TALLOC_CTX *ctx,
const char *fname,
char **pp_workgroup,
char **pp_server,
+ uint16_t *p_port,
char **pp_share,
char **pp_path,
char **pp_user,
@@ -238,6 +239,7 @@ SMBC_parse_path(TALLOC_CTX *ctx,
/* Ensure these returns are at least valid pointers. */
*pp_server = talloc_strdup(ctx, "");
+ *p_port = 0;
*pp_share = talloc_strdup(ctx, "");
*pp_path = talloc_strdup(ctx, "");
*pp_user = talloc_strdup(ctx, "");
@@ -363,6 +365,28 @@ SMBC_parse_path(TALLOC_CTX *ctx,
return -1;
}
+ /*
+ * Does *pp_server contain a ':' ? If so
+ * this denotes the port.
+ */
+ q = strchr_m(*pp_server, ':');
+ if (q != NULL) {
+ long int port;
+ char *endptr = NULL;
+ *q = '\0';
+ q++;
+ if (*q == '\0') {
+ /* Bad port. */
+ return -1;
+ }
+ port = strtol(q, &endptr, 10);
+ if (*endptr != '\0') {
+ /* Bad port. */
+ return -1;
+ }
+ *p_port = (uint16_t)port;
+ }
+
if (*p == (char)0) {
goto decoding; /* That's it ... */
}