X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/0f00dc4c8eb47e67bc0f148c2dd109f73a451e0a..1519ef6617fd7351bd40026b9eeb47c7f7f42234:/progs/dsig.c diff --git a/progs/dsig.c b/progs/dsig.c index 5e5a3cfe..3f217da6 100644 --- a/progs/dsig.c +++ b/progs/dsig.c @@ -39,6 +39,7 @@ #include #include +#include #include #include #include @@ -204,7 +205,7 @@ static int bget(block *b, FILE *fp, unsigned bin) if (getstring(fp, &d, GSF_FILE)) return (E_EOF); for (tag = 0; tagtab[tag]; tag++) { - if (strcmp(tagtab[tag], d.buf) == 0) + if (STRCMP(tagtab[tag], ==, d.buf)) goto done; } return (E_TAG); @@ -233,12 +234,13 @@ static int bget(block *b, FILE *fp, unsigned bin) octet buf[8]; if (fread(buf, sizeof(buf), 1, fp) < 1) return (E_EOF); - b->t = ((time_t)(((LOAD32(buf + 0) << 16) << 16) & ~MASK32) | + b->t = ((time_t)(((LOAD32(buf + 0) << 16) << 16) & + ~(unsigned long)MASK32) | (time_t)LOAD32(buf + 4)); } else { if (getstring(fp, &b->d, GSF_FILE)) return (E_EOF); - if (strcmp(b->d.buf, "forever") == 0) + if (STRCMP(b->d.buf, ==, "forever")) b->t = KEXP_FOREVER; else if ((b->t = get_date(b->d.buf, 0)) == -1) return (E_DATE); @@ -325,7 +327,8 @@ static void blob(block *b, dstr *d) STORE32(d->buf + d->len, 0xffffffff); STORE32(d->buf + d->len + 4, 0xffffffff); } else { - STORE32(d->buf + d->len, ((b->t & ~MASK32) >> 16) >> 16); + STORE32(d->buf + d->len, + ((b->t & ~(unsigned long)MASK32) >> 16) >> 16); STORE32(d->buf + d->len + 4, b->t); } d->len += 8; @@ -534,7 +537,7 @@ static int sign(int argc, char *argv[]) ki = optarg; break; case 'e': - if (strcmp(optarg, "forever") == 0) + if (STRCMP(optarg, ==, "forever")) exp = KEXP_FOREVER; else if ((exp = get_date(optarg, 0)) == -1) die(EXIT_FAILURE, "bad expiry time"); @@ -570,14 +573,14 @@ static int sign(int argc, char *argv[]) /* --- Open files --- */ if (hfile) ifile = hfile; - if (!ifile || strcmp(ifile, "-") == 0) + if (!ifile || STRCMP(ifile, ==, "-")) ifp = stdin; else if ((ifp = fopen(ifile, (f & f_bin) ? "rb" : "r")) == 0) { die(EXIT_FAILURE, "couldn't open input file `%s': %s", ifile, strerror(errno)); } - if (!ofile || strcmp(ofile, "-") == 0) + if (!ofile || STRCMP(ofile, ==, "-")) ofp = stdout; else if ((ofp = fopen(ofile, (f & f_bin) ? "wb" : "w")) == 0) { die(EXIT_FAILURE, "couldn't open output file `%s': %s", @@ -906,7 +909,7 @@ static int verify(int argc, char *argv[]) } f |= f_bogus; } else if (b.b.len != GH_CLASS(s->h)->hashsz || - memcmp(d.buf, b.b.buf, b.b.len) != 0) { + MEMCMP(d.buf, !=, b.b.buf, b.b.len)) { if (verb > 1) printf("BAD file `%s' has incorrect hash\n", b.d.buf); f |= f_bogus;