[PC-BSD Commits] r1748 - pcbsd/trunk/SoundDetect

svn at pcbsd.org svn at pcbsd.org
Mon Apr 21 17:25:01 PDT 2008


Author: carlos
Date: 2008-04-21 17:25:00 -0700 (Mon, 21 Apr 2008)
New Revision: 1748

Modified:
   pcbsd/trunk/SoundDetect/parse_sound.c
   pcbsd/trunk/SoundDetect/sound_detect.c
Log:
 found major buffer overrun testing fbsd7.0 , fixed 

Modified: pcbsd/trunk/SoundDetect/parse_sound.c
===================================================================
--- pcbsd/trunk/SoundDetect/parse_sound.c	2008-04-21 20:07:58 UTC (rev 1747)
+++ pcbsd/trunk/SoundDetect/parse_sound.c	2008-04-22 00:25:00 UTC (rev 1748)
@@ -9,6 +9,7 @@
 
 #include <libxml/xmlmemory.h>
 #include <libxml/parser.h>
+#include <string.h>
 
 const char* GetKo(xmlDocPtr doc, xmlNodePtr cur, char* chip_id); 
 const char*  parse_Sound_CardXML(char *docname, char* Vendor_Name, char* chip_id ) ;
@@ -18,25 +19,26 @@
 /* cnb 2008-01-01
     we get the kernel module to load according to search keys(vendor,chipid)
  */
+
 const char* GetKo(xmlDocPtr doc, xmlNodePtr cur, char* chip_id) {
 
 	xmlChar *key;
-	char tempkey[10];
-	cur = cur->xmlChildrenNode;
+	static char tempkey[16];
+	cur = cur->xmlChildrenNode ;
+	while (cur!= NULL) {
 
-	while (cur != NULL) {
+		    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+		    snprintf(tempkey,sizeof tempkey ,"%s",(char*)key);
 
-		    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
-		    sprintf(tempkey,"%s",key);
-		if(!memcmp(tempkey,chip_id,10)) 
-		{
+		    if(!memcmp(tempkey,chip_id,strlen(tempkey))) { 
 		        xmlFree(key);
 			return cur->name;
-		}
-		cur = cur->next;
+		    }
+		    cur = cur->next;
 	}
-		    xmlFree(key);
-    return "snd_driver";
+	xmlFree(key);
+	return "snd_driver";
+
 }
 
 /* cnb 2008-01-01
@@ -71,12 +73,11 @@
 		xmlFreeDoc(doc);
 		return kernelmodule;
 	}
-	
 	cur = cur->xmlChildrenNode;
-	while (cur != NULL) 
-	{
+	while (cur!= NULL) 
+	{            
 		if ((!xmlStrcmp(cur->name, (const xmlChar *)Vendor_Name))){
-			sprintf(kernelmodule,"%s",GetKo (doc, cur,chip_id));
+		    snprintf(kernelmodule,sizeof kernelmodule,"%s",GetKo(doc, cur,chip_id));
 			xmlFreeDoc(doc);
 			return kernelmodule;
 		}

Modified: pcbsd/trunk/SoundDetect/sound_detect.c
===================================================================
--- pcbsd/trunk/SoundDetect/sound_detect.c	2008-04-21 20:07:58 UTC (rev 1747)
+++ pcbsd/trunk/SoundDetect/sound_detect.c	2008-04-22 00:25:00 UTC (rev 1748)
@@ -83,10 +83,9 @@
 				sprintf(chip_id,"0x%08x",((p->pc_device << 16) | p->pc_vendor)) ;
 				sprintf(vendor,"x%x",p->pc_vendor );
  			        sprintf(kmodule,"%s",parse_Sound_CardXML(SOUNDCARD_XML,vendor, chip_id)); 
-				
 				if(kldload(kmodule) <0)
 				{
-					warn("\nError loading module... ");
+				    warn("\nError loading module...%s",kmodule);
 				}else{ 
 				  if(memcmp(kmodule,"snd_driver",10))
 				{



More information about the Commits mailing list