mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-20 15:48:54 +02:00
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>
This commit is contained in:
@@ -22,7 +22,7 @@ struct dirent
|
|||||||
long d_ino; /* Always zero. */
|
long d_ino; /* Always zero. */
|
||||||
unsigned short d_reclen; /* Always zero. */
|
unsigned short d_reclen; /* Always zero. */
|
||||||
unsigned short d_namlen; /* Length of name in d_name. */
|
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
|
#ifdef _WIN64
|
||||||
@@ -76,7 +76,7 @@ struct _wdirent
|
|||||||
long d_ino; /* Always zero. */
|
long d_ino; /* Always zero. */
|
||||||
unsigned short d_reclen; /* Always zero. */
|
unsigned short d_reclen; /* Always zero. */
|
||||||
unsigned short d_namlen; /* Length of name in d_name. */
|
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. */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user