9c94fbc11c1bb90ea92e216b5c65d908b2c79b0d
galt
  Fri May 13 18:56:18 2022 -0700
Fixing oddly encoded firstBuf in hgSession. refs #29274, #29373

diff --git src/hg/hgSession/hgSession.c src/hg/hgSession/hgSession.c
index a4b6506..39a0924 100644
--- src/hg/hgSession/hgSession.c
+++ src/hg/hgSession/hgSession.c
@@ -802,50 +802,48 @@
 else
     printf("%s on", CART_HAS_DEFAULT_VISIBILITY);
 }
 
 #define INITIAL_USE_COUNT 0
 static int saveCartAsSession(struct sqlConnection *conn, char *encUserName, char *encSessionName,
                              int sharingLevel)
 /* Save all settings in cart, either adding a new session or overwriting an existing session.
  * Return useCount so that the caller can distinguish between adding and overWriting. */
 {
 struct sqlResult *sr = NULL;
 struct dyString *dy = dyStringNew(16 * 1024);
 char **row;
 char *firstUse = NULL;
 int useCount = INITIAL_USE_COUNT;
-char firstUseBuf[32];
 char *settings = "";
 
 boolean gotSettings = (sqlFieldIndex(conn, namedSessionTable, "settings") >= 0);
 
 /* If this session already existed, preserve its firstUse, useCount,
  * and settings (if available). */
 if (gotSettings)
     sqlDyStringPrintf(dy, "SELECT firstUse, useCount, settings FROM %s "
                   "WHERE userName = '%s' AND sessionName = '%s';",
                   namedSessionTable, encUserName, encSessionName);
 else
     sqlDyStringPrintf(dy, "SELECT firstUse, useCount FROM %s "
                   "WHERE userName = '%s' AND sessionName = '%s';",
                   namedSessionTable, encUserName, encSessionName);
 sr = sqlGetResult(conn, dy->string);
 if ((row = sqlNextRow(sr)) != NULL)
     {
-    safef(firstUseBuf, sizeof(firstUseBuf), "'%s'", row[0]);
-    firstUse = firstUseBuf;
+    firstUse = cloneString(row[0]);
     useCount = atoi(row[1]) + 1;
     if (gotSettings)
         {
         settings = cloneString(row[2]);
         if (settings == NULL)
             settings = "";
         }
     }
 sqlFreeResult(&sr);
 
 saveSessionData(cart, encUserName, encSessionName,
                 cgiOptionalString(hgsSessionDataDbSuffix));
 
 /* Remove pre-existing session (if any) before updating. */
 dyStringClear(dy);