mirror of
https://github.com/sheumann/telnetd.git
synced 2024-11-25 05:30:54 +00:00
Improve upon previous commit:
1. Check return of mmap(2) (*) 2. Avoid FD leak when fstat fails. 3. Fix style(9). (*) Pointed out by jmg@ git-svn-id: http://svn0.us-east.freebsd.org/base/head/contrib/telnet@262679 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
This commit is contained in:
parent
2c30da6c4a
commit
2d43ae29e1
@ -926,14 +926,15 @@ telnet(int f, int p, char *host)
|
|||||||
if (hostinfo && *IM)
|
if (hostinfo && *IM)
|
||||||
putf(IM, ptyibuf2);
|
putf(IM, ptyibuf2);
|
||||||
if (IF && if_fd != -1) {
|
if (IF && if_fd != -1) {
|
||||||
if(fstat (if_fd, &statbuf)!=-1) {
|
if (fstat(if_fd, &statbuf) != -1 && statbuf.st_size > 0) {
|
||||||
if (statbuf.st_size > 0) {
|
if_buf = (char *) mmap (0, statbuf.st_size,
|
||||||
if_buf = (char *) mmap (0, statbuf.st_size, PROT_READ, 0, if_fd, 0);
|
PROT_READ, 0, if_fd, 0);
|
||||||
putf(if_buf, ptyibuf2);
|
if (if_buf != MAP_FAILED) {
|
||||||
munmap (if_buf, statbuf.st_size);
|
putf(if_buf, ptyibuf2);
|
||||||
|
munmap(if_buf, statbuf.st_size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
close (if_fd);
|
close (if_fd);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pcc)
|
if (pcc)
|
||||||
|
Loading…
Reference in New Issue
Block a user