Skip to content

Commit

Permalink
sh_setmatch(): fix node size calculation
Browse files Browse the repository at this point in the history
This fixes the function that sets ${.sh.match}. Patch from OpenSUSE:
https://build.opensuse.org/package/view_file/shells/ksh/ksh93-limit-name-len.dif

src/cmd/ksh93/sh/init.c: sh_setmatch():
- Fix node size calculation, possibly preventing data corruption.

src/cmd/ksh93/include/ulimit.h: Limit_t:
- Defining the 'name' struct member as 'char name[16]' makes
  no sense as the name is being initialised statically in
  data/limits.c; just make it a 'char *name' pointer.
  • Loading branch information
McDutchie committed Feb 2, 2021
1 parent 3002c41 commit 9f980ba
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/cmd/ksh93/include/ulimit.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@

typedef struct Limit_s
{
const char name[16];
const char* name;
const char* description;
int index;
const char* conf;
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/ksh93/sh/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ struct match
char *val;
char *rval[2];
regoff_t *match;
char node[NV_MINSZ+sizeof(char*)];
char node[NV_MINSZ+sizeof(char*)+sizeof(Dtlink_t)];
regoff_t first;
int vsize;
int nmatch;
Expand Down Expand Up @@ -721,7 +721,7 @@ static int hasgetdisc(register Namfun_t *fp)
void sh_setmatch(Shell_t *shp,const char *v, int vsize, int nmatch, regoff_t match[],int index)
{
struct match *mp = &ip->SH_MATCH_init;
Namval_t *np = nv_namptr(mp->node,0);
Namval_t *np = (Namval_t*)(&(mp->node[0]));
register int i,n,x;
unsigned int savesub = shp->subshell;
Namarr_t *ap = nv_arrayptr(SH_MATCHNOD);
Expand Down

0 comments on commit 9f980ba

Please sign in to comment.