1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-02 09:47:23 +03:00

r25170: Remove pstring limits from ms_fnmatch and module load.

Jeremy.
This commit is contained in:
Jeremy Allison 2007-09-14 22:03:41 +00:00 committed by Gerald (Jerry) Carter
parent 1a02226700
commit 764574ee05
3 changed files with 49 additions and 40 deletions

View File

@ -96,7 +96,9 @@ int smb_load_modules(const char **modules)
NTSTATUS smb_probe_module(const char *subsystem, const char *module)
{
pstring full_path;
char *full_path = NULL;
TALLOC_CTX *ctx = talloc_stackframe();
NTSTATUS status;
/* Check for absolute path */
@ -109,15 +111,23 @@ NTSTATUS smb_probe_module(const char *subsystem, const char *module)
if (module[0] == '/')
return do_smb_load_module(module, True);
pstrcpy(full_path, lib_path(subsystem));
pstrcat(full_path, "/");
pstrcat(full_path, module);
pstrcat(full_path, ".");
pstrcat(full_path, shlib_ext());
full_path = talloc_asprintf(ctx,
"%s/%s.%s",
lib_path(subsystem),
module,
shlib_ext());
if (!full_path) {
TALLOC_FREE(ctx);
return NT_STATUS_NO_MEMORY;
}
DEBUG(5, ("Probing module '%s': Trying to load from %s\n", module, full_path));
DEBUG(5, ("Probing module '%s': Trying to load from %s\n",
module, full_path));
return do_smb_load_module(full_path, True);
status = do_smb_load_module(full_path, True);
TALLOC_FREE(ctx);
return status;
}
#else /* HAVE_DLOPEN */

View File

@ -148,11 +148,12 @@ static int ms_fnmatch_core(const smb_ucs2_t *p, const smb_ucs2_t *n,
int ms_fnmatch(const char *pattern, const char *string, BOOL translate_pattern,
BOOL is_case_sensitive)
{
wpstring p, s;
smb_ucs2_t *p = NULL;
smb_ucs2_t *s = NULL;
int ret, count, i;
struct max_n *max_n = NULL;
if (strcmp(string, "..") == 0) {
if (ISDOTDOT(string)) {
string = ".";
}
@ -166,15 +167,12 @@ int ms_fnmatch(const char *pattern, const char *string, BOOL translate_pattern,
}
}
if (push_ucs2(NULL, p, pattern, sizeof(p), STR_TERMINATE) == (size_t)-1) {
/* Not quite the right answer, but finding the right one
under this failure case is expensive, and it's pretty close */
if (push_ucs2_allocate(&p, pattern) == (size_t)-1) {
return -1;
}
if (push_ucs2(NULL, s, string, sizeof(s), STR_TERMINATE) == (size_t)-1) {
/* Not quite the right answer, but finding the right one
under this failure case is expensive, and it's pretty close */
if (push_ucs2_allocate(&s, string) == (size_t)-1) {
SAFE_FREE(p);
return -1;
}
@ -205,16 +203,17 @@ int ms_fnmatch(const char *pattern, const char *string, BOOL translate_pattern,
if (count != 0) {
max_n = SMB_CALLOC_ARRAY(struct max_n, count);
if (!max_n) {
SAFE_FREE(p);
SAFE_FREE(s);
return -1;
}
}
ret = ms_fnmatch_core(p, s, max_n, strrchr_w(s, UCS2_CHAR('.')), is_case_sensitive);
if (max_n) {
free(max_n);
}
SAFE_FREE(max_n);
SAFE_FREE(p);
SAFE_FREE(s);
return ret;
}

View File

@ -220,7 +220,7 @@ logons are not enabled.\n", inet_ntoa(p->ip) ));
sizeof(pstring) - PTR_DIFF(q, outbuf),
True); /* PDC name */
q += dos_PutUniCode(q, lp_workgroup(),
sizeof(pstring) - (q-outbuf),
sizeof(pstring) - PTR_DIFF(q, outbuf),
True); /* Domain name*/
if (sizeof(pstring) - PTR_DIFF(q, outbuf) < 8) {
return;