diff options
author | Jeremy Allison <jra@samba.org> | 2007-12-07 17:32:32 -0800 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2007-12-07 17:32:32 -0800 |
commit | 42cfffae80480eae4381902fff3f7c61f858a933 (patch) | |
tree | 2fc1bc486fa988a4f2854310bcf91943db1aa566 /source3/utils | |
parent | 25288b0e4472c728fc5a3a70c6c3e1f621ffae5f (diff) | |
download | samba-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/utils')
-rw-r--r-- | source3/utils/net_rpc.c | 14 | ||||
-rw-r--r-- | source3/utils/net_rpc_printer.c | 12 | ||||
-rw-r--r-- | source3/utils/sharesec.c | 20 | ||||
-rw-r--r-- | source3/utils/smbcacls.c | 31 |
4 files changed, 51 insertions, 26 deletions
diff --git a/source3/utils/net_rpc.c b/source3/utils/net_rpc.c index b41142a087..3f78d6ced8 100644 --- a/source3/utils/net_rpc.c +++ b/source3/utils/net_rpc.c @@ -4359,9 +4359,10 @@ static bool get_user_tokens(int *num_tokens, struct user_token **user_tokens) struct winbindd_request request; struct winbindd_response response; const char *extra_data; - fstring name; + char *name; int i; struct user_token *result; + TALLOC_CTX *frame = NULL; if (lp_winbind_use_default_domain() && (opt_target_workgroup == NULL)) { @@ -4374,7 +4375,7 @@ static bool get_user_tokens(int *num_tokens, struct user_token **user_tokens) ZERO_STRUCT(request); ZERO_STRUCT(response); - + if (winbindd_request_response(WINBINDD_LIST_USERS, &request, &response) != NSS_STATUS_SUCCESS) return False; @@ -4387,7 +4388,8 @@ static bool get_user_tokens(int *num_tokens, struct user_token **user_tokens) extra_data = (const char *)response.extra_data.data; *num_tokens = 0; - while(next_token(&extra_data, name, ",", sizeof(fstring))) { + frame = talloc_stackframe(); + while(next_token_talloc(frame, &extra_data, &name, ",")) { *num_tokens += 1; } @@ -4395,14 +4397,14 @@ static bool get_user_tokens(int *num_tokens, struct user_token **user_tokens) if (result == NULL) { DEBUG(1, ("Could not malloc sid array\n")); + TALLOC_FREE(frame); return False; } extra_data = (const char *)response.extra_data.data; i=0; - while(next_token(&extra_data, name, ",", sizeof(fstring))) { - + while(next_token_talloc(frame, &extra_data, &name, ",")) { fstring domain, user; char *p; @@ -4425,7 +4427,7 @@ static bool get_user_tokens(int *num_tokens, struct user_token **user_tokens) get_user_sids(domain, user, &(result[i].token)); i+=1; } - + TALLOC_FREE(frame); SAFE_FREE(response.extra_data.data); *user_tokens = result; diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c index d40b953707..bcfb37713c 100644 --- a/source3/utils/net_rpc_printer.c +++ b/source3/utils/net_rpc_printer.c @@ -514,17 +514,17 @@ static NTSTATUS net_copy_driverfile(TALLOC_CTX *mem_ctx, const char *p; char *src_name; char *dst_name; - fstring version; - fstring filename; - fstring tok; + char *version; + char *filename; + char *tok; /* scroll through the file until we have the part beyond archi_table.short_archi */ p = file; - while (next_token(&p, tok, "\\", sizeof(tok))) { + while (next_token_talloc(mem_ctx, &p, &tok, "\\")) { if (strequal(tok, short_archi)) { - next_token(&p, version, "\\", sizeof(version)); - next_token(&p, filename, "\\", sizeof(filename)); + next_token_talloc(mem_ctx, &p, &version, "\\"); + next_token_talloc(mem_ctx, &p, &filename, "\\"); } } diff --git a/source3/utils/sharesec.c b/source3/utils/sharesec.c index e03222b005..cd2c78f8f3 100644 --- a/source3/utils/sharesec.c +++ b/source3/utils/sharesec.c @@ -148,7 +148,7 @@ static bool parse_ace(SEC_ACE *ace, const char *orig_str) { char *p; const char *cp; - fstring tok; + char *tok; unsigned int atype = 0; unsigned int aflags = 0; unsigned int amask = 0; @@ -156,8 +156,10 @@ static bool parse_ace(SEC_ACE *ace, const char *orig_str) SEC_ACCESS mask; const struct perm_value *v; char *str = SMB_STRDUP(orig_str); + TALLOC_CTX *frame = talloc_stackframe(); if (!str) { + TALLOC_FREE(frame); return False; } @@ -166,6 +168,7 @@ static bool parse_ace(SEC_ACE *ace, const char *orig_str) if (!p) { printf("ACE '%s': missing ':'.\n", orig_str); SAFE_FREE(str); + TALLOC_FREE(frame); return False; } *p = '\0'; @@ -183,14 +186,16 @@ static bool parse_ace(SEC_ACE *ace, const char *orig_str) printf("ACE '%s': failed to convert '%s' to SID\n", orig_str, str); SAFE_FREE(str); + TALLOC_FREE(frame); return False; } cp = p; - if (!next_token(&cp, tok, "/", sizeof(fstring))) { + if (!next_token_talloc(frame, &cp, &tok, "/")) { printf("ACE '%s': failed to find '/' character.\n", orig_str); SAFE_FREE(str); + TALLOC_FREE(frame); return False; } @@ -202,24 +207,27 @@ static bool parse_ace(SEC_ACE *ace, const char *orig_str) printf("ACE '%s': missing 'ALLOWED' or 'DENIED' entry at '%s'\n", orig_str, tok); SAFE_FREE(str); + TALLOC_FREE(frame); return False; } /* Only numeric form accepted for flags at present */ /* no flags on share permissions */ - if (!(next_token(&cp, tok, "/", sizeof(fstring)) && + if (!(next_token_talloc(frame, &cp, &tok, "/") && sscanf(tok, "%i", &aflags) && aflags == 0)) { printf("ACE '%s': bad integer flags entry at '%s'\n", orig_str, tok); SAFE_FREE(str); + TALLOC_FREE(frame); return False; } - if (!next_token(&cp, tok, "/", sizeof(fstring))) { + if (!next_token_talloc(frame, &cp, &tok, "/")) { printf("ACE '%s': missing / at '%s'\n", orig_str, tok); SAFE_FREE(str); + TALLOC_FREE(frame); return False; } @@ -227,6 +235,7 @@ static bool parse_ace(SEC_ACE *ace, const char *orig_str) if (sscanf(tok, "%i", &amask) != 1) { printf("ACE '%s': bad hex number at '%s'\n", orig_str, tok); + TALLOC_FREE(frame); SAFE_FREE(str); return False; } @@ -255,6 +264,7 @@ static bool parse_ace(SEC_ACE *ace, const char *orig_str) if (!found) { printf("ACE '%s': bad permission value at '%s'\n", orig_str, p); + TALLOC_FREE(frame); SAFE_FREE(str); return False; } @@ -262,6 +272,7 @@ static bool parse_ace(SEC_ACE *ace, const char *orig_str) } if (*p) { + TALLOC_FREE(frame); SAFE_FREE(str); return False; } @@ -270,6 +281,7 @@ static bool parse_ace(SEC_ACE *ace, const char *orig_str) mask = amask; init_sec_ace(ace, &sid, atype, mask, aflags); SAFE_FREE(str); + TALLOC_FREE(frame); return True; } diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c index 1057d35db3..e5ba8e5d0b 100644 --- a/source3/utils/smbcacls.c +++ b/source3/utils/smbcacls.c @@ -272,7 +272,7 @@ static bool parse_ace(struct cli_state *cli, SEC_ACE *ace, { char *p; const char *cp; - fstring tok; + char *tok; unsigned int atype = 0; unsigned int aflags = 0; unsigned int amask = 0; @@ -280,8 +280,10 @@ static bool parse_ace(struct cli_state *cli, SEC_ACE *ace, SEC_ACCESS mask; const struct perm_value *v; char *str = SMB_STRDUP(orig_str); + TALLOC_CTX *frame = talloc_stackframe(); if (!str) { + TALLOC_FREE(frame); return False; } @@ -290,6 +292,7 @@ static bool parse_ace(struct cli_state *cli, SEC_ACE *ace, if (!p) { printf("ACE '%s': missing ':'.\n", orig_str); SAFE_FREE(str); + TALLOC_FREE(frame); return False; } *p = '\0'; @@ -307,14 +310,16 @@ static bool parse_ace(struct cli_state *cli, SEC_ACE *ace, printf("ACE '%s': failed to convert '%s' to SID\n", orig_str, str); SAFE_FREE(str); + TALLOC_FREE(frame); return False; } cp = p; - if (!next_token(&cp, tok, "/", sizeof(fstring))) { + if (!next_token_talloc(frame, &cp, &tok, "/")) { printf("ACE '%s': failed to find '/' character.\n", orig_str); SAFE_FREE(str); + TALLOC_FREE(frame); return False; } @@ -326,23 +331,26 @@ static bool parse_ace(struct cli_state *cli, SEC_ACE *ace, printf("ACE '%s': missing 'ALLOWED' or 'DENIED' entry at '%s'\n", orig_str, tok); SAFE_FREE(str); + 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))) { printf("ACE '%s': bad integer flags entry at '%s'\n", orig_str, tok); SAFE_FREE(str); + TALLOC_FREE(frame); return False; } - if (!next_token(&cp, tok, "/", sizeof(fstring))) { + if (!next_token_talloc(frame, &cp, &tok, "/")) { printf("ACE '%s': missing / at '%s'\n", orig_str, tok); SAFE_FREE(str); + TALLOC_FREE(frame); return False; } @@ -351,6 +359,7 @@ static bool parse_ace(struct cli_state *cli, SEC_ACE *ace, printf("ACE '%s': bad hex number at '%s'\n", orig_str, tok); SAFE_FREE(str); + TALLOC_FREE(frame); return False; } goto done; @@ -379,12 +388,14 @@ static bool parse_ace(struct cli_state *cli, SEC_ACE *ace, printf("ACE '%s': bad permission value at '%s'\n", orig_str, p); SAFE_FREE(str); + TALLOC_FREE(frame); return False; } p++; } if (*p) { + TALLOC_FREE(frame); SAFE_FREE(str); return False; } @@ -392,6 +403,7 @@ static bool parse_ace(struct cli_state *cli, SEC_ACE *ace, done: mask = amask; init_sec_ace(ace, &sid, atype, mask, aflags); + TALLOC_FREE(frame); SAFE_FREE(str); return True; } @@ -418,18 +430,17 @@ static bool add_ace(SEC_ACL **the_acl, SEC_ACE *ace) } /* parse a ascii version of a security descriptor */ -static SEC_DESC *sec_desc_parse(struct cli_state *cli, char *str) +static SEC_DESC *sec_desc_parse(TALLOC_CTX *ctx, struct cli_state *cli, char *str) { const char *p = str; - fstring tok; + char *tok; SEC_DESC *ret = NULL; size_t sd_size; DOM_SID *grp_sid=NULL, *owner_sid=NULL; 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 (strncmp(tok,"REVISION:", 9) == 0) { revision = strtol(tok+9, NULL, 16); continue; @@ -479,7 +490,7 @@ static SEC_DESC *sec_desc_parse(struct cli_state *cli, char *str) goto done; } - ret = make_sec_desc(talloc_tos(),revision, SEC_DESC_SELF_RELATIVE, owner_sid, grp_sid, + ret = make_sec_desc(ctx,revision, SEC_DESC_SELF_RELATIVE, owner_sid, grp_sid, NULL, dacl, &sd_size); done: @@ -677,7 +688,7 @@ static int cacl_set(struct cli_state *cli, char *filename, size_t sd_size; int result = EXIT_OK; - sd = sec_desc_parse(cli, the_acl); + sd = sec_desc_parse(talloc_tos(), cli, the_acl); if (!sd) return EXIT_PARSE_ERROR; if (test_args) return EXIT_OK; |