mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix more bugs that occur when enabling ASan (#293)
src/cmd/ksh93/{bltins/typeset,sh/name,sh/nvtree,sh/nvtype}.c:
- Replace more instances of memcmp with strncmp to fix
heap-buffer-overflow errors when running the regression tests
with ASan enabled.
src/cmd/ksh93/edit/vi.c:
- Fix an invalid dereference of the 'p' pointer to fix a crash in
vi mode when entering a comment in the command history. This
bugfix was backported from ksh2020:
https://github.com/att/ast/issues/798
src/cmd/ksh93/tests/pty.sh:
- Add a regression test for the vi mode crash.
This commit is contained in:
parent
88a1f3d661
commit
1aec9b06dd
6 changed files with 20 additions and 5 deletions
|
|
@ -187,7 +187,7 @@ Namval_t *nv_addnode(Namval_t* np, int remove)
|
|||
nv_delete(np,root,NV_NOFREE);
|
||||
np = nv_search(sp->rp->nvname,root,NV_ADD);
|
||||
}
|
||||
if(sp->numnodes && memcmp(np->nvname,NV_CLASS,sizeof(NV_CLASS)-1))
|
||||
if(sp->numnodes && strncmp(np->nvname,NV_CLASS,sizeof(NV_CLASS)-1))
|
||||
{
|
||||
name = (sp->nodes[0])->nvname;
|
||||
i = strlen(name);
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ void *nv_diropen(Namval_t *np,const char *name)
|
|||
{
|
||||
char *cp = nv_name(dp->hp);
|
||||
c = strlen(cp);
|
||||
if(memcmp(name,cp,c) || name[c]!='[')
|
||||
if(strncmp(name,cp,c) || name[c]!='[')
|
||||
dp->hp = (Namval_t*)dtnext(dp->root,dp->hp);
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -883,7 +883,7 @@ Namval_t *nv_mktype(Namval_t **nodes, int numnodes)
|
|||
continue;
|
||||
}
|
||||
nnodes++;
|
||||
if(name && memcmp(&name[m],&np->nvname[m],n)==0 && np->nvname[m+n]=='.')
|
||||
if(name && strncmp(&name[m],&np->nvname[m],n)==0 && np->nvname[m+n]=='.')
|
||||
offset -= sizeof(char*);
|
||||
dsize = nv_datasize(np,&offset);
|
||||
if(!nv_isarray(np) && (dp=(Namtype_t*)nv_hasdisc(np, &type_disc)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue