mirror of
https://github.com/sheumann/telnetd.git
synced 2024-11-22 01:31: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,15 +926,16 @@ telnet(int f, int p, char *host)
|
||||
if (hostinfo && *IM)
|
||||
putf(IM, ptyibuf2);
|
||||
if (IF && if_fd != -1) {
|
||||
if(fstat (if_fd, &statbuf)!=-1) {
|
||||
if (statbuf.st_size > 0) {
|
||||
if_buf = (char *) mmap (0, statbuf.st_size, PROT_READ, 0, if_fd, 0);
|
||||
if (fstat(if_fd, &statbuf) != -1 && statbuf.st_size > 0) {
|
||||
if_buf = (char *) mmap (0, statbuf.st_size,
|
||||
PROT_READ, 0, if_fd, 0);
|
||||
if (if_buf != MAP_FAILED) {
|
||||
putf(if_buf, ptyibuf2);
|
||||
munmap (if_buf, statbuf.st_size);
|
||||
munmap(if_buf, statbuf.st_size);
|
||||
}
|
||||
}
|
||||
close (if_fd);
|
||||
}
|
||||
}
|
||||
|
||||
if (pcc)
|
||||
(void) strncat(ptyibuf2, ptyip, pcc+1);
|
||||
|
Loading…
Reference in New Issue
Block a user