#5 socket() returns -1 if it fails, not 0.

closed-fixed
nobody
None
5
2004-11-15
2004-11-10
Bjorn Augestad
No

Below is a code snippet where you have a bug:

void host_unreachable(ipt destination, u16 id, ipt
source, char *packet, int packet_len)
{
char buf[128] = {0};
struct iphdr *iph;
struct icmphdr *icmp;
char *data;
int len = 0, on = 1, icmp_socket;
struct sockaddr_in whereto = {0};

if (!(icmp_socket = socket(AF_INET, SOCK_RAW,
IPPROTO_RAW)))
return;

I guess the summary says it all, socket() returns -1 if
it fails.

HTH
boa

Discussion

  • Brendan O'Dea
    Brendan O'Dea
    2004-11-15

    Logged In: YES
    user_id=976467

    Fixed in CVS, thanks.

     
  • Brendan O'Dea
    Brendan O'Dea
    2004-11-15

    • status: open --> closed-fixed