svn commit: r262679 - head/contrib/telnet/telnetd
Marcel Moolenaar
marcel at FreeBSD.org
Sun Mar 2 03:34:07 UTC 2014
Author: marcel
Date: Sun Mar 2 03:34:06 2014
New Revision: 262679
URL: http://svnweb.freebsd.org/changeset/base/262679
Log:
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@
Modified:
head/contrib/telnet/telnetd/telnetd.c
Modified: head/contrib/telnet/telnetd/telnetd.c
==============================================================================
--- head/contrib/telnet/telnetd/telnetd.c Sun Mar 2 02:52:34 2014 (r262678)
+++ head/contrib/telnet/telnetd/telnetd.c Sun Mar 2 03:34:06 2014 (r262679)
@@ -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)
More information about the svn-src-head
mailing list