[OpenAFS-devel] Possible bug rx_getaddr.c with memset

Mark Huijgen mark@nl.simpc.com
Wed, 11 Oct 2006 15:40:47 +0200


openafs-1.4.1/src/rx/rx_getaddr.c line 303-305
             maskBuffer[count] = htonl(0xffffffff);
             memset(&ifr, sizeof(ifr), 0);
             ifr.ifr_addr.sa_family = AF_INET;

Description of memset:
-------------------------------------------
NAME
        memset - fill memory with a constant byte

SYNOPSIS
        #include <string.h>

        void *memset(void *s, int c, size_t n);

DESCRIPTION
        The  memset() function fills the first n bytes of the memory 
area pointed to by s with the constant byte c.
--------------------------------------------

So this codes fills 0 bytes of &ifr with the value sizeof(ifr)
Shouldnt this be:
	memset(&ifr, 0, sizeof(ifr));

Credits go to
http://www.kottke.org/06/10/google-code-search, last example Programming 
errors :
http://www.google.com/codesearch?hl=en&lr=&q=memset%5Cs*%5C%28.%2B%2C%5Cs*0%5Cs*%5C%29&btnG=Search

Version 1.5.8 contains this exact same issue.

Regards,
Mark