44ccfacbe3a3d4b300f80d48651c77837a4b571e
galt
  Tue Apr 26 11:12:02 2022 -0700
SQL INJECTION Prevention Version 2 - this improves our methods by making subclauses of SQL that get passed around be both easy and correct to use. The way that was achieved was by getting rid of the obscure and not well used functions sqlSafefFrag and sqlDyStringPrintfFrag and replacing them with the plain versions of those functions, since these are not needed anymore. The new version checks for NOSQLINJ in unquoted %-s which is used to include SQL clauses, and will give an error the NOSQLINJ clause is not present, and this will automatically require the correct behavior by developers. sqlDyStringPrint is a very useful function, however because it was not enforced, users could use various other dyString functions and they operated without any awareness or checking for SQL correct use. Now those dyString functions are prohibited and it will produce an error if you try to use a dyString function on a SQL string, which is simply detected by the presence of the NOSQLINJ prefix.

diff --git src/hg/hgTables/great.c src/hg/hgTables/great.c
index 3d1806d..e62c5ca 100644
--- src/hg/hgTables/great.c
+++ src/hg/hgTables/great.c
@@ -111,31 +111,31 @@
     "\nPlease go back and ensure that one of those assemblies is chosen.",
 	dyStringContents(dy));
     htmlClose();
 	dyStringFree(&dy);
     }
 
 slNameFreeList(&supportedAssemblies);
 }
 
 void doGreatTopLevel()
 /* intermediate page for formats printed directly from top form */
 {
 struct dyString *name = getRequestName();
 
 htmlOpen("Send BED data to GREAT as %s", dyStringContents(name));
-freeDyString(&name);
+dyStringFree(&name);
 verifyGreatAssemblies();
 startGreatForm();
 cgiMakeHiddenVar(hgtaDoTopSubmit, "get output");
 printGreatSubmitButtons();
 hPrintf("<div style='height:.9em;'></div>\n");
 htmlClose();
 }
 
 void startGreatForm()
 /* Start form for GREAT */
 {
 hPrintf("<FORM ACTION=\"%s\" NAME='greatForm' METHOD=POST>\n", getScriptName());
 }
 
 void printGreatSubmitButtons()
@@ -171,33 +171,33 @@
 struct dyString *requestURL = dyStringCreate("http://%s/%s", cgiServerNamePort(), path);
 struct dyString *greatRequest;
 
 // archive server for hg18
 if (sameWord("hg18", database))
   greatRequest = dyStringCreate(
     "<meta http-equiv='refresh' content='0;url=http://bejerano.stanford.edu/great/public-2.0.2/cgi-bin/greatStart.php?requestURL=%s&requestSpecies=%s&requestName=%s&requestSender=UCSC%%20Table%%20Browser'>",
     dyStringContents(requestURL), database, dyStringContents(requestName));
 else
   greatRequest = dyStringCreate(
     "<meta http-equiv='refresh' content='0;url=http://great.stanford.edu/public/cgi-bin/greatStart.php?requestURL=%s&requestSpecies=%s&requestName=%s&requestSender=UCSC%%20Table%%20Browser'>",
     dyStringContents(requestURL), database, dyStringContents(requestName));
 
 hPrintf("<b>GREAT</b> is processing BED data from \"%s\"...please wait.\n", dyStringContents(requestName));
 hWrites(dyStringContents(greatRequest));
-freeDyString(&greatRequest);
-freeDyString(&requestName);
-freeDyString(&requestURL);
+dyStringFree(&greatRequest);
+dyStringFree(&requestName);
+dyStringFree(&requestURL);
 }
 
 void doGetGreatOutput(void (*dispatch)())
 {
 struct tempName tn;
 int saveStdout;
 FILE *f;
 
 trashDirFile(&tn, "great", cartSessionId(cart), ".bed");
 f = fopen(tn.forCgi, "w");
 
 /* We want to capture hgTables stdout output to a trash file
  * which will later be fetched by Great via URL. */
 /* Workaround because stdout stream is not assignable on some operating systems */
 fflush(stdout);