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/lib/chainNetDbLoad.c src/hg/lib/chainNetDbLoad.c
index c527b17..22a75846 100644
--- src/hg/lib/chainNetDbLoad.c
+++ src/hg/lib/chainNetDbLoad.c
@@ -287,38 +287,38 @@
         }
     }
 slReverse(&chain->blockList);
 
 lmCleanup(&lm);
 return chain;
 }
 
 static struct chain *chainLoadIdSome(char *database, char *track, char *chrom, 
         int start, int end, int id, boolean loadAll)
 /* Load some or all of chain. */
 {
 struct sqlConnection *conn;
 struct sqlResult *sr;
 char **row;
-char table[64];
+char table[HDB_MAX_TABLE_STRING];
 boolean hasBin;
 struct chain *chain;
 char query[256];
 struct dyString *dy = newDyString(128);
 
 /* Load chain header. */
-if (!hFindSplitTable(database, chrom, track, table, &hasBin))
+if (!hFindSplitTable(database, chrom, track, table, sizeof table, &hasBin))
    errAbort("%s table is not in %s", track, database);
 conn = sqlConnect(database);
 sqlSafef(query, sizeof(query),
 	"select * from %s where id = %d", table, id);
 sr = sqlGetResult(conn, query);
 if ((row = sqlNextRow(sr)) == NULL)
     errAbort("chain %d is not in %s", id, table);
 chain = chainHeadLoad(row+hasBin);
 sqlFreeResult(&sr);
 
 /* Load links. */
 if (loadAll)
     {
     sqlDyStringPrintf(dy, 
 	 "select * from %sLink where chainId = %d", table, id);