From matt@gsicomp.on.ca  Tue Oct  1 21:51:32 2002
Return-Path: <matt@gsicomp.on.ca>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 177C937B401
	for <FreeBSD-gnats-submit@freebsd.org>; Tue,  1 Oct 2002 21:51:32 -0700 (PDT)
Received: from tomts15-srv.bellnexxia.net (tomts15.bellnexxia.net [209.226.175.3])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 519FE43E6A
	for <FreeBSD-gnats-submit@freebsd.org>; Tue,  1 Oct 2002 21:51:30 -0700 (PDT)
	(envelope-from matt@gsicomp.on.ca)
Received: from xena.gsicomp.on.ca ([65.95.176.54])
          by tomts15-srv.bellnexxia.net
          (InterMail vM.5.01.04.19 201-253-122-122-119-20020516) with ESMTP
          id <20021002045128.TSAF12486.tomts15-srv.bellnexxia.net@xena.gsicomp.on.ca>
          for <FreeBSD-gnats-submit@freebsd.org>;
          Wed, 2 Oct 2002 00:51:28 -0400
Received: from gabby.gsicomp.on.ca (root@gabby.gsicomp.on.ca [192.168.0.2])
	by xena.gsicomp.on.ca (8.11.3/8.11.3) with ESMTP id g923VTp09084
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 1 Oct 2002 23:31:29 -0400 (EDT)
	(envelope-from matt@gabby.gsicomp.on.ca)
Received: (from matt@localhost)
	by gabby.gsicomp.on.ca (8.11.6/8.9.3) id g924Uvw24902;
	Wed, 2 Oct 2002 00:30:57 -0400 (EDT)
	(envelope-from matt)
Message-Id: <200210020430.g924Uvw24902@gabby.gsicomp.on.ca>
Date: Wed, 2 Oct 2002 00:30:57 -0400 (EDT)
From: Matthew Emmerton <matt@gsicomp.on.ca>
Reply-To: Matthew Emmerton <matt@gsicomp.on.ca>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: burncd prints incorrect output when using -l option
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         43574
>Category:       bin
>Synopsis:       burncd prints incorrect output when using -l option
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    sos
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Oct 01 22:00:07 PDT 2002
>Closed-Date:    Sun May 04 03:03:39 PDT 2003
>Last-Modified:  Sun May 04 03:03:39 PDT 2003
>Originator:     Matthew Emmerton
>Release:        FreeBSD 4.4-RELEASE i386
>Organization:
GSI Computer Services
>Environment:
System: FreeBSD gabby.gsicomp.on.ca 4.4-RELEASE FreeBSD 4.4-RELEASE #0: Wed Aug 28 21:49:13 EDT 2002 root@gabby.gsicomp.on.ca:/archive/obj/usr/src/sys/GABBY.20020821.01 i386

Also occurs on -CURRENT from about two weeks ago.

>Description:

	When using burncd with the -l (list) option, as each file is burned,
	the name of each file is not displayed.  Instead, the name of the last
	file in the list is always displayed.

	As written, a pointer to the filename is saved in the per-track
	structure for each track.  While this works fine when all files
	are given on the command line (since each filename is a different
	element of argv[]), this fails when a listing file is used.

	This is because when the listing file is parsed, the lines are
	read into a buffer, and it's the address of this buffer that is
	saved in the per-track structure.  Since each track will then
	have a file_name pointer pointing to the single static buffer, the
	filename that will be displayed for each track is the last file
	in the list (the last contents of the buffer).

>How-To-Repeat:

	$ cat filelist
	pcm/song1.pcm
	pcm/song2.pcm
	pcm/song3.pcm
	$ burncd -s 24 /dev/acd0c -l audio filelist fixate

>Fix:

--- usr.sbin/burncd/burncd.c.orig	Mon Sep 30 22:51:26 2002
+++ usr.sbin/burncd/burncd.c	Mon Sep 30 22:55:13 2002
@@ -48,7 +48,7 @@
 
 struct track_info {
 	int	file;
-	char	*file_name;
+	char	file_name[MAXPATHLEN + 1];
 	off_t	file_size;
 	int	block_size;
 	int	block_type;
@@ -331,7 +331,7 @@
 	if (fstat(file, &sb) < 0)
 		err(EX_IOERR, "fstat(%s)", name);
 	tracks[notracks].file = file;
-	tracks[notracks].file_name = name;
+	strncpy(tracks[notracks].file_name, name, MAXPATHLEN);
 	if (file == STDIN_FILENO)
 		tracks[notracks].file_size = -1;
 	else
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->sos 
Responsible-Changed-By: njl 
Responsible-Changed-When: Sat Nov 23 16:13:01 PST 2002 
Responsible-Changed-Why:  
sos@ is maintainer of burncd.  The patch looks good but should probably 
use strlcpy() to be sure string is null terminated 

http://www.freebsd.org/cgi/query-pr.cgi?pr=43574 
State-Changed-From-To: open->closed 
State-Changed-By: sos 
State-Changed-When: Sun May 4 03:03:21 PDT 2003 
State-Changed-Why:  
Fixed in -current (5.1). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=43574 
>Unformatted:
