mothra: fix libpanel entry buffer overflow when pasting text

front
cinap_lenrek 2012-01-01 21:00:01 +01:00
parent 31109f5047
commit 9c0301115d
1 changed files with 5 additions and 4 deletions

View File

@ -28,16 +28,17 @@ void pl_snarfentry(Panel *p, int cut){
write(fd, ep->entry, n);
ep->entp=ep->entry;
}else{
if((s=malloc(1024+SLACK))==0){
n = 1024;
if((s=malloc(n+SLACK))==0){
close(fd);
return;
}
if((n=readn(fd, s, 1024))<0)
if((n=readn(fd, s, n))<0)
n=0;
free(ep->entry);
s=realloc(s, n+SLACK);
ep->entry=s;
ep->eent=s+n+SLACK;
ep->eent=s+n;
ep->entp=s+n;
}
close(fd);
@ -129,9 +130,9 @@ void pl_typeentry(Panel *p, Rune c){
ep->entp=ep->entry+n;
ep->eent=ep->entp+100;
}
*ep->entp='\0';
break;
}
memset(ep->entp, 0, SLACK);
pldraw(p, p->b);
}
Point pl_getsizeentry(Panel *p, Point children){