diff options
author | Eli Zaretskii <eliz@gnu.org> | 2012-12-14 11:09:36 +0200 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2012-12-14 11:09:36 +0200 |
commit | 92340ec75375cc92b5024296817f5bb7f989135f (patch) | |
tree | 7055e019cfae1bf03bd2633388d9f6e27cf7d045 | |
parent | 1e20eeb758c5c78055962c6de6ee6ac2b49b8a02 (diff) | |
download | emacs-92340ec75375cc92b5024296817f5bb7f989135f.tar.gz |
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.
-rw-r--r-- | src/ChangeLog | 9 | ||||
-rw-r--r-- | src/w32.c | 39 |
2 files changed, 19 insertions, 29 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 5239559f867..fe30528da91 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -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 diff --git a/src/w32.c b/src/w32.c index fc97b0b490b..edb9b1b6189 100644 --- a/src/w32.c +++ b/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 |