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/hgTables/identifiers.c src/hg/hgTables/identifiers.c
index 272350f..596f35f 100644
--- src/hg/hgTables/identifiers.c
+++ src/hg/hgTables/identifiers.c
@@ -80,31 +80,31 @@
}
else if (isBigBed(db, table, curTrack, ctLookupName))
{
assert(sameString(field, "name"));
return randomBigBedIds(table, conn, count);
}
else if (isVcfTable(table, &isTabix))
{
assert(sameString(field, "id"));
return randomVcfIds(table, conn, count, isTabix);
}
else
{
char fullTable[HDB_MAX_TABLE_STRING];
char *c = strchr(table, '.');
- if (c || ! hFindSplitTable(database, NULL, table, fullTable, NULL))
+ if (c || ! hFindSplitTable(database, NULL, table, fullTable, sizeof fullTable, NULL))
safecpy(fullTable, sizeof(fullTable), table);
return sqlRandomSampleConn(conn, fullTable, field, count);
}
}
static void explainIdentifiers(char *db, struct sqlConnection *conn, char *idField)
/* Tell the user what field(s) they may paste/upload values for, and give
* some examples. */
{
char *xrefTable = NULL, *xrefIdField = NULL, *aliasField = NULL;
getXrefInfo(conn, &xrefTable, &xrefIdField, &aliasField);
hPrintf("The items must be values of the %s field of the currently "
"selected table, %s",
idField, curTable);
if (aliasField != NULL)