[patch] netmd.c messes the tty

Sam Hocevar <[email protected]>
Newsgroups gmane.comp.audio.netmd.devel
Message-ID <[email protected]>
   netmd.c does not check for the get_devname return value and spits
random characters to stdout. Trivial patch attached.

Sam.
-- 
Samuel Hocevar <[email protected]> <http://sam.zoy.org/>
libnetmd-get_devname-patch.diff (text/plain, 967 B)
Index: libnetmd.c
===================================================================
RCS file: /var/cvs/libnetmd/libnetmd.c,v
retrieving revision 1.39
diff -u -r1.39 libnetmd.c
--- libnetmd.c	23 Dec 2002 14:18:49 -0000	1.39
+++ libnetmd.c	25 Dec 2002 20:50:52 -0000
@@ -202,6 +202,7 @@
 					   (USB_DT_STRING << 8) | 0x02, 0, b, 256, 5000) < 0)
 	{
 		fprintf(stdout, "cannot get config descriptor %d, %s (%d)\n", buf[15], strerror(errno), errno);
+		buf[0] = 0;
 		return 0;
 	}
 
Index: netmd.c
===================================================================
RCS file: /var/cvs/libnetmd/netmd.c,v
retrieving revision 1.30
diff -u -r1.30 netmd.c
--- netmd.c	20 Sep 2002 22:28:23 -0000	1.30
+++ netmd.c	25 Dec 2002 20:50:52 -0000
@@ -34,7 +34,12 @@
 		return -1;
 	}
 
-	get_devname(devh, name, 16);
+	if(!get_devname(devh, name, 16))
+	{
+		printf("Could not get device name\n");
+		return -1;
+	}
+
 	printf("%s\n", name);
 
 	initialize_disc_info(devh, md);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.