[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: use socklen_t in talk(1)



Does noone read this anymore?

> Return-Path: owner-bugs+M5179@openbsd.org
> Delivery-Date: Mon Mar  1 17:45:40 2004
> Received: from openbsd.cs.colorado.edu (openbsd.cs.colorado.edu [128.138.207.242])
> 	by cvs.openbsd.org (8.12.11/8.12.1) with ESMTP id i220jdiC013281
> 	(version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=FAIL);
> 	Mon, 1 Mar 2004 17:45:40 -0700 (MST)
> Received: from openbsd.org (localhost.cs.colorado.edu [127.0.0.1])
> 	by openbsd.cs.colorado.edu (8.12.11/8.12.10) with ESMTP id i220ieTs006261;
> 	Mon, 1 Mar 2004 17:44:42 -0700 (MST)
> Received: from frontend4.aha.ru (virtmail4.aha.ru [195.2.83.183])
> 	by openbsd.cs.colorado.edu (8.12.11/8.12.10) with ESMTP id i220hZTP022040
> 	for <bugs@openbsd.org>; Mon, 1 Mar 2004 17:43:36 -0700 (MST)
> Received: from [194.226.217.217] (HELO news.degunino.net)
> 	by frontend4.aha.ru (CommuniGate Pro SMTP 4.1.8) with SMTP id 224882328
> 	for bugs@openbsd.org; Tue, 02 Mar 2004 01:43:27 +0300
> Received: (qmail 3031 invoked from network); 1 Mar 2004 22:45:47 -0000
> Received: from unknown (HELO midian.korovino.net) (192.168.131.216)
> 	by mailserver.degunino.net with SMTP; 1 Mar 2004 22:45:47 -0000
> Received: from midian.korovino.net (localhost [127.0.0.1])
> 	by midian.korovino.net (8.12.11/8.12.10) with ESMTP id i21Mb0eM012796 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=NO); Tue, 2 Mar 2004 01:37:00 +0300 (MSK)
> Received: (from andrushock@localhost)
> 	by midian.korovino.net (8.12.11/8.12.10/Submit) id i21MatTa023632; Tue, 2 Mar 2004 01:36:55 +0300 (MSK)
> Date: Tue, 2 Mar 2004 01:36:54 +0300
> From: Andrey Matveev <andrushock@korovino.net>
> To: bugs@openbsd.org
> Cc: andrushock@korovino.net
> Subject: use socklen_t in talk(1)
> Message-ID: <20040301223654.GA10662@midian.korovino.net>
> Mime-Version: 1.0
> Content-Type: text/plain; charset=koi8-r
> Content-Disposition: inline
> X-Loop: bugs@openbsd.org
> Precedence: list
> Sender: owner-bugs@openbsd.org
> 
> Changes the following:
> 
> 	- for storage of lengths of structures of addresses of
> 	  sockets we use type socklen_t instead of int
> 	  (and suppress pointer signedness warn's when compile
> 	  with CFLAGS+=-pedantic);
> 
> 	- correct check on socket() failure (in case of error
> 	  socket() returns `-1', otherwise the the return value
> 	  is non-negative number).
> 
> --- usr.bin/talk/ctl.c.orig	Tue Mar  2 01:21:33 2004
> +++ usr.bin/talk/ctl.c	Tue Mar  2 01:22:45 2004
> @@ -66,12 +66,12 @@
>  void
>  open_sockt(void)
>  {
> -	int length;
> +	socklen_t length;
>  
>  	my_addr.sin_addr = my_machine_addr;
>  	my_addr.sin_port = 0;
>  	sockt = socket(AF_INET, SOCK_STREAM, 0);
> -	if (sockt <= 0)
> +	if (sockt < 0)
>  		quit("Bad socket", 1);
>  	if (bind(sockt, (struct sockaddr *)&my_addr, sizeof(my_addr)) != 0)
>  		quit("Binding local socket", 1);
> @@ -84,12 +84,12 @@
>  void
>  open_ctl(void)
>  {
> -	int length;
> +	socklen_t length;
>  
>  	ctl_addr.sin_port = 0;
>  	ctl_addr.sin_addr = my_machine_addr;
>  	ctl_sockt = socket(AF_INET, SOCK_DGRAM, 0);
> -	if (ctl_sockt <= 0)
> +	if (ctl_sockt < 0)
>  		quit("Bad socket", 1);
>  	if (bind(ctl_sockt,
>  	    (struct sockaddr *)&ctl_addr, sizeof(ctl_addr)) != 0)
> --- usr.bin/talk/invite.c.orig	Tue Mar  2 01:22:57 2004
> +++ usr.bin/talk/invite.c	Tue Mar  2 01:24:20 2004
> @@ -70,7 +70,7 @@
>  	struct itimerval itimer;
>  	CTL_RESPONSE response;
>  	struct sockaddr rp;
> -	int rplen = sizeof(struct sockaddr);
> +	socklen_t rplen;
>  	struct hostent *rphost;
>  	char rname[STRING_LENGTH];
>  
> @@ -101,6 +101,7 @@
>  	message("Waiting for your party to respond");
>  	signal(SIGALRM, re_invite);
>  	(void) setjmp(invitebuf);
> +	rplen = sizeof(struct sockaddr);
>  	while ((new_sockt = accept(sockt, &rp, &rplen)) < 0) {
>  		if (errno == EINTR || errno == ECONNABORTED)
>  			continue;