]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
depmod: Fix out of boundary write with long paths
authorTobias Stoeckmann <tobias@stoeckmann.org>
Wed, 14 Aug 2024 15:40:40 +0000 (17:40 +0200)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Fri, 16 Aug 2024 04:33:49 +0000 (23:33 -0500)
If a root path is specified which is PATH_MAX - 1 characters long
and option -A is specified, then depfile_up_to_date_dir triggers
an out of boundary write during slash addition.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
tools/depmod.c

index bd9df207cd0adf2eb55e73a822330cc2fb36adbb..78ab20760dd3d5a2e37315848a1b1cd1b4df1c07 100644 (file)
@@ -2855,7 +2855,7 @@ static int depfile_up_to_date_dir(DIR *d, time_t mtime, size_t baselen, char *pa
 /* uptodate: 1, outdated: 0, errors < 0 */
 static int depfile_up_to_date(const char *dirname)
 {
-       char path[PATH_MAX];
+       char path[PATH_MAX + 1];
        DIR *d = opendir(dirname);
        struct stat st;
        size_t baselen;