mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
net: change split_hive_key() to properly allocate subkeyname
instead of returning a pointer into another string.
Michael
(This used to be commit 68d08ecf92
)
This commit is contained in:
parent
65088387c0
commit
ae790f9b89
@ -41,7 +41,7 @@ static WERROR open_hive(TALLOC_CTX *ctx, const char *path,
|
||||
WERROR werr;
|
||||
NT_USER_TOKEN *token = NULL;
|
||||
char *hivename = NULL;
|
||||
const char *tmp_subkeyname = NULL;
|
||||
char *tmp_subkeyname = NULL;
|
||||
TALLOC_CTX *tmp_ctx = talloc_stackframe();
|
||||
|
||||
if ((hive == NULL) || (subkeyname == NULL)) {
|
||||
|
@ -72,9 +72,10 @@ void print_registry_value(const char *valname,
|
||||
* - strip trailing '\\' chars
|
||||
*/
|
||||
WERROR split_hive_key(TALLOC_CTX *ctx, const char *path, char **hivename,
|
||||
const char **subkeyname)
|
||||
char **subkeyname)
|
||||
{
|
||||
char *p;
|
||||
const char *tmp_subkeyname;
|
||||
|
||||
if ((path == NULL) || (hivename == NULL) || (subkeyname == NULL)) {
|
||||
return WERR_INVALID_PARAM;
|
||||
@ -100,10 +101,14 @@ WERROR split_hive_key(TALLOC_CTX *ctx, const char *path, char **hivename,
|
||||
|
||||
if ((p == NULL) || (*p == '\0')) {
|
||||
/* just the hive - no subkey given */
|
||||
*subkeyname = "";
|
||||
tmp_subkeyname = "";
|
||||
} else {
|
||||
*p = '\0';
|
||||
*subkeyname = p+1;
|
||||
tmp_subkeyname = p+1;
|
||||
}
|
||||
*subkeyname = talloc_strdup(ctx, tmp_subkeyname);
|
||||
if (*subkeyname == NULL) {
|
||||
return WERR_NOMEM;
|
||||
}
|
||||
|
||||
return WERR_OK;
|
||||
|
@ -34,6 +34,6 @@ void print_registry_value(const char *valname,
|
||||
* - strip trailing '\\' chars
|
||||
*/
|
||||
WERROR split_hive_key(TALLOC_CTX *ctx, const char *path, char **hivename,
|
||||
const char **subkeyname);
|
||||
char **subkeyname);
|
||||
|
||||
#endif
|
||||
|
@ -28,7 +28,7 @@ static bool reg_hive_key(TALLOC_CTX *ctx, const char *fullname,
|
||||
{
|
||||
WERROR werr;
|
||||
char *hivename = NULL;
|
||||
const char *tmp_keyname = NULL;
|
||||
char *tmp_keyname = NULL;
|
||||
bool ret = false;
|
||||
TALLOC_CTX *tmp_ctx = talloc_stackframe();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user