diff options
author | cinap_lenrek <cinap_lenrek@centraldogma> | 2012-01-01 21:00:01 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@centraldogma> | 2012-01-01 21:00:01 +0100 |
commit | 9c0301115d8782cfa90e0c2c24f03bf3304f1405 (patch) | |
tree | e020841ff9730cfd39ee2c04a1d8efee69bdefa8 /sys/src/cmd/mothra/libpanel | |
parent | 31109f5047f04a3ab0a9a9b78910ef1c193e3e6f (diff) |
mothra: fix libpanel entry buffer overflow when pasting text
Diffstat (limited to 'sys/src/cmd/mothra/libpanel')
-rw-r--r-- | sys/src/cmd/mothra/libpanel/entry.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/src/cmd/mothra/libpanel/entry.c b/sys/src/cmd/mothra/libpanel/entry.c index 85e724ef7..30e12a6e1 100644 --- a/sys/src/cmd/mothra/libpanel/entry.c +++ b/sys/src/cmd/mothra/libpanel/entry.c @@ -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){ |