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)
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:
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With