Stop crashing when a NULL filename is passed to file_status(),
instead, return FN_ERROR.
Also return FN_ERROR when a zero-length filename is passed to file_status().
Fixed as part of bug 13111.
--- /dev/null
+ o Minor bugfixes
+ - Stop crashing when a NULL filename is passed to file_status().
+ Fixed as part of bug 13111.
+
+ o Minor enhancements:
+ - Return FN_ERROR when a zero-length filename is passed to file_status().
+ Fixed as part of bug 13111.
#endif
}
-/** Return FN_ERROR if filename can't be read, FN_NOENT if it doesn't
+/** Return FN_ERROR if filename can't be read, or is NULL or zero-length,
+ * FN_NOENT if it doesn't
* exist, FN_FILE if it is a regular file, or FN_DIR if it's a
* directory. On FN_ERROR, sets errno. */
file_status_t
struct stat st;
char *f;
int r;
+ if (!fname || strlen(fname) == 0) {
+ return FN_ERROR;
+ }
f = tor_strdup(fname);
clean_name_for_stat(f);
log_debug(LD_FS, "stat()ing %s", f);