Skip to content
Tcl Source Code History Of Ticket 7079e4f91601e9c7
Login

History Of Ticket 7079e4f91601e9c7

Artifacts Associated With Ticket 7079e4f91601e9c7

  1. Ticket change [2bb7aed66a] (rid 195004) by salmonx on 2021-06-22 07:49:25:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/html"
    4. comment initialized to:
      <p>
      A stack overflow vulnerability in Tcl nmakehelp.c allows code execution via a crated file
      </p>
      
      <p> The length of local variable 'szBuffer' in GetVersionFromFile is 100. szBuffer can be controlled via crafted argv.
      
      </p>
      
      <hr>
      <pre>
      static const char *
      GetVersionFromFile(
          const char *filename,
          const char *match,
          int numdots)
      {
          size_t cbBuffer = 100;
          static char szBuffer[100];
          char *szResult = NULL;
          FILE *fp = fopen(filename, "rt");
      
          if (fp != NULL) {
      	/*
      	 * Read data until we see our match string.
      	 */
      
      	while (fgets(szBuffer, cbBuffer, fp) != NULL) {
      	    LPSTR p, q;
      
      	    p = strstr(szBuffer, match);
      	    if (p != NULL) {
      		/*
      		 * Skip to first digit after the match.
      		 */
      
      		p += strlen(match);
      		while (*p && !isdigit(*p)) {
      		    ++p;
      		}
      
      		/*
      		 * Find ending whitespace.
      		 */
      
      		q = p;
      		while (*q && (strchr("0123456789.ab", *q)) && ((!strchr(".ab", *q)
      			    && (!strchr("ab", q[-1])) || --numdots))) {
      		    ++q;
      		}
      
      		memcpy(szBuffer, p, q - p); // Bug is here
      		szBuffer[q-p] = 0;
      		szResult = szBuffer;
      		break;
      	    }
      	}
      	fclose(fp);
          }
          return szResult;
      }
      
      </pre>
      
    5. foundin initialized to: "ALL"
    6. is_private initialized to: "0"
    7. login: "salmonx"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "1e6726276a059d4157d886e633147205cbd8e399"
    10. resolution initialized to: "None"
    11. severity initialized to: "Important"
    12. status initialized to: "Open"
    13. submitter initialized to: "salmonx"
    14. subsystem initialized to: "69. Other"
    15. title initialized to:
      A stack overflow vulnerability in Tcl nmakehelp.c allows code execution via a crated file
      
    16. type initialized to: "Bug"
  2. Ticket change [81b23a128d] (rid 195010) by jan.nijtmans on 2021-06-22 09:17:26:

    1. assignee changed to: "jan.nijtmans"
    2. closedate changed to: "2459387.88710669"
    3. closer changed to: "jan.nijtmans"
    4. icomment:
      Well, let's analyse it.
      
      Since szBuffer is initialized with fgets(), it is guaranteed to be a NULL-terminated string. The two later while's check for "*p" and "*q" resp, so those two while-loops end - worst-case - at the final NULL-character. If 'p' points at szBuffer[0] and 'q' points at szBuffer[99], then - still - the memcpy() does not overflow. I don't see at all how this can lead to code execution.
      
      If you found this by some automatic tool, then please report this as "false alarm" to the tool maintainers.
      
      The only bug I see in this line is that 'memcpy()' should have been a 'memmove()', since p is pointing to the same buffer, it could be overlapping, which is disallowed for 'memcpy()'. That's fixed here: [28ef6c0c741408a2] (but - still - that cannot lead to code execution.
      
    5. login: "jan.nijtmans"
    6. mimetype: "text/x-fossil-wiki"
    7. resolution changed to: "Invalid"
    8. severity changed to: "Cosmetic"
    9. status changed to: "Closed"
  3. Ticket change [16a462a427] (rid 195024) by jan.nijtmans on 2021-06-23 12:30:41:

    1. closedate changed to: "2459389.02131105"
    2. icomment:
      It turns out that it's easy to eliminate the use of memcpy (or memove) altogether, that should make your analysis tool 100% happy!
      
    3. login: "jan.nijtmans"
    4. mimetype: "text/x-fossil-wiki"
    5. resolution changed to: "Fixed"