recvfrom bug?

From: Ferenc Tamas Gyurcsan (gyurex@brian.vpszk.bme.hu)
Date: Sun Mar 12 2000 - 17:08:47 EST


Hi Smartfolks,

I was trying to use recvfrom with udp sockets, but it doesn't seem to
return the address where the message came from.
Here is my code snippet, in case the problem is with me:

   (int *buf is in the function header...)
    struct sockaddr addr1;
    int retval=0;
    fprintf(stderr,"\nBefore in Buffer = %d",*buf);
    fprintf(stderr,"\nBefore in socketaddress\n");
    /*well, just for this test, quickly, not the best, I know*/
    for (int cou=0;cou<16;cou++)
        fprintf(stderr," %d",*((char *)((&addr1)+cou)));

    if ((retval = recvfrom(s,buf,n,mode,&addr1,length_ptr)) < 0)
        return(-1);

    fprintf(stderr,"\nAfter in Buffer = %d",*buf);
    fprintf(stderr,"\nAfter in socketaddress (retval=%d)
                    (length=%d)\n",retval,*length_ptr);
    for (int cou=0;cou<16;cou++)
        fprintf(stderr,"%d ",*((char *)((&addr1)+cou)));

And the output is:

Before in Buffer = 0
Before in socketaddress
 0 -96 4 -72 16 32 0 0 0 0 0 0 0 0 0 8

After in Buffer = 1
After in socketaddress (retval=4)(length=16)
 0 -96 4 -72 16 32 0 0 0 0 0 0 0 0 0 8

So buffer is overwritten, the length=16, but the address seems to be the
same. Kernel:2.2.13.

Ferenc

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Mar 15 2000 - 21:00:22 EST