git: 1a38a53924e5 - stable/13 - makefs: avoid uninitialized memory in root directory date

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Fri, 14 Apr 2023 12:52:54 UTC
The branch stable/13 has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=1a38a53924e5b43a14bea8e87aac42176c336ff8

commit 1a38a53924e5b43a14bea8e87aac42176c336ff8
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2023-04-06 16:53:00 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-04-14 12:10:37 +0000

    makefs: avoid uninitialized memory in root directory date
    
    Move date setting into cd9660_populate_iso_dir_record so there is no
    path that leaves it unset.
    
    PR:             203531
    Reported by:    Thomas Schmitt <scdbackup@gmx.net>
    Reviewed by:    markj
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D39258
    
    (cherry picked from commit 7bc4ccf3aea935dde8ffc3e7c287884e22f87646)
---
 usr.sbin/makefs/cd9660.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/usr.sbin/makefs/cd9660.c b/usr.sbin/makefs/cd9660.c
index 4159e08c8210..cf2696e578a4 100644
--- a/usr.sbin/makefs/cd9660.c
+++ b/usr.sbin/makefs/cd9660.c
@@ -727,7 +727,10 @@ cd9660_populate_iso_dir_record(struct _iso_directory_record_cd9660 *record,
 			       u_char ext_attr_length, u_char flags,
 			       u_char name_len, const char * name)
 {
+	time_t tstamp = stampst.st_ino ? stampst.st_mtime : time(NULL);
+
 	record->ext_attr_length[0] = ext_attr_length;
+	cd9660_time_915(record->date, tstamp);
 	record->flags[0] = ISO_FLAG_CLEAR | flags;
 	record->file_unit_size[0] = 0;
 	record->interleave[0] = 0;
@@ -814,7 +817,6 @@ cd9660_fill_extended_attribute_record(cd9660node *node)
 static int
 cd9660_translate_node_common(iso9660_disk *diskStructure, cd9660node *newnode)
 {
-	time_t tstamp = stampst.st_ino ? stampst.st_mtime : time(NULL);
 	u_char flag;
 	char temp[ISO_FILENAME_MAXLENGTH_WITH_PADDING];
 
@@ -831,12 +833,6 @@ cd9660_translate_node_common(iso9660_disk *diskStructure, cd9660node *newnode)
 	cd9660_populate_iso_dir_record(newnode->isoDirRecord, 0,
 	    flag, strlen(temp), temp);
 
-	/* Set the various dates */
-
-	/* If we want to use the current date and time */
-
-	cd9660_time_915(newnode->isoDirRecord->date, tstamp);
-
 	cd9660_bothendian_dword(newnode->fileDataLength,
 	    newnode->isoDirRecord->size);
 	/* If the file is a link, we want to set the size to 0 */