Use gcc -ansi -pedantic in 9c. Fix many non-C89-isms.

This commit is contained in:
rsc 2006-04-01 19:24:03 +00:00
parent 226d80b821
commit cbeb0b26e4
492 changed files with 3218 additions and 3167 deletions

View file

@ -148,7 +148,7 @@ struct ServerState
enum
{
APOPCHALLEN = 128,
APOPCHALLEN = 128
};
static int apopchal(ServerState*, int, char[APOPCHALLEN]);

View file

@ -143,7 +143,7 @@ hasqueries(Attr *a)
char *ignored[] = {
"role",
"disabled",
"disabled"
};
static int

View file

@ -33,7 +33,7 @@ enum {
MShashlen = 16,
MSchallen = 8,
MSresplen = 24,
MSresplen = 24
};
static int
@ -315,7 +315,7 @@ out:
keyclose(s.k);
free(user);
free(resp);
// xioclose(s.asfd);
/* xioclose(s.asfd); */
return ret;
}
@ -411,16 +411,17 @@ chaproles[] =
};
Proto chap = {
.name= "chap",
.roles= chaproles,
.checkkey= chapcheck,
.keyprompt= "user? !password?",
"chap",
chaproles,
"user? !password?",
chapcheck
};
Proto mschap = {
.name= "mschap",
.roles= chaproles,
.checkkey= chapcheck,
.keyprompt= "user? !password?",
"mschap",
chaproles,
"user? !password?",
chapcheck
};

View file

@ -56,7 +56,7 @@ struct AuthMethod {
{
{ "p9", p9auth, srvp9auth,},
{ "netkey", netkeyauth, netkeysrvauth,},
// { "none", noauth, srvnoauth,},
/* { "none", noauth, srvnoauth,}, */
{ nil, nil}
};
AuthMethod *am = authmethod; /* default is p9 */
@ -687,7 +687,7 @@ enum
Qdir,
Qcpunote,
Nfid = 32,
Nfid = 32
};
struct {
@ -697,7 +697,7 @@ struct {
} fstab[] =
{
[Qdir] { ".", {Qdir, 0, QTDIR}, DMDIR|0555 },
[Qcpunote] { "cpunote", {Qcpunote, 0}, 0444 },
[Qcpunote] { "cpunote", {Qcpunote, 0}, 0444 }
};
typedef struct Note Note;

View file

@ -17,7 +17,7 @@
static char *msg[] = {
"key",
"delkey",
"debug",
"debug"
};
static int

View file

@ -13,7 +13,7 @@ enum
RpcWriteHex,
/* thread stack size - big buffers for printing */
STACK = 65536,
STACK = 65536
};
typedef struct Conv Conv;

View file

@ -12,7 +12,7 @@ enum
Qlog,
Qctl,
Qneedkey,
Qconv,
Qconv
};
static int qtop;
@ -41,7 +41,7 @@ static struct
"rpc", Qrpc, 0666,
"proto", Qprotolist, 0444,
"log", Qlog, 0600|DMEXCL,
"conv", Qconv, 0400,
"conv", Qconv, 0400
};
static void

View file

@ -26,7 +26,7 @@ threadmain(int argc, char *argv[])
char *mtpt;
char err[ERRMAX];
// mtpt = "/mnt";
/* mtpt = "/mnt"; */
mtpt = nil;
owner = getuser();
quotefmtinstall();

View file

@ -15,7 +15,7 @@ extern Proto p9sk1, p9sk2, p9cr;
static Proto* okproto[] =
{
&p9sk1,
nil,
nil
};
static int
@ -267,6 +267,6 @@ p9anyroles[] =
Proto p9any = {
"p9any",
p9anyroles,
p9anyroles
};

View file

@ -197,7 +197,7 @@ out:
enum
{
MAXCHAL = 64,
MAXCHAL = 64
};
typedef struct State State;
@ -222,7 +222,7 @@ enum
SHaveChal,
SNeedResp,
Maxphase,
Maxphase
};
static char *phasenames[Maxphase] =
@ -231,7 +231,7 @@ static char *phasenames[Maxphase] =
[CHaveResp] "CHaveResp",
[SHaveChal] "SHaveChal",
[SNeedResp] "SNeedResp",
[SNeedResp] "SNeedResp"
};
static void
@ -525,7 +525,7 @@ Proto p9cr =
.write= p9crwrite,
.read= p9crread,
.close= p9crclose,
.keyprompt= "user? !password?",
.keyprompt= "user? !password?"
};
Proto vnc =
@ -536,5 +536,5 @@ Proto vnc =
.read= p9crread,
.close= p9crclose,
.keyprompt= "!password?",
.addkey= vncaddkey,
.addkey= vncaddkey
};

View file

@ -343,11 +343,11 @@ Proto p9sk1 = {
p9sk1roles,
"user? dom? !password?",
p9sk1check,
p9sk1close,
p9sk1close
};
Proto p9sk2 = {
"p9sk2",
p9sk2roles,
p9sk2roles
};

View file

@ -23,7 +23,7 @@ Proto *prototab[] = {
&p9sk2,
&pass,
&rsa,
nil,
nil
};
Proto*

View file

@ -41,7 +41,7 @@ char *rpcname[] =
"start",
"write",
"readhex",
"writehex",
"writehex"
};
static int

View file

@ -10,9 +10,9 @@
enum{ CHK = 16};
enum{ MAXFILESIZE = 10*1024*1024 };
enum{// PW status bits
enum{/* PW status bits */
Enabled = (1<<0),
STA = (1<<1), // extra SecurID step
STA = (1<<1) /* extra SecurID step */
};
static char testmess[] = "__secstore\tPAK\nC=%s\nm=0\n";
@ -75,28 +75,28 @@ havesecstore(void)
return strcmp((char*)buf, "!account exists") == 0;
}
// delimited, authenticated, encrypted connection
enum{ Maxmsg=4096 }; // messages > Maxmsg bytes are truncated
/* delimited, authenticated, encrypted connection */
enum{ Maxmsg=4096 }; /* messages > Maxmsg bytes are truncated */
typedef struct SConn SConn;
extern SConn* newSConn(int); // arg is open file descriptor
extern SConn* newSConn(int); /* arg is open file descriptor */
struct SConn{
void *chan;
int secretlen;
int (*secret)(SConn*, uchar*, int);//
int (*read)(SConn*, uchar*, int); // <0 if error; errmess in buffer
int (*secret)(SConn*, uchar*, int);/* */
int (*read)(SConn*, uchar*, int); /* <0 if error; errmess in buffer */
int (*write)(SConn*, uchar*, int);
void (*free)(SConn*); // also closes file descriptor
void (*free)(SConn*); /* also closes file descriptor */
};
// secret(s,b,dir) sets secret for digest, encrypt, using the secretlen
// bytes in b to form keys for the two directions;
// set dir=0 in client, dir=1 in server
/* secret(s,b,dir) sets secret for digest, encrypt, using the secretlen */
/* bytes in b to form keys for the two directions; */
/* set dir=0 in client, dir=1 in server */
// error convention: write !message in-band
/* error convention: write !message in-band */
#define readstr secstore_readstr
static void writerr(SConn*, char*);
static int readstr(SConn*, char*); // call with buf of size Maxmsg+1
// returns -1 upon error, with error message in buf
static int readstr(SConn*, char*); /* call with buf of size Maxmsg+1 */
/* returns -1 upon error, with error message in buf */
typedef struct ConnState {
uchar secret[SHA1dlen];
@ -105,8 +105,8 @@ typedef struct ConnState {
} ConnState;
typedef struct SS{
int fd; // file descriptor for read/write of encrypted data
int alg; // if nonzero, "alg sha rc4_128"
int fd; /* file descriptor for read/write of encrypted data */
int alg; /* if nonzero, "alg sha rc4_128" */
ConnState in, out;
} SS;
@ -123,7 +123,7 @@ SC_secret(SConn *conn, uchar *sigma, int direction)
hmac_sha1(sigma, nsigma, (uchar*)"two", 3, ss->out.secret, nil);
hmac_sha1(sigma, nsigma, (uchar*)"one", 3, ss->in.secret, nil);
}
setupRC4state(&ss->in.rc4, ss->in.secret, 16); // restrict to 128 bits
setupRC4state(&ss->in.rc4, ss->in.secret, 16); /* restrict to 128 bits */
setupRC4state(&ss->out.rc4, ss->out.secret, 16);
ss->alg = 1;
return 0;
@ -174,7 +174,7 @@ SC_read(SConn *conn, uchar *buf, int n)
werrstr("!SC_read invalid count");
return -1;
}
len = (count[0]&0x7f)<<8 | count[1]; // SSL-style count; no pad
len = (count[0]&0x7f)<<8 | count[1]; /* SSL-style count; no pad */
if(ss->alg){
len -= SHA1dlen;
if(len <= 0 || readn(ss->fd, digest, SHA1dlen) != SHA1dlen){
@ -328,7 +328,7 @@ getfile(SConn *conn, uchar *key, int nkey)
if((len = atoi(s)) < 0){
werrstr("secstore: remote file %s does not exist", gf);
return -1;
}else if(len > MAXFILESIZE){//assert
}else if(len > MAXFILESIZE){/*assert */
werrstr("secstore: implausible file size %d for %s", len, gf);
return -1;
}
@ -400,7 +400,7 @@ typedef struct PAKparams{
static PAKparams *pak;
// This group was generated by the seed EB7B6E35F7CD37B511D96C67D6688CC4DD440E1E.
/* This group was generated by the seed EB7B6E35F7CD37B511D96C67D6688CC4DD440E1E. */
static void
initPAKparams(void)
{
@ -422,8 +422,8 @@ initPAKparams(void)
"2A6E0BAE08B14258F8C03CC1B30E0DDADFCF7CEDF0727684D3D255F1", nil, 16, nil);
}
// H = (sha(ver,C,sha(passphrase)))^r mod p,
// a hash function expensive to attack by brute force.
/* H = (sha(ver,C,sha(passphrase)))^r mod p, */
/* a hash function expensive to attack by brute force. */
static void
longhash(char *ver, char *C, uchar *passwd, mpint *H)
{
@ -449,7 +449,7 @@ longhash(char *ver, char *C, uchar *passwd, mpint *H)
mpexp(H, pak->r, pak->p, H);
}
// Hi = H^-1 mod p
/* Hi = H^-1 mod p */
static char *
PAK_Hi(char *C, char *passphrase, mpint *H, mpint *Hi)
{
@ -462,8 +462,8 @@ PAK_Hi(char *C, char *passphrase, mpint *H, mpint *Hi)
return mptoa(Hi, 64, nil, 0);
}
// another, faster, hash function for each party to
// confirm that the other has the right secrets.
/* another, faster, hash function for each party to */
/* confirm that the other has the right secrets. */
static void
shorthash(char *mess, char *C, char *S, char *m, char *mu, char *sigma, char *Hi, uchar *digest)
{
@ -485,12 +485,12 @@ shorthash(char *mess, char *C, char *S, char *m, char *mu, char *sigma, char *Hi
sha1((uchar*)Hi, strlen(Hi), digest, state);
}
// On input, conn provides an open channel to the server;
// C is the name this client calls itself;
// pass is the user's passphrase
// On output, session secret has been set in conn
// (unless return code is negative, which means failure).
// If pS is not nil, it is set to the (alloc'd) name the server calls itself.
/* On input, conn provides an open channel to the server; */
/* C is the name this client calls itself; */
/* pass is the user's passphrase */
/* On output, session secret has been set in conn */
/* (unless return code is negative, which means failure). */
/* If pS is not nil, it is set to the (alloc'd) name the server calls itself. */
static int
PAKclient(SConn *conn, char *C, char *pass, char **pS)
{
@ -503,7 +503,7 @@ PAKclient(SConn *conn, char *C, char *pass, char **pS)
hexHi = PAK_Hi(C, pass, H, Hi);
// random 1<=x<=q-1; send C, m=g**x H
/* random 1<=x<=q-1; send C, m=g**x H */
x = mprand(164, genrandom, nil);
mpmod(x, pak->q, x);
if(mpcmp(x, mpzero) == 0)
@ -517,7 +517,7 @@ PAKclient(SConn *conn, char *C, char *pass, char **pS)
snprint(mess, Maxmsg, "%s\tPAK\nC=%s\nm=%s\n", VERSION, C, hexm);
conn->write(conn, (uchar*)mess, strlen(mess));
// recv g**y, S, check hash1(g**xy)
/* recv g**y, S, check hash1(g**xy) */
if(readstr(conn, mess) < 0){
fprint(2, "error: %s\n", mess);
writerr(conn, "couldn't read g**y");
@ -556,18 +556,18 @@ PAKclient(SConn *conn, char *C, char *pass, char **pS)
goto done;
}
// send hash2(g**xy)
/* send hash2(g**xy) */
shorthash("client", C, S, hexm, hexmu, hexsigma, hexHi, digest);
enc64(kc, sizeof kc, digest, SHA1dlen);
snprint(mess2, Maxmsg, "k'=%s\n", kc);
conn->write(conn, (uchar*)mess2, strlen(mess2));
// set session key
/* set session key */
shorthash("session", C, S, hexm, hexmu, hexsigma, hexHi, digest);
memset(hexsigma, 0, strlen(hexsigma));
n = conn->secret(conn, digest, 0);
memset(digest, 0, SHA1dlen);
if(n < 0){//assert
if(n < 0){/*assert */
writerr(conn, "can't set secret");
goto done;
}

View file

@ -41,7 +41,7 @@ Test test[] =
"cram", proxyserver, proxyclient,
"p9sk1", proxyserver, proxyclient,
"p9sk2", proxyserver, proxyclient,
"p9any", proxyserver, proxyclient,
"p9any", proxyserver, proxyclient
};
void