PR/26882: Matthew Mondor: ipfstat -t fails to restore termios tty state

if it fails for ipf disabled. Fix from Peter Postma.
This commit is contained in:
christos 2004-07-14 18:22:10 +00:00
parent 3e92a012a2
commit fe028e1238

View File

@ -1,4 +1,4 @@
/* $NetBSD: ipfstat.c,v 1.4 2004/05/09 04:12:03 christos Exp $ */
/* $NetBSD: ipfstat.c,v 1.5 2004/07/14 18:22:10 christos Exp $ */
/*
* Copyright (C) 1993-2001, 2003 by Darren Reed.
@ -1005,7 +1005,8 @@ int topclosed;
char str1[STSTRSIZE], str2[STSTRSIZE], str3[STSTRSIZE], str4[STSTRSIZE];
int maxtsentries = 0, reverse = 0, sorting = STSORT_DEFAULT;
int i, j, winy, tsentry, maxx, maxy, redraw = 0;
int len, srclen, dstlen, forward = 1, c = 0;
int len, srclen, dstlen, forward = 1, c = 0, ret = 0;
const char *errstr;
ips_stat_t ipsst, *ipsstp = &ipsst;
statetop_t *tstable = NULL, *tp;
ipstate_t ips;
@ -1047,8 +1048,9 @@ int topclosed;
/* get state table */
bzero((char *)&ipsst, sizeof(ipsst));
if ((ioctl(state_fd, SIOCGETFS, &ipfo) == -1)) {
perror("ioctl(SIOCGETFS)");
exit(-1);
errstr = "ioctl(SIOCGETFS)";
ret = -1;
goto out;
}
/* clear the history */
@ -1112,8 +1114,9 @@ int topclosed;
tstable = realloc(tstable,
maxtsentries * sizeof(statetop_t));
if (tstable == NULL) {
perror("realloc");
exit(-1);
errstr = "realloc";
ret = -1;
goto out;
}
}
@ -1389,12 +1392,17 @@ int topclosed;
}
} /* while */
out:
printw("\n");
curs_set(1);
nocbreak();
endwin();
free(tstable);
if (ret != 0) {
perror(errstr);
exit(ret);
}
}
#endif