Ticket #8975: scummvm-0.13-bufferoverflow.patch

File scummvm-0.13-bufferoverflow.patch, 740 bytes (added by SF/reddwarf69, 15 years ago)

Fix

  • engines/saga/sfuncs.cpp

     
    15701570
    15711571        for (int i = 0; i < nArgs; i++) {
    15721572                snprintf(buf1, 100, "%d", thread->pop());
    1573                 strncat(buf, buf1, 256);
     1573                strncat(buf, buf1, sizeof(buf) - strlen(buf) - 1);
    15741574                if (i + 1 < nArgs)
    1575                         strncat(buf, ", ", 256);
     1575                        strncat(buf, ", ", sizeof(buf) - strlen(buf) - 1);
    15761576        }
    15771577
    15781578        debug(0, "%s)", buf);
  • engines/scumm/he/logic_he.cpp

     
    8686
    8787        for (int i = 1; i < numArgs; i++) {
    8888                snprintf(tmp, 32, ", %d", args[i]);
    89                 strncat(str, tmp, 256);
     89                strncat(str, tmp, sizeof(str) - strlen(str) - 1);
    9090        }
    91         strncat(str, "])", 256);
     91        strncat(str, "])", sizeof(str) - strlen(str) - 1);
    9292
    9393        debug(0, "%s", str);
    9494#else