src/hg/hgTracks/simpleTracks.c 1.146

1.146 2010/06/04 18:08:14 fanhsu
Changed sprintf to safef for DECIPHER track.
Index: src/hg/hgTracks/simpleTracks.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTracks/simpleTracks.c,v
retrieving revision 1.145
retrieving revision 1.146
diff -b -B -U 4 -r1.145 -r1.146
--- src/hg/hgTracks/simpleTracks.c	1 Jun 2010 18:35:32 -0000	1.145
+++ src/hg/hgTracks/simpleTracks.c	4 Jun 2010 18:08:14 -0000	1.146
@@ -4934,9 +4934,11 @@
 
 int i=0;
 conn = hAllocConn(database);
 
-sprintf(query, "select distinct diseaseClassCode from gadAll where geneSymbol='%s' and association = 'Y' order by diseaseClassCode", item->name);
+safef(query, sizeof(query), 
+"select distinct diseaseClassCode from gadAll where geneSymbol='%s' and association = 'Y' order by diseaseClassCode", 
+item->name);
 sr = sqlMustGetResult(conn, query);
 row = sqlNextRow(sr);
 
 /* show up to 20 max entries */
@@ -4944,22 +4946,22 @@
 while ((row != NULL) && i<20)
     {
     if (i != 0)
 	{
-	sprintf(chp, ",");
+	safef(chp, 2, ",");
 	chp++;
 	}
     diseaseClassCode = row[0];
 
-    sprintf(chp, "%s", diseaseClassCode);
+    safef(chp, 100, "%s", diseaseClassCode);
     chp = chp+strlen(diseaseClassCode);
     row = sqlNextRow(sr);
     i++;
     }
 
 if ((i == 20) && (row != NULL))
     {
-    sprintf(chp, " ...");
+    safef(chp, 4, " ...");
     chp++;chp++;chp++;chp++;
     }
 
 *chp = '\0';
@@ -4983,9 +4985,10 @@
 int i=0;
 
 conn = hAllocConn(database);
 
-sprintf(query, "select distinct broadPhen from gadAll where geneSymbol='%s' and association = 'Y' order by broadPhen", item->name);
+safef(query, sizeof(query),
+"select distinct broadPhen from gadAll where geneSymbol='%s' and association = 'Y' order by broadPhen", item->name);
 sr = sqlMustGetResult(conn, query);
 row = sqlNextRow(sr);
 
 /* show up to 20 max entries */
@@ -5093,9 +5096,9 @@
 int i=0;
 
 conn = hAllocConn(database);
 
-sprintf(query,
+safef(query,sizeof(query),
         "select distinct phenotype from decipherRaw where id='%s' order by phenotype", item->name);
 sr = sqlMustGetResult(conn, query);
 row = sqlNextRow(sr);
 
@@ -5104,20 +5107,20 @@
 while ((row != NULL) && i<20)
     {
     if (i != 0)
 	{
-	sprintf(chp, "; ");
+	safef(chp, 3, "; ");
 	chp++;chp++;
 	}
-    sprintf(chp, "%s", row[0]);
+    safef(chp, 100, "%s", row[0]);
     chp = chp+strlen(row[0]);
     row = sqlNextRow(sr);
     i++;
     }
 
 if ((i == 20) && (row != NULL))
     {
-    sprintf(chp, " ...");
+    safef(chp, 5, " ...");
     chp++;chp++;chp++;chp++;
     }
 
 *chp = '\0';
@@ -5142,15 +5145,15 @@
 /* color scheme:
 	RED:	If the entry is a deletion (mean ratio < 0)
 	GREEN:	If the entry is a duplication (mean ratio > 0)
 */
-sprintf(cond_str, "name='%s' ", bedItem->name);
+safef(cond_str, sizeof(cond_str),"name='%s' ", bedItem->name);
 decipherId = sqlGetField(database, "decipher", "name", cond_str);
 if (decipherId != NULL)
     {
     if (hTableExists(database, "decipherRaw"))
     	{
-    	sprintf(query, "select mean_ratio > 0 from decipherRaw where id = '%s'", decipherId);
+    	safef(query, sizeof(query), "select mean_ratio > 0 from decipherRaw where id = '%s'", decipherId);
     	sr = sqlGetResult(conn, query);
     	if ((row = sqlNextRow(sr)) != NULL)
             {
 	    if (sameWord(row[0], "1"))
@@ -5165,9 +5168,10 @@
 	sqlFreeResult(&sr);
     	/* add more logic here to check for mean_ratio = 0 
 	   (which is a problem to be fixed by DECIPHER */
 
-	sprintf(query, "select mean_ratio = 0 from decipherRaw where id = '%s'", decipherId);
+	safef(query, sizeof(query), 
+	       "select mean_ratio = 0 from decipherRaw where id = '%s'", decipherId);
     	sr = sqlGetResult(conn, query);
     	if ((row = sqlNextRow(sr)) != NULL)
             {
 	    if (sameWord(row[0], "1"))