mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-03 08:30:09 +00:00
Fix bug #12621 with crashes on MS-Windows in LookupAccountSid.
src/w32.c (get_name_and_id): Always pass NULL as the first argument of lookup_account_sid. Avoids crashes with UNC file names that refer to DFS domains, not to specific machine names. (Bug#12621) Remove now unused argument FNAME; all callers changed. (get_file_owner_and_group): Remove now unused argument FNAME; all callers changed.
This commit is contained in:
parent
1e20eeb758
commit
92340ec753
@ -1,3 +1,12 @@
|
||||
2012-12-14 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
* w32.c (get_name_and_id): Always pass NULL as the first argument
|
||||
of lookup_account_sid. Avoids crashes with UNC file names that
|
||||
refer to DFS domains, not to specific machine names. (Bug#12621)
|
||||
Remove now unused argument FNAME; all callers changed.
|
||||
(get_file_owner_and_group): Remove now unused argument FNAME; all
|
||||
callers changed.
|
||||
|
||||
2012-12-11 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
* search.c (search_buffer): Check the inverse translations of each
|
||||
|
39
src/w32.c
39
src/w32.c
@ -3362,8 +3362,7 @@ w32_add_to_cache (PSID sid, unsigned id, char *name)
|
||||
#define GID 2
|
||||
|
||||
static int
|
||||
get_name_and_id (PSECURITY_DESCRIPTOR psd, const char *fname,
|
||||
unsigned *id, char *nm, int what)
|
||||
get_name_and_id (PSECURITY_DESCRIPTOR psd, unsigned *id, char *nm, int what)
|
||||
{
|
||||
PSID sid = NULL;
|
||||
char machine[MAX_COMPUTERNAME_LENGTH+1];
|
||||
@ -3373,7 +3372,6 @@ get_name_and_id (PSECURITY_DESCRIPTOR psd, const char *fname,
|
||||
DWORD name_len = sizeof (name);
|
||||
char domain[1024];
|
||||
DWORD domain_len = sizeof (domain);
|
||||
char *mp = NULL;
|
||||
int use_dflt = 0;
|
||||
int result;
|
||||
|
||||
@ -3388,22 +3386,7 @@ get_name_and_id (PSECURITY_DESCRIPTOR psd, const char *fname,
|
||||
use_dflt = 1;
|
||||
else if (!w32_cached_id (sid, id, nm))
|
||||
{
|
||||
/* If FNAME is a UNC, we need to lookup account on the
|
||||
specified machine. */
|
||||
if (IS_DIRECTORY_SEP (fname[0]) && IS_DIRECTORY_SEP (fname[1])
|
||||
&& fname[2] != '\0')
|
||||
{
|
||||
const char *s;
|
||||
char *p;
|
||||
|
||||
for (s = fname + 2, p = machine;
|
||||
*s && !IS_DIRECTORY_SEP (*s); s++, p++)
|
||||
*p = *s;
|
||||
*p = '\0';
|
||||
mp = machine;
|
||||
}
|
||||
|
||||
if (!lookup_account_sid (mp, sid, name, &name_len,
|
||||
if (!lookup_account_sid (NULL, sid, name, &name_len,
|
||||
domain, &domain_len, &ignore)
|
||||
|| name_len > UNLEN+1)
|
||||
use_dflt = 1;
|
||||
@ -3418,9 +3401,7 @@ get_name_and_id (PSECURITY_DESCRIPTOR psd, const char *fname,
|
||||
}
|
||||
|
||||
static void
|
||||
get_file_owner_and_group (PSECURITY_DESCRIPTOR psd,
|
||||
const char *fname,
|
||||
struct stat *st)
|
||||
get_file_owner_and_group (PSECURITY_DESCRIPTOR psd, struct stat *st)
|
||||
{
|
||||
int dflt_usr = 0, dflt_grp = 0;
|
||||
|
||||
@ -3431,9 +3412,9 @@ get_file_owner_and_group (PSECURITY_DESCRIPTOR psd,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (get_name_and_id (psd, fname, &st->st_uid, st->st_uname, UID))
|
||||
if (get_name_and_id (psd, &st->st_uid, st->st_uname, UID))
|
||||
dflt_usr = 1;
|
||||
if (get_name_and_id (psd, fname, &st->st_gid, st->st_gname, GID))
|
||||
if (get_name_and_id (psd, &st->st_gid, st->st_gname, GID))
|
||||
dflt_grp = 1;
|
||||
}
|
||||
/* Consider files to belong to current user/group, if we cannot get
|
||||
@ -3655,19 +3636,19 @@ stat_worker (const char * path, struct stat * buf, int follow_symlinks)
|
||||
psd = get_file_security_desc_by_handle (fh);
|
||||
if (psd)
|
||||
{
|
||||
get_file_owner_and_group (psd, name, buf);
|
||||
get_file_owner_and_group (psd, buf);
|
||||
LocalFree (psd);
|
||||
}
|
||||
else if (is_windows_9x () == TRUE)
|
||||
get_file_owner_and_group (NULL, name, buf);
|
||||
get_file_owner_and_group (NULL, buf);
|
||||
else if (!(is_a_symlink && follow_symlinks))
|
||||
{
|
||||
psd = get_file_security_desc_by_name (name);
|
||||
get_file_owner_and_group (psd, name, buf);
|
||||
get_file_owner_and_group (psd, buf);
|
||||
xfree (psd);
|
||||
}
|
||||
else
|
||||
get_file_owner_and_group (NULL, name, buf);
|
||||
get_file_owner_and_group (NULL, buf);
|
||||
CloseHandle (fh);
|
||||
}
|
||||
else
|
||||
@ -3775,7 +3756,7 @@ stat_worker (const char * path, struct stat * buf, int follow_symlinks)
|
||||
else
|
||||
buf->st_mode = S_IFREG;
|
||||
|
||||
get_file_owner_and_group (NULL, name, buf);
|
||||
get_file_owner_and_group (NULL, buf);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
Loading…
Reference in New Issue
Block a user