summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <pwithnall@endlessos.org>2021-04-19 19:23:10 +0100
committerPhilip Withnall <pwithnall@endlessos.org>2021-04-19 19:23:10 +0100
commit496135c569788334b4256c72e781cad7dbc9404a (patch)
tree514d830ea4d7444c6920a99dcdfb7ac92d0d6f70
parent3c027268a4fe0dab76b2b661263a67eb676cabbd (diff)
downloadglib-496135c569788334b4256c72e781cad7dbc9404a.tar.gz
dirent: Add trailing nul delimiter to FILENAME_MAX
`FILENAME_MAX` is not guaranteed to include a trailing nul delimiter, so explicitly add one. See https://www.gnu.org/software/libc/manual/html_node/Limits-for-Files.html: `PATH_MAX` is explicitly defined to include a nul delimiter; `FILENAME_MAX` is not. See also https://twitter.com/pid_eins/status/1357008940886818822. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
-rw-r--r--glib/dirent/dirent.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/glib/dirent/dirent.h b/glib/dirent/dirent.h
index 237665b4e..857710f6a 100644
--- a/glib/dirent/dirent.h
+++ b/glib/dirent/dirent.h
@@ -22,7 +22,7 @@ struct dirent
long d_ino; /* Always zero. */
unsigned short d_reclen; /* Always zero. */
unsigned short d_namlen; /* Length of name in d_name. */
- char d_name[FILENAME_MAX]; /* File name. */
+ char d_name[FILENAME_MAX+1]; /* File name plus nul delimiter. */
};
#ifdef _WIN64
@@ -76,7 +76,7 @@ struct _wdirent
long d_ino; /* Always zero. */
unsigned short d_reclen; /* Always zero. */
unsigned short d_namlen; /* Length of name in d_name. */
- wchar_t d_name[FILENAME_MAX]; /* File name. */
+ wchar_t d_name[FILENAME_MAX+1]; /* File name plus nul delimiter. */
};
/*