[Opensrf-commits] r1021 - branches/STABLE_0_9/src/srfsh

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Jul 10 23:20:18 EDT 2007


Author: miker
Date: 2007-07-10 23:15:39 -0400 (Tue, 10 Jul 2007)
New Revision: 1021

Modified:
   branches/STABLE_0_9/src/srfsh/srfsh.c
Log:
Backporting possible buffer overflow fix from Scott McKellar.



Modified: branches/STABLE_0_9/src/srfsh/srfsh.c
===================================================================
--- branches/STABLE_0_9/src/srfsh/srfsh.c	2007-07-11 03:13:01 UTC (rev 1020)
+++ branches/STABLE_0_9/src/srfsh/srfsh.c	2007-07-11 03:15:39 UTC (rev 1021)
@@ -120,19 +120,15 @@
 	if( ! words )
 		return 0;
 
-
-	int i = 0;
-	char* current;
-	char buffer[256];
-	memset(buffer, 0, 256);
-	while( (current=words[i++]) ) {
-		strcat(buffer, current);
-		strcat(buffer, " ");
+	growing_buffer * gbuf = buffer_init( 64 );
+	buffer_add( gbuf, *words );
+	while( *++words ) {
+		buffer_add( gbuf, " " );
+		buffer_add( gbuf, *words );
 	}
-	if( ! buffer || strlen(buffer) < 1 ) 
-		printf("\n");
+	fprintf( stderr, "???: %s\n", gbuf->buf );
+	buffer_free( gbuf );
 
-	fprintf( stderr, "???: %s\n", buffer );
 	return 0;
 
 }



More information about the opensrf-commits mailing list