+2015-07-17 Benno Schulenberg <bensberg@justemail.net>
+ * src/files.c (open_buffer): Verify that a named and existing file
+ is a normal file, to avoid opening an empty buffer when the name of
+ a directory is specified. This fixes Savannah bug #45383 reported
+ by Mike Frysinger, and also Savannah bug #27839 (which is an echo
+ from Debian bug #551717 reported by Paul Wise).
+
2015-07-17 Mike Frysinger <vapier@gentoo.org>
* src/browser.c (browser_refresh): Use the proper type (off_t) for
the size of a file, and avoid warnings about too large bit shifts.
}
#endif
+ /* When the specified filename is not empty, and the thing exists,
+ * verify that it is a normal file. */
+ if (strcmp(filename, "") != 0) {
+ struct stat fileinfo;
+
+ if (stat(filename, &fileinfo) == 0 && !S_ISREG(fileinfo.st_mode)) {
+ if (S_ISDIR(fileinfo.st_mode))
+ statusbar(_("\"%s\" is a directory"), filename);
+ else
+ statusbar(_("\"%s\" is not a normal file"), filename);
+ beep();
+ return;
+ }
+ }
+
/* If we're going to load into a new buffer, first create the new
* buffer and lock the corresponding file. */
if (new_buffer) {