🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #35306

Re: nnrpd daemon (-D) mode fixes

#35306
From: Forrest J. Cavalier III
Date: Wed, 10 Feb 1999 00:00
34 lines
2004 bytes
In article <79smvr$7ni8$1@newssvr04-int.news.prodigy.com>, davidsen@tmr.com wrote...
>
>In article <873e4kprj6.fsf@erlenstar.demon.co.uk>,
>Andrew Gierth  <andrew@erlenstar.demon.co.uk> wrote:
[snip]
>| The original code was correct in this respect. This is why accept()
>| et. al. have an additional size parameter for the address. The cast is
>| something of a historical crock, but is nevertheless correct.
>
>When a procedure prototype requires a struct of one type, and you
>provide a struct of another type which mayor may not be the same size
>on every system, using a cast is not "correct." What is correct is to
>declare the struct of the proper type in the first place. It's used
>only in one place, so this is not "clever" use of an existing struct to
>save space, it's just the wrong type struct.
>
>Pardon my asking, but are you new to writing portable code or
>something?

Bill, maybe you can think of it this way:

The accept() function properly handles a number of sockaddr_
types. If it were C++, the problem would be solved by inherited
classes.  

Bill, your "corrected" code fails if a sizeof(sockaddr_in) is
larger than sizeof(sockaddr).  (What should happen is that
accept() would see a wrong length member and return an error.)


Forrest


Technical Details
Message-ID: <79t2ms$iil$1@news1.epix.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
References: <79eufj$7nh0$1@newssvr04-int.news.prodigy.com> <873e4kprj6.fsf@erlenstar.demon.co.uk> <79smvr$7ni8$1@newssvr04-int.news.prodigy.com>

Show Full Headers
Complete Article Headers
Message-ID: <79t2ms$iil$1@news1.epix.net>
Subject: Re: nnrpd daemon (-D) mode fixes
Date: Wed, 10 Feb 1999 00:00:00 +0000
From: mibsoft@mibsoftware.com (Forrest J. Cavalier III)
References: <79eufj$7nh0$1@newssvr04-int.news.prodigy.com> <873e4kprj6.fsf@erlenstar.demon.co.uk> <79smvr$7ni8$1@newssvr04-int.news.prodigy.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 442992687
Content-Type: Text/Plain; charset=US-ASCII
Organization: Mib Software
Mime-Version: 1.0
Newsgroups: news.software.nntp