Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Dec 2002 16:56:58 +0100 (CET)
From:      Alain Thivillon <at@rominet.net>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        at@rominet.net, roberto@keltia.freenix.org
Subject:   bin/46165: call to getsockopt in libc/gen/getpeerid is bogus
Message-ID:  <20021210155658.51199F6A68@khany.hsc.fr>

next in thread | raw e-mail | index | archive | help

>Number:         46165
>Category:       bin
>Synopsis:       call to getsockopt in libc/gen/getpeerid is bogus
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Dec 10 08:00:07 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Alain Thivillon
>Release:        FreeBSD 4.7-RELEASE-p2 i386
>Organization:
Rominet Networks
>Environment:
System: FreeBSD khany.hsc.fr 4.7-RELEASE-p2 FreeBSD 4.7-RELEASE-p2 #1: Sat Nov 30 14:37:59 CET 2002 at@khany.hsc.fr:/usr/obj/usr/src/sys/KHANY i386


>Description:

  call to getsockopt in libc/gen/getpeerid to get Unix Dgram socket 
  caller credentials is wrong. Option name LOCAL_PEERCRED is passed
  in second argument instead of third.
  
  As LOCAL_PEERCRED == SOCK_STREAM == 1, this bug has no influence.
  However, this is the only one usage of LOCAL_PEERCRED in /usr/src,
  this can seriously impact mental health of programmers looking for an
  example ...

>How-To-Repeat:

  Read code and documentation (getsockopt(2) and unix(4) on the same screen.

>Fix:


--- src/lib/libc/gen/getpeereid.c.orig	Sat Mar  9 06:23:56 2002
+++ src/lib/libc/gen/getpeereid.c	Tue Dec 10 16:49:00 2002
@@ -43,7 +43,7 @@
 	int error;
 
 	xuclen = sizeof(xuc);
-	error = getsockopt(s, LOCAL_PEERCRED, 1, &xuc, &xuclen);
+	error = getsockopt(s, SOCK_STREAM, LOCAL_PEERCRED, &xuc, &xuclen);
 	if (error != 0)
 		return (error);
 	if (xuc.cr_version != XUCRED_VERSION)

>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021210155658.51199F6A68>