Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to compile ecepass.c

Tags:

c

gcc

freebsd

I can not for the life of me compile this old code. I'm attempting to use it to test external vulnerabilities for a client. I have it running in FreeBSD 11 and compiling with gcc. Any idea why I'm getting this error?

int in_cksum(u_short *addr, int len)
{
    int sum;
    int nleft;
    u_short ans;
    u_short *w;

    sum = 0;
    ans = 0;
    nleft = len;
    w = addr;

    while (nleft > 1) {
      sum += *w++;
      nleft -= 2;
    }
    if (nleft == 1) {
      *(u_char *)(&ans) = *(u_char *)w;
       sum += ans;
    }
    return (sum);
}

Full code here: https://pastebin.com/MGSYycmB

Error:

In file included from ecepass.c:8:0: ecepass.c:72:5: error: expected declaration specifiers or '...' before numeric constant int in_cksum(u_short *addr, int len)

like image 405
sethh Avatar asked Nov 30 '25 05:11

sethh


1 Answers

In the code posted on PasteBin, at line #8 (and #24 :d) there's the statement: #include <machine/in_cksum.h>

As I'm not on Nix, I've searched the file on Internet and found 2 references:

  • [GitHub]: osv/bsd/x64/machine/in_cksum.h
  • [RTEMS]: source:rtems-libbsd/freebsd/sys/arm/include/machine/in_cksum.h @ ffcd542

In both of them (around line #40+), seems like in_cksum is a preprocessor macro:

#define in_cksum(m, len)        in_cksum_skip(m, len, 0)

Change the name of your function (and all the places in your code that reference it) to something that's not a macro, or another defined identifier as a matter of fact, e.g. checksum (hopefully it's not already defined :) ), and you should be fine (might apply to other of your functions as well).
Or as an alternative, remove the machine/in_cksum.h inclusion (direct and indirect (via other nested includes)), but this might get a little bit more difficult (also, I didn't check all the code to see if other functions from the include are used).

like image 181
CristiFati Avatar answered Dec 02 '25 21:12

CristiFati



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!