mothra: fix libpanel entry buffer overflow when pasting text
This commit is contained in:
parent
31109f5047
commit
9c0301115d
1 changed files with 5 additions and 4 deletions
|
@ -28,16 +28,17 @@ void pl_snarfentry(Panel *p, int cut){
|
||||||
write(fd, ep->entry, n);
|
write(fd, ep->entry, n);
|
||||||
ep->entp=ep->entry;
|
ep->entp=ep->entry;
|
||||||
}else{
|
}else{
|
||||||
if((s=malloc(1024+SLACK))==0){
|
n = 1024;
|
||||||
|
if((s=malloc(n+SLACK))==0){
|
||||||
close(fd);
|
close(fd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if((n=readn(fd, s, 1024))<0)
|
if((n=readn(fd, s, n))<0)
|
||||||
n=0;
|
n=0;
|
||||||
free(ep->entry);
|
free(ep->entry);
|
||||||
s=realloc(s, n+SLACK);
|
s=realloc(s, n+SLACK);
|
||||||
ep->entry=s;
|
ep->entry=s;
|
||||||
ep->eent=s+n+SLACK;
|
ep->eent=s+n;
|
||||||
ep->entp=s+n;
|
ep->entp=s+n;
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
|
@ -129,9 +130,9 @@ void pl_typeentry(Panel *p, Rune c){
|
||||||
ep->entp=ep->entry+n;
|
ep->entp=ep->entry+n;
|
||||||
ep->eent=ep->entp+100;
|
ep->eent=ep->entp+100;
|
||||||
}
|
}
|
||||||
|
*ep->entp='\0';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
memset(ep->entp, 0, SLACK);
|
|
||||||
pldraw(p, p->b);
|
pldraw(p, p->b);
|
||||||
}
|
}
|
||||||
Point pl_getsizeentry(Panel *p, Point children){
|
Point pl_getsizeentry(Panel *p, Point children){
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue