Module Name:    src
Committed By:   mrg
Date:           Mon Aug 14 05:41:09 UTC 2023

Modified Files:
        src/sys/fs/msdosfs: msdosfs_vnops.c

Log Message:
when calling a function that needs more bytes than we have, create a
stack variable long enough and use that instead.

found by GCC 12.


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/sys/fs/msdosfs/msdosfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/msdosfs/msdosfs_vnops.c
diff -u src/sys/fs/msdosfs/msdosfs_vnops.c:1.110 src/sys/fs/msdosfs/msdosfs_vnops.c:1.111
--- src/sys/fs/msdosfs/msdosfs_vnops.c:1.110	Sat Oct 23 16:58:17 2021
+++ src/sys/fs/msdosfs/msdosfs_vnops.c	Mon Aug 14 05:41:09 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vnops.c,v 1.110 2021/10/23 16:58:17 thorpej Exp $	*/
+/*	$NetBSD: msdosfs_vnops.c,v 1.111 2023/08/14 05:41:09 mrg Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.110 2021/10/23 16:58:17 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.111 2023/08/14 05:41:09 mrg Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1163,12 +1163,17 @@ msdosfs_readdir(void *v)
 				    offset / sizeof(struct direntry);
 				dirbuf->d_type = DT_REG;
 			}
-			if (chksum != msdosfs_winChksum(dentp->deName))
+			if (chksum != msdosfs_winChksum(dentp->deName)) {
+				char deName[11];
+
+				memcpy(deName, dentp->deName,
+				       sizeof dentp->deName);
+				memset(&deName[8], 0, 3);
 				dirbuf->d_namlen =
-				    msdosfs_dos2unixfn(dentp->deName,
-				    (u_char *)dirbuf->d_name,
-				    pmp->pm_flags & MSDOSFSMNT_SHORTNAME);
-			else
+				    msdosfs_dos2unixfn(deName,
+				        (u_char *)dirbuf->d_name,
+				        pmp->pm_flags & MSDOSFSMNT_SHORTNAME);
+			} else
 				dirbuf->d_name[dirbuf->d_namlen] = 0;
 			namlen = dirbuf->d_namlen;
 			chksum = -1;

Reply via email to