summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-12-07 17:32:32 -0800
committerJeremy Allison <jra@samba.org>2007-12-07 17:32:32 -0800
commit42cfffae80480eae4381902fff3f7c61f858a933 (patch)
tree2fc1bc486fa988a4f2854310bcf91943db1aa566 /source3/libsmb
parent25288b0e4472c728fc5a3a70c6c3e1f621ffae5f (diff)
downloadsamba-42cfffae80480eae4381902fff3f7c61f858a933.tar.gz
samba-42cfffae80480eae4381902fff3f7c61f858a933.tar.bz2
samba-42cfffae80480eae4381902fff3f7c61f858a933.zip
Remove next_token - all uses must now be next_token_talloc.
No more temptations to use static length strings. Jeremy. (This used to be commit ec003f39369910dee852b7cafb883ddaa321c2de)
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/clikrb5.c17
-rw-r--r--source3/libsmb/libsmbclient.c55
-rw-r--r--source3/libsmb/namequery.c30
3 files changed, 61 insertions, 41 deletions
diff --git a/source3/libsmb/clikrb5.c b/source3/libsmb/clikrb5.c
index d996d61a48..549574caad 100644
--- a/source3/libsmb/clikrb5.c
+++ b/source3/libsmb/clikrb5.c
@@ -1592,6 +1592,7 @@ done:
krb5_error_code ret = 0;
TALLOC_CTX *mem_ctx;
char keytab_string[MAX_KEYTAB_NAME_LEN];
+ char *kt_str = NULL;
bool found_valid_name = False;
const char *pragma = "FILE";
const char *tmp = NULL;
@@ -1654,29 +1655,27 @@ done:
ret = ENOMEM;
goto out;
}
-
+
if (strncmp(tmp, "ANY:", 4) == 0) {
tmp += 4;
}
memset(&keytab_string, '\0', sizeof(keytab_string));
- while (next_token(&tmp, keytab_string, ",", sizeof(keytab_string))) {
-
- if (strncmp(keytab_string, "WRFILE:", 7) == 0) {
+ while (next_token_talloc(mem_ctx, &tmp, &kt_str, ",")) {
+ if (strncmp(kt_str, "WRFILE:", 7) == 0) {
found_valid_name = True;
- tmp = keytab_string;
+ tmp = kt_str;
tmp += 7;
}
- if (strncmp(keytab_string, "FILE:", 5) == 0) {
+ if (strncmp(kt_str, "FILE:", 5) == 0) {
found_valid_name = True;
- tmp = keytab_string;
+ tmp = kt_str;
tmp += 5;
}
if (found_valid_name) {
-
if (tmp[0] != '/') {
ret = KRB5_KT_BADNAME;
goto out;
@@ -1690,7 +1689,7 @@ done:
break;
}
}
-
+
if (!found_valid_name) {
ret = KRB5_KT_UNKNOWN_TYPE;
goto out;
diff --git a/source3/libsmb/libsmbclient.c b/source3/libsmb/libsmbclient.c
index de2eaa7cfa..9f5567576f 100644
--- a/source3/libsmb/libsmbclient.c
+++ b/source3/libsmb/libsmbclient.c
@@ -4219,7 +4219,7 @@ parse_ace(struct cli_state *ipc_cli,
{
char *p;
const char *cp;
- fstring tok;
+ char *tok;
unsigned int atype;
unsigned int aflags;
unsigned int amask;
@@ -4230,6 +4230,7 @@ parse_ace(struct cli_state *ipc_cli,
const char *perm;
uint32 mask;
};
+ TALLOC_CTX *frame = talloc_stackframe();
/* These values discovered by inspection */
static const struct perm_value special_values[] = {
@@ -4252,7 +4253,10 @@ parse_ace(struct cli_state *ipc_cli,
ZERO_STRUCTP(ace);
p = strchr_m(str,':');
- if (!p) return False;
+ if (!p) {
+ TALLOC_FREE(frame);
+ return False;
+ }
*p = '\0';
p++;
/* Try to parse numeric form */
@@ -4265,12 +4269,14 @@ parse_ace(struct cli_state *ipc_cli,
/* Try to parse text form */
if (!convert_string_to_sid(ipc_cli, pol, numeric, &sid, str)) {
- return False;
+ TALLOC_FREE(frame);
+ return false;
}
cp = p;
- if (!next_token(&cp, tok, "/", sizeof(fstring))) {
- return False;
+ if (!next_token_talloc(frame, &cp, &tok, "/")) {
+ TALLOC_FREE(frame);
+ return false;
}
if (StrnCaseCmp(tok, "ALLOWED", strlen("ALLOWED")) == 0) {
@@ -4278,23 +4284,27 @@ parse_ace(struct cli_state *ipc_cli,
} else if (StrnCaseCmp(tok, "DENIED", strlen("DENIED")) == 0) {
atype = SEC_ACE_TYPE_ACCESS_DENIED;
} else {
- return False;
+ TALLOC_FREE(frame);
+ return false;
}
/* Only numeric form accepted for flags at present */
- if (!(next_token(&cp, tok, "/", sizeof(fstring)) &&
+ if (!(next_token_talloc(frame, &cp, &tok, "/") &&
sscanf(tok, "%i", &aflags))) {
- return False;
+ TALLOC_FREE(frame);
+ return false;
}
- if (!next_token(&cp, tok, "/", sizeof(fstring))) {
- return False;
+ if (!next_token_talloc(frame, &cp, &tok, "/")) {
+ TALLOC_FREE(frame);
+ return false;
}
if (strncmp(tok, "0x", 2) == 0) {
if (sscanf(tok, "%i", &amask) != 1) {
- return False;
+ TALLOC_FREE(frame);
+ return false;
}
goto done;
}
@@ -4318,18 +4328,23 @@ parse_ace(struct cli_state *ipc_cli,
}
}
- if (!found) return False;
+ if (!found) {
+ TALLOC_FREE(frame);
+ return false;
+ }
p++;
}
if (*p) {
- return False;
+ TALLOC_FREE(frame);
+ return false;
}
done:
mask = amask;
init_sec_ace(ace, &sid, atype, mask, aflags);
- return True;
+ TALLOC_FREE(frame);
+ return true;
}
/* add an ACE to a list of ACEs in a SEC_ACL */
@@ -4368,7 +4383,7 @@ sec_desc_parse(TALLOC_CTX *ctx,
char *str)
{
const char *p = str;
- fstring tok;
+ char *tok;
SEC_DESC *ret = NULL;
size_t sd_size;
DOM_SID *group_sid=NULL;
@@ -4376,7 +4391,7 @@ sec_desc_parse(TALLOC_CTX *ctx,
SEC_ACL *dacl=NULL;
int revision=1;
- while (next_token(&p, tok, "\t,\r\n", sizeof(tok))) {
+ while (next_token_talloc(ctx, &p, &tok, "\t,\r\n")) {
if (StrnCaseCmp(tok,"REVISION:", 9) == 0) {
revision = strtol(tok+9, NULL, 16);
@@ -4544,7 +4559,8 @@ dos_attr_parse(SMBCCTX *context,
{
int n;
const char *p = str;
- fstring tok;
+ char *tok = NULL;
+ TALLOC_CTX *frame = NULL;
struct {
const char * create_time_attr;
const char * access_time_attr;
@@ -4577,8 +4593,8 @@ dos_attr_parse(SMBCCTX *context,
}
}
- while (next_token(&p, tok, "\t,\r\n", sizeof(tok))) {
-
+ frame = talloc_stackframe();
+ while (next_token_talloc(frame, &p, &tok, "\t,\r\n")) {
if (StrnCaseCmp(tok, "MODE:", 5) == 0) {
dad->mode = strtol(tok+5, NULL, 16);
continue;
@@ -4622,6 +4638,7 @@ dos_attr_parse(SMBCCTX *context,
continue;
}
}
+ TALLOC_FREE(frame);
}
/*****************************************************
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index 04db3322ca..9650b5fc45 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -791,10 +791,10 @@ bool getlmhostsent(TALLOC_CTX *ctx, XFILE *fp, char **pp_name, int *name_type,
*pp_name = NULL;
while(!x_feof(fp) && !x_ferror(fp)) {
- char ip[INET6_ADDRSTRLEN];
- fstring flags;
- fstring extra;
- fstring name;
+ char *ip;
+ char *flags;
+ char *extra;
+ char *name;
const char *ptr;
char *ptr1;
int count = 0;
@@ -815,13 +815,13 @@ bool getlmhostsent(TALLOC_CTX *ctx, XFILE *fp, char **pp_name, int *name_type,
ptr = line;
- if (next_token(&ptr,ip ,NULL,sizeof(ip)))
+ if (next_token_talloc(ctx, &ptr, &ip, NULL))
++count;
- if (next_token(&ptr,name ,NULL, sizeof(name)))
+ if (next_token_talloc(ctx, &ptr, &name, NULL))
++count;
- if (next_token(&ptr,flags,NULL, sizeof(flags)))
+ if (next_token_talloc(ctx, &ptr, &flags, NULL))
++count;
- if (next_token(&ptr,extra,NULL, sizeof(extra)))
+ if (next_token_talloc(ctx, &ptr, &extra, NULL))
++count;
if (count <= 0)
@@ -1422,10 +1422,11 @@ NTSTATUS internal_resolve_name(const char *name,
const char *resolve_order)
{
const char *name_resolve_list;
- fstring tok;
+ char *tok;
const char *ptr;
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
int i;
+ TALLOC_CTX *frame = NULL;
*return_iplist = NULL;
*return_count = 0;
@@ -1488,7 +1489,8 @@ NTSTATUS internal_resolve_name(const char *name,
/* iterate through the name resolution backends */
- while (next_token(&ptr, tok, LIST_SEP, sizeof(tok))) {
+ frame = talloc_stackframe();
+ while (next_token_talloc(frame, &ptr, &tok, LIST_SEP)) {
if((strequal(tok, "host") || strequal(tok, "hosts"))) {
status = resolve_hosts(name, name_type, return_iplist,
return_count);
@@ -1545,6 +1547,7 @@ NTSTATUS internal_resolve_name(const char *name,
/* All of the resolve_* functions above have returned false. */
+ TALLOC_FREE(frame);
SAFE_FREE(*return_iplist);
*return_count = 0;
@@ -1595,6 +1598,7 @@ NTSTATUS internal_resolve_name(const char *name,
DEBUG(10, ("\n"));
}
+ TALLOC_FREE(frame);
return status;
}
@@ -1738,7 +1742,7 @@ static NTSTATUS get_dc_list(const char *domain,
const char *p;
char *port_str = NULL;
int port;
- fstring name;
+ char *name;
int num_addresses = 0;
int local_count, i, j;
struct ip_service *return_iplist = NULL;
@@ -1826,7 +1830,7 @@ static NTSTATUS get_dc_list(const char *domain,
*/
p = pserver;
- while (next_token(&p,name,LIST_SEP,sizeof(name))) {
+ while (next_token_talloc(ctx, &p, &name, LIST_SEP)) {
if (strequal(name, "*")) {
status = internal_resolve_name(domain, 0x1C, sitename,
&auto_ip_list,
@@ -1870,7 +1874,7 @@ static NTSTATUS get_dc_list(const char *domain,
/* fill in the return list now with real IP's */
while ((local_count<num_addresses) &&
- next_token(&p,name,LIST_SEP,sizeof(name))) {
+ next_token_talloc(ctx, &p, &name, LIST_SEP)) {
struct sockaddr_storage name_ss;
/* copy any addersses from the auto lookup */