🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #245

(1.5.5) nntpd dumps core on a Sun-4.

#245
From: Felix Lee
Date: Thu, 20 Jul 1989 17:47
126 lines
3981 bytes
(1.5.5) nntpd dumps core on a Sun-4 (using Sun's compiler), because
code in subnet.c tries to pass (long) where a (struct in_addr) is
expected.  Which fails miserably because Sun's Sun-4 compiler passes
structs as pointers.

Context diff follows.  (including some random lint cleanup; nntp 1.5.5
is quite linty.)
--
Felix Lee	flee@shire.cs.psu.edu	*!psuvax1!shire!flee

*** /tmp/,RCSt1a03093	Thu Jul 20 13:36:52 1989
--- subnet.c	Wed Jul 19 18:40:38 1989
***************
*** 117,123 ****
  
  	if_count = ifc.ifc_len / sizeof (struct ifreq);
  
! 	in_ifsni = (struct in_if *) malloc(if_count * sizeof (struct in_if));
  	if (in_ifsni == 0) {
  		(void) close(s);
  		return (-1);
--- 117,124 ----
  
  	if_count = ifc.ifc_len / sizeof (struct ifreq);
  
! 	in_ifsni = (struct in_if *)
! 		malloc((unsigned) if_count * sizeof (struct in_if));
  	if (in_ifsni == 0) {
  		(void) close(s);
  		return (-1);
***************
*** 124,129 ****
--- 125,132 ----
  	}
  
  	for (i = j = 0; i < if_count; ++i) {
+ 		struct sockaddr_in *s_in;
+ 
  		ifr = &ifc.ifc_req[i];
  		if (ioctl(s, SIOCGIFFLAGS, ifr) < 0)
  			continue;
***************
*** 133,144 ****
  			continue;
  		if (ifr->ifr_addr.sa_family != AF_INET)
  			continue;
! 		addr = (*(struct sockaddr_in *)&ifr->ifr_addr).sin_addr.s_addr;
! 		in_ifsni[j].i_net = inet_netof(addr);
  		if (ioctl(s, SIOCGIFNETMASK, ifr) < 0)
  			continue;
! 		in_ifsni[j].i_subnetmask =
! 		 ntohl((*(struct sockaddr_in *)&ifr->ifr_addr).sin_addr.s_addr);
  		/*
  		 * The following should "never happen".  But under SunOs
  		 * 3.4, along with the rest of their broken networking code,
--- 136,148 ----
  			continue;
  		if (ifr->ifr_addr.sa_family != AF_INET)
  			continue;
! 		s_in = (struct sockaddr_in *) &ifr->ifr_addr;
! 		addr = s_in->sin_addr.s_addr;
! 		in_ifsni[j].i_net = inet_netof(s_in->sin_addr);
  		if (ioctl(s, SIOCGIFNETMASK, ifr) < 0)
  			continue;
! 		s_in = (struct sockaddr_in *) &ifr->ifr_addr;
! 		in_ifsni[j].i_subnetmask = ntohl(s_in->sin_addr.s_addr);
  		/*
  		 * The following should "never happen".  But under SunOs
  		 * 3.4, along with the rest of their broken networking code,
***************
*** 198,205 ****
  	register u_long	i = ntohl(in);
  	register u_long	net;
  	u_long		inet_netof(), inet_lnaof();
  
! 	net = inet_netof(in);
  
  	/*
  	 * Check whether network is a subnet;
--- 202,211 ----
  	register u_long	i = ntohl(in);
  	register u_long	net;
  	u_long		inet_netof(), inet_lnaof();
+ 	struct in_addr in_a;
  
! 	in_a.s_addr = in;
! 	net = inet_netof(in_a);
  
  	/*
  	 * Check whether network is a subnet;
***************
*** 212,218 ****
  		if (net == in_ifsni[j].i_net) {
  #endif
  			net = i & in_ifsni[j].i_subnetmask;
! 			if (inet_lnaof(htonl(net)) == 0)
  				return (0);
  			else
  				return (net >> in_ifsni[j].i_bitshift);
--- 218,225 ----
  		if (net == in_ifsni[j].i_net) {
  #endif
  			net = i & in_ifsni[j].i_subnetmask;
! 			in_a.s_addr = htonl(net);
! 			if (inet_lnaof(in_a) == 0)
  				return (0);
  			else
  				return (net >> in_ifsni[j].i_bitshift);
***************
*** 228,234 ****
   */
  
  bsr(mask)
! 	register int	mask;
  {
  	register int	count = 0;
  
--- 235,241 ----
   */
  
  bsr(mask)
! 	register long	mask;
  {
  	register int	count = 0;
  
Technical Details
Message-ID: <FLEE.89Jul20134740@shire.cs.psu.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!psuvax1!flee

Show Full Headers
Complete Article Headers
Message-ID: <FLEE.89Jul20134740@shire.cs.psu.edu>
Subject: (1.5.5) nntpd dumps core on a Sun-4.
Date: Thu, 20 Jul 1989 17:47:40 +0000
From: flee@shire.cs.psu.edu (Felix Lee)
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!psuvax1!flee
Newsgroups: news.software.nntp
Sender: news@psuvax1.cs.psu.edu
Distribution: news
Organization: Penn State University Computer Science
Lines: 125