Fossil

Check-in [7c3cb470]
Login

Check-in [7c3cb470]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:If the proc argument list is an empty list, don't segfault by accessing memory outside the bounds of the array. For example, as used in the footer /artifact/7f36cbf30a82ef3cec30c1917a96415fa7d76eeb?txt=1&ln=3
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7c3cb470e65bf79274f67d44b3fa2a14d54d18bd
User & Date: andybradford 2015-11-21 17:25:58
Context
2015-11-21
18:37
Revise TH1 proc_command fix from the previous check-in so it more closely matches the original fix from [f2d87242503d7a7d]. ... (check-in: c66083ed user: mistachkin tags: trunk)
17:25
If the proc argument list is an empty list, don't segfault by accessing memory outside the bounds of the array. For example, as used in the footer /artifact/7f36cbf30a82ef3cec30c1917a96415fa7d76eeb?txt=1&ln=3 ... (check-in: 7c3cb470 user: andybradford tags: trunk)
2015-11-19
09:44
Fix uninitialized variable in command-line shell dc2ac024d3 and other shell improvements, cherry-picked from SQLite trunk. ... (check-in: 63256980 user: jan.nijtmans tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/th_lang.c.
493
494
495
496
497
498
499

500
501
502
503
504
505
506
507
      argl[2];    /* Space for copies of parameter names and default values */
  p = (ProcDefn *)Th_Malloc(interp, nByte);

  /* If the last parameter in the parameter list is "args", then set the
  ** ProcDefn.hasArgs flag. The "args" parameter does not require an
  ** entry in the ProcDefn.azParam[] or ProcDefn.azDefault[] arrays.
  */

  if( anParam[nParam-1]==4 && 0==memcmp(azParam[nParam-1], "args", 4) ){
    p->hasArgs = 1;
    nParam--;
  }

  p->nParam    = nParam;
  p->azParam   = (char **)&p[1];
  p->anParam   = (int *)&p->azParam[nParam];







>
|







493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
      argl[2];    /* Space for copies of parameter names and default values */
  p = (ProcDefn *)Th_Malloc(interp, nByte);

  /* If the last parameter in the parameter list is "args", then set the
  ** ProcDefn.hasArgs flag. The "args" parameter does not require an
  ** entry in the ProcDefn.azParam[] or ProcDefn.azDefault[] arrays.
  */
  if( nParam
      && anParam[nParam-1]==4 && 0==memcmp(azParam[nParam-1], "args", 4) ){
    p->hasArgs = 1;
    nParam--;
  }

  p->nParam    = nParam;
  p->azParam   = (char **)&p[1];
  p->anParam   = (int *)&p->azParam[nParam];