[dahdi-commits] seanbright: tools/trunk r5656 - /tools/trunk/dahdi_monitor.c

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Tue Jan 13 17:46:01 CST 2009


Author: seanbright
Date: Tue Jan 13 17:46:00 2009
New Revision: 5656

URL: http://svn.digium.com/svn-view/dahdi?view=rev&rev=5656
Log:
The problem with using dahdi_copy_string here is that it is guaranteed to NULL
terminate the destination string, which in this case was not correct.  So revert
back to using strncpy and also decrease the buffer by 1 since it was reserving
an extra byte behind NULL for some reason.  Fix suggested by reporter.

(closes issue #14103)
Reported by: gork

Modified:
    tools/trunk/dahdi_monitor.c

Modified: tools/trunk/dahdi_monitor.c
URL: http://svn.digium.com/svn-view/dahdi/tools/trunk/dahdi_monitor.c?view=diff&rev=5656&r1=5655&r2=5656
==============================================================================
--- tools/trunk/dahdi_monitor.c (original)
+++ tools/trunk/dahdi_monitor.c Tue Jan 13 17:46:00 2009
@@ -155,17 +155,17 @@
 
 void draw_barheader()
 {
-	char bar[barlen+5];
+	char bar[barlen + 4];
 
 	memset(bar, '-', sizeof(bar));
 	memset(bar, '<', 1);
-	memset(bar+barlen+2, '>', 1);
-	memset(bar+barlen+3, '\0', 1);
-
-	dahdi_copy_string(bar+(barlen/2), "(RX)", 4);
+	memset(bar + barlen + 2, '>', 1);
+	memset(bar + barlen + 3, '\0', 1);
+
+	strncpy(bar + (barlen / 2), "(RX)", 4);
 	printf("%s", bar);
 
-	dahdi_copy_string(bar+(barlen/2), "(TX)", 4);
+	strncpy(bar + (barlen / 2), "(TX)", 4);
 	printf(" %s\n", bar);
 }
 




More information about the dahdi-commits mailing list