Thread: recvfrom():: Bad address

  1. #1
    Registered User
    Join Date
    Aug 2009

    recvfrom():: Bad address

    Im not sure if you need more code but
    struct Ethfrm_t
    	struct FCfrm_t* ptr;
    	unsigned char DestEthAdr[6];
    	unsigned char SrcEthAdr[6];
    	UINT32  VLAN_HdrSave;
    	//unsigned char  reserved[4];
    	void* buffer;
    }  __attribute__ ((packed));
    Ethfrm_t* Ethfrm;
    Ethfrm = malloc(sizeof(Ethfrm));
    Ethfrm->buffer = (void*)malloc(BUF_SIZE); 	/*Buffer for Ethernet Frame*/
    length = recvfrom(s, Ethfrm->buffer, BUF_SIZE, 0, NULL, NULL);
    		if (length == -1) {
    This works but when i uncomment the unsigned char reserved i get the BAD ADDRESS error after like 2 seconds of the server running Im not really sure what that means or how to fix it?

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Portland, OR
    Quote Originally Posted by kiros88 View Post
    Ethfrm = malloc(sizeof(Ethfrm));
    Should be

    Ethfrm = malloc(sizeof(*Ethfrm));
    You're only allocating a pointer's worth of space.
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. address out of bounds in sockets program
    By newbie_socketsp in forum Networking/Device Communication
    Replies: 2
    Last Post: 08-05-2008, 06:41 AM
  2. Finding memory address using memory pattern
    By MindWorX in forum C++ Programming
    Replies: 1
    Last Post: 05-25-2008, 07:20 AM
  3. Memory leaks problem in C -- Help please
    By Amely in forum C Programming
    Replies: 14
    Last Post: 05-21-2008, 11:16 AM
  4. Identify dynamic IP address of network device
    By BobS0327 in forum Tech Board
    Replies: 2
    Last Post: 02-21-2006, 01:49 PM
  5. Shocking(kind of)
    By Shadow in forum A Brief History of
    Replies: 25
    Last Post: 12-10-2002, 08:52 PM