From: Eli Zaretskii Date: Mon, 10 Mar 2014 17:26:45 +0000 (+0200) Subject: Fix an obscure bug in fstatat on Windows 9X. X-Git-Tag: emacs-24.3.90~229 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=70db0db7bf9fe648584f4e00a71c8c3b272a5d03;p=emacs.git Fix an obscure bug in fstatat on Windows 9X. src/w32.c (fstatat): Don't add an extra slash if the argument ends with a slash: this fails the subsequent call to stat_worker on Windows 9X. Reported by oslsachem . --- diff --git a/src/ChangeLog b/src/ChangeLog index c383aeaa0a0..62ad09eb4c2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2014-03-10 Eli Zaretskii + + * w32.c (fstatat): Don't add an extra slash if the argument ends + with a slash: this fails the subsequent call to stat_worker on + Windows 9X. Reported by oslsachem . + 2014-03-10 Martin Rudalics * w32term.c (w32_read_socket): In SIZE_RESTORED case diff --git a/src/w32.c b/src/w32.c index 11fb2a72f69..e84c63d674c 100644 --- a/src/w32.c +++ b/src/w32.c @@ -5138,7 +5138,10 @@ fstatat (int fd, char const *name, struct stat *st, int flags) if (fd != AT_FDCWD) { - if (_snprintf (fullname, sizeof fullname, "%s/%s", dir_pathname, name) + char lastc = dir_pathname[strlen (dir_pathname) - 1]; + + if (_snprintf (fullname, sizeof fullname, "%s%s%s", + dir_pathname, IS_DIRECTORY_SEP (lastc) ? "" : "/", name) < 0) { errno = ENAMETOOLONG;