On 5/10/14, Ted Unangst <t...@tedunangst.com> wrote: > On Fri, May 09, 2014 at 22:20, patrick keshishian wrote: >> Ted, what is the purpose of the first if-statement >> in readident()? >> >> static char * >> readident(char *buf, char *ident) >> { >> if (IDENTLEN != 64) >> errx(1, "wrong IDENTLEN"); > > If somebody changes IDENTLEN, it will break the sscanf on the next line.
would it be better as a compile time error? --- reop.c.orig Sat May 10 12:21:30 2014 +++ reop.c Sat May 10 12:27:16 2014 @@ -59,7 +59,10 @@ #define EKCALG "eS" /* ephemeral-curve25519-Salsa20 */ #define SYMALG "SP" /* Salsa20-Poly1305 */ #define KDFALG "BK" /* bcrypt kdf */ -#define IDENTLEN 64 +#define IDENTLEN 64 /* Do NOT change. See readident() */ +#if IDENTLEN != 64 +#error wrong IDENTLEN +#endif #define FPLEN 8 /* metadata */ @@ -434,8 +437,6 @@ gethomefile(const char *filename) static char * readident(char *buf, char *ident) { - if (IDENTLEN != 64) - errx(1, "wrong IDENTLEN"); if (sscanf(buf, "ident:%63s", ident) != 1) errx(1, "no ident found: %s", buf); if (!(buf = strchr(buf + 1, '\n')))