1da15f230f81e48dd030f04649f186688cefd933
chmalee
  Thu May 7 11:58:06 2026 -0700
Fix incorrect strncpy call in jsonParse with a better snippage of the input string that avoids a strncpy altogether, refs #37500

diff --git src/lib/jsonParse.c src/lib/jsonParse.c
index 430b169ab6a..1aca5bc9902 100644
--- src/lib/jsonParse.c
+++ src/lib/jsonParse.c
@@ -158,34 +158,37 @@
 }
 
 static char *getStringLm(char *str, int *posPtr, struct lm *lm)
 {
 // read a double-quote delimited string; we handle backslash escaping.
 // returns allocated string.
 boolean escapeMode = FALSE;
 int i;
 struct dyString *ds = dyStringNew(1024);
 getSpecificChar('"', str, posPtr);
 for(i = 0;; i++)
     {
     char c = str[*posPtr + i];
     if(!c)
         {
-        char cpy[i+1];
-        strncpy(str, cpy, i);
-        cpy[i] = '\0';
-        errAbort("Premature end of string (missing trailing double-quote); string position '%d', string: '%s'", *posPtr, cpy);
+        int maxSnip = 80;
+        int snipLen = min(i, maxSnip);
+        char *snipStart = str + *posPtr + (i - snipLen);
+        char *ellipsis = (i > maxSnip) ? "..." : "";
+        errAbort("Premature end of string (missing trailing double-quote); "
+                 "string position '%d', string: '%s%.*s'",
+                 *posPtr, ellipsis, snipLen, snipStart);
         }
     else if(escapeMode)
         {
         // We support escape sequences listed in http://www.json.org,
         // except for Unicode which we cannot support in C-strings
         switch(c)
             {
             case 'b':
                 c = '\b';
                 break;
             case 'f':
                 c = '\f';
                 break;
             case 'n':
                 c = '\n';