[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#138822: Bad filename output



Package: playmidi
Version: 2.4-3

If a file with a long (> COLS - 53) name is next to a file with long
karaoke text in a playlist, when running playmidi -r, the last line of
karaoke text appears as the line under the filename.

diff -ur playmidi-2.4.orig/io_ncurses.c playmidi-2.4/io_ncurses.c
--- playmidi-2.4.orig/io_ncurses.c	Sat Mar 16 23:11:55 2002
+++ playmidi-2.4/io_ncurses.c		Sun Mar 17 18:59:14 2002
@@ -311,6 +311,8 @@
 	    mvprintw(i + 2, 0, "Channel %2d  ³", i + 1);
 	tmp = strrchr(filename, '/');
 	strncpy(textbuf, (tmp == NULL ? filename : tmp + 1), COLS - 53);
+	if (strlen(textbuf) > COLS - 53)
+	    textbuf[COLS - 53] = '\0';
 	attrset(A_BOLD);
 	mvaddstr(0, 53, textbuf);
 	mvaddch(1, 41, 'P');

textbuf is used for the output of karaoke text in addition to the
filename, but is not cleared after use. Originally, when the file has a
long name, '\0' is not appended to the end of the copied segment by
strncpy, so it is the null at the end of the old karaoke text that forms
the end of the "filename". The changes check the length of the
"filename", and if it's too long, it appends a null to where the end is
meant to be.

Kernel: 2.4.19-pre3
glibc:  2.2.5-3

libncurses5 version:	5.2.20020112a-3
libxaw7 version:		4.1.0-13
svgalibg1 version:		1.4.3-4
xlibs version:		4.1.0-13
debconf version:		1.0.25

Seneca
seneca@slemish.com




Reply to: