e81403a315a24af601884b8a19e89bcecc92f267 galt Sat Dec 8 20:04:28 2018 -0800 Fixing hFindSplitTable and its use. Standard size, give real string size so no undetected overflows. Test result and abort if not found. Avoids SQL errors that otherwise will popup. Handles uninitialzed stack better for the output name. refs #22596. diff --git src/hg/hgc/rmskJoinedClick.c src/hg/hgc/rmskJoinedClick.c index b51361d..2af9bc5 100644 --- src/hg/hgc/rmskJoinedClick.c +++ src/hg/hgc/rmskJoinedClick.c @@ -221,38 +221,40 @@ else if (startsWith ("rmskJoinedBaseline", table)) { strcpy (alignTable, "rmskAlignBaseline"); strcpy (outTable, "rmskOutBaseline"); } cartWebStart (cart, database, "%s", tdb->longLabel); int offset = cartInt (cart, "o"); if (offset >= 0) { struct sqlConnection *conn2 = hAllocConn (database); struct sqlResult *sr2; char **row; char query[256]; - char qTable[64]; + char qTable[HDB_MAX_TABLE_STRING]; boolean hasBin; int start = cartInt (cart, "o"); if (hTableExists (database, table)) { - hFindSplitTable (database, seqName, table, qTable, &hasBin); + if (!hFindSplitTable (database, seqName, table, qTable, sizeof(qTable), &hasBin)) + errAbort("track %s not found", table); + sqlSafef (query, sizeof (query), "select * from %s where chrom = '%s' and alignStart >= %d" " and id = %s", qTable, seqName, start-1, repeat); sr2 = sqlGetResult (conn2, query); if ((row = sqlNextRow (sr2)) != NULL) { struct rmskJoined *rmJoin = rmskJoinedLoad (row + hasBin); char class[32]; class[0] = '\0'; char family[32]; family[0] = '\0'; char *poundPtr = index (rmJoin->name, '#'); if (poundPtr) @@ -275,31 +277,32 @@ printf ("<b>Orientation:</b> %s<br>\n", rmJoin->strand); printf ("<b>Joined Element Genomic Range:</b> %s:%d-%d<br>\n", rmJoin->chrom, rmJoin->alignStart+1, rmJoin->alignEnd); printf ("<br><br>\n"); } sqlFreeResult (&sr2); } /* * Locate *.out annotation for this element */ if (hTableExists (database, outTable)) { int isFirst = 0; struct rmskOut2 *ro; - hFindSplitTable (database, seqName, outTable, qTable, &hasBin); + if (!hFindSplitTable (database, seqName, outTable, qTable, sizeof(qTable), &hasBin)) + errAbort("track %s not found", outTable); sqlSafef (query, sizeof (query), "select * from %s where genoName = '%s' and genoStart >= %d" " and id = %s", qTable, seqName, start-1, repeat); sr2 = sqlGetResult (conn2, query); printf ("<h4>RepeatMasker Annotation:</h4>\n"); printf ("The RepeatMasker annotation line(s) for this element. " "If the element is fragmented the output will contain one " "line per joined fragment.<p>\n"); printf ("<table cellspacing=\"0\">\n"); while ((row = sqlNextRow (sr2)) != NULL) { ro = rmskOut2Load (row + hasBin); if (!isFirst++) printOutTableHeader (ro->strand[0]); @@ -346,31 +349,32 @@ printf (" </tr>\n"); } sqlFreeResult (&sr2); printf ("</table>\n"); } printf ("<br><br>\n"); /* * Locate *.align data for this element */ if (hTableExists (database, alignTable)) { struct rmskAlign *ro; - hFindSplitTable (database, seqName, alignTable, qTable, &hasBin); + if (!hFindSplitTable (database, seqName, alignTable, qTable, sizeof(qTable), &hasBin)) + errAbort("track %s not found", alignTable); sqlSafef (query, sizeof (query), "select * from %s where genoName = '%s' and genoStart >= %d" " and id = %s", qTable, seqName, start-1, repeat); sr2 = sqlGetResult (conn2, query); printf ("<h4>RepeatMasker Alignments:</h4>\n"); printf ("The raw alignment data used by RepeatMasker to generate " "the final annotation call for this element. NOTE: The " "aligned sequence names and consensus positions may differ " "from the final annotation.<p>\n"); printf ("<table>\n"); while ((row = sqlNextRow (sr2)) != NULL) { ro = rmskAlignLoad (row + hasBin); printf (" <tr>\n");