diff options
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/chgpasswd.c | 42 | ||||
-rw-r--r-- | source3/smbd/lanman.c | 51 | ||||
-rw-r--r-- | source3/smbd/server.c | 26 |
3 files changed, 81 insertions, 38 deletions
diff --git a/source3/smbd/chgpasswd.c b/source3/smbd/chgpasswd.c index aef5adb72f..5a1d71d2af 100644 --- a/source3/smbd/chgpasswd.c +++ b/source3/smbd/chgpasswd.c @@ -304,34 +304,50 @@ static void pwd_sub(char *buf) static int talktochild(int master, const char *seq) { + TALLOC_CTX *frame = talloc_stackframe(); int count = 0; - fstring issue, expected; + char *issue; + char *expected; - fstrcpy(issue, "."); + issue = talloc_strdup(frame, "."); + if (!issue) { + TALLOC_FREE(frame); + return false; + } - while (next_token(&seq, expected, NULL, sizeof(expected))) - { + while (next_token_talloc(frame, &seq, &expected, NULL)) { pwd_sub(expected); count++; - if (!expect(master, issue, expected)) - { + if (!expect(master, issue, expected)) { DEBUG(3, ("Response %d incorrect\n", count)); - return False; + TALLOC_FREE(frame); + return false; } - if (!next_token(&seq, issue, NULL, sizeof(issue))) - fstrcpy(issue, "."); - + if (!next_token_talloc(frame, &seq, &issue, NULL)) { + issue = talloc_strdup(frame, "."); + if (!issue) { + TALLOC_FREE(frame); + return false; + } + } pwd_sub(issue); } + if (!strequal(issue, ".")) { /* we have one final issue to send */ - fstrcpy(expected, "."); - if (!expect(master, issue, expected)) + expected = talloc_strdup(frame, "."); + if (!expected) { + TALLOC_FREE(frame); + return false; + } + if (!expect(master, issue, expected)) { + TALLOC_FREE(frame); return False; + } } - + TALLOC_FREE(frame); return (count > 0); } diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c index b194fc6231..feb5fa4b05 100644 --- a/source3/smbd/lanman.c +++ b/source3/smbd/lanman.c @@ -1177,11 +1177,13 @@ static int get_server_info(uint32 servertype, struct srv_info_struct *s; const char *ptr = lines[i]; bool ok = True; + TALLOC_CTX *frame = NULL; + char *p; if (!*ptr) { continue; } - + if (count == alloced) { alloced += 10; *servers = SMB_REALLOC_ARRAY(*servers,struct srv_info_struct, alloced); @@ -1193,26 +1195,43 @@ static int get_server_info(uint32 servertype, memset((char *)((*servers)+count),'\0',sizeof(**servers)*(alloced-count)); } s = &(*servers)[count]; - - if (!next_token(&ptr,s->name, NULL, sizeof(s->name))) { + + frame = talloc_stackframe(); + s->name[0] = '\0'; + if (!next_token_talloc(frame,&ptr,&p, NULL)) { + TALLOC_FREE(frame); continue; } - if (!next_token(&ptr,stype, NULL, sizeof(stype))) { + fstrcpy(s->name, p); + + stype[0] = '\0'; + if (!next_token_talloc(frame,&ptr, &p, NULL)) { + TALLOC_FREE(frame); continue; } - if (!next_token(&ptr,s->comment, NULL, sizeof(s->comment))) { + fstrcpy(stype, p); + + s->comment[0] = '\0'; + if (!next_token_talloc(frame,&ptr, &p, NULL)) { + TALLOC_FREE(frame); continue; } - if (!next_token(&ptr,s->domain, NULL, sizeof(s->domain))) { + fstrcpy(s->comment, p); + + s->domain[0] = '\0'; + if (!next_token_talloc(frame,&ptr,&p, NULL)) { /* this allows us to cope with an old nmbd */ - fstrcpy(s->domain,lp_workgroup()); + fstrcpy(s->domain,lp_workgroup()); + } else { + fstrcpy(s->domain, p); } - - if (sscanf(stype,"%X",&s->type) != 1) { - DEBUG(4,("r:host file ")); - ok = False; + TALLOC_FREE(frame); + + if (sscanf(stype,"%X",&s->type) != 1) { + DEBUG(4,("r:host file ")); + ok = False; } - + /* Filter the servers/domains we return based on what was asked for. */ /* Check to see if we are being asked for a local list only. */ @@ -1222,11 +1241,11 @@ static int get_server_info(uint32 servertype, } /* doesn't match up: don't want it */ - if (!(servertype & s->type)) { - DEBUG(4,("r:serv type ")); - ok = False; + if (!(servertype & s->type)) { + DEBUG(4,("r:serv type ")); + ok = False; } - + if ((servertype & SV_TYPE_DOMAIN_ENUM) != (s->type & SV_TYPE_DOMAIN_ENUM)) { DEBUG(4,("s: dom mismatch ")); diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 328993f6b0..6b1ab6ff17 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -352,9 +352,10 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_ /* Now open a listen socket for each of the interfaces. */ for(i = 0; i < num_interfaces; i++) { + TALLOC_CTX *frame = NULL; const struct sockaddr_storage *ifss = iface_n_sockaddr_storage(i); - fstring tok; + char *tok; const char *ptr; if (ifss == NULL) { @@ -364,8 +365,9 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_ continue; } - for (ptr=ports; next_token(&ptr, tok, " \t,", - sizeof(tok)); ) { + frame = talloc_stackframe(); + for (ptr=ports; + next_token_talloc(frame,&ptr, &tok, " \t,");) { unsigned port = atoi(tok); if (port == 0 || port > 0xffff) { continue; @@ -389,6 +391,7 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_ DEBUG(0,("open_sockets_smbd: listen: " "%s\n", strerror(errno))); close(s); + TALLOC_FREE(frame); return False; } FD_SET(s,&listen_set); @@ -398,18 +401,21 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_ if (num_sockets >= FD_SETSIZE) { DEBUG(0,("open_sockets_smbd: Too " "many sockets to bind to\n")); + TALLOC_FREE(frame); return False; } } + TALLOC_FREE(frame); } } else { /* Just bind to 0.0.0.0 - accept connections from anywhere. */ - fstring tok; + TALLOC_CTX *frame = talloc_stackframe(); + char *tok; const char *ptr; const char *sock_addr = lp_socket_address(); - fstring sock_tok; + char *sock_tok; const char *sock_ptr; if (strequal(sock_addr, "0.0.0.0") || @@ -421,10 +427,9 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_ #endif } - for (sock_ptr=sock_addr; next_token(&sock_ptr, sock_tok, " \t,", - sizeof(sock_tok)); ) { - for (ptr=ports; next_token(&ptr, tok, " \t,", - sizeof(tok)); ) { + for (sock_ptr=sock_addr; + next_token_talloc(frame, &sock_ptr, &sock_tok, " \t,"); ) { + for (ptr=ports; next_token_talloc(frame, &ptr, &tok, " \t,"); ) { struct sockaddr_storage ss; unsigned port = atoi(tok); @@ -456,6 +461,7 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_ "listen: %s\n", strerror(errno))); close(s); + TALLOC_FREE(frame); return False; } @@ -468,10 +474,12 @@ static bool open_sockets_smbd(bool is_daemon, bool interactive, const char *smb_ if (num_sockets >= FD_SETSIZE) { DEBUG(0,("open_sockets_smbd: Too " "many sockets to bind to\n")); + TALLOC_FREE(frame); return False; } } } + TALLOC_FREE(frame); } SAFE_FREE(ports); |