mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 04:43:53 +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@
This commit is contained in:
parent
4896af9f55
commit
6df39cc949
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=262679
|
@ -926,14 +926,15 @@ 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);
|
||||
putf(if_buf, ptyibuf2);
|
||||
munmap (if_buf, statbuf.st_size);
|
||||
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);
|
||||
}
|
||||
}
|
||||
close (if_fd);
|
||||
}
|
||||
}
|
||||
|
||||
if (pcc)
|
||||
|
|
Loading…
Reference in a new issue