debian/changelog: Prepare for next minor version.
[catacomb] / progs / cookie.c
index 56849e5..62e23b7 100644 (file)
 #include <mLib/base64.h>
 #include <mLib/bits.h>
 #include <mLib/dstr.h>
+#include <mLib/macros.h>
 #include <mLib/mdwopt.h>
 #include <mLib/quis.h>
 #include <mLib/report.h>
 #include <mLib/sub.h>
 
 #include "cc.h"
+#include "ct.h"
 #include "key.h"
 #include "gmac.h"
 #include "getdate.h"
@@ -79,7 +81,7 @@ typedef struct cookie {
   octet *_p = (octet *)(p);                                            \
   const cookie *_c = (c);                                              \
   STORE32(_p + 0, _c->k);                                              \
-  STORE32(_p + 4, ((_c->exp & ~MASK32) >> 16) >> 16);                  \
+  STORE32(_p + 4, ((_c->exp & ~(unsigned long)MASK32) >> 16) >> 16);   \
   STORE32(_p + 8, _c->exp);                                            \
 } while (0)
 
@@ -96,7 +98,8 @@ typedef struct cookie {
   cookie *_c = (c);                                                    \
   const octet *_p = (const octet *)(p);                                        \
   _c->k = LOAD32(_p + 0);                                              \
-  _c->exp = ((time_t)(((LOAD32(_p + 4) << 16) << 16) & ~MASK32) |      \
+  _c->exp = ((time_t)(((LOAD32(_p + 4) << 16) << 16) &                 \
+                     ~(unsigned long)MASK32) |                         \
             (time_t)LOAD32(_p + 8));                                   \
 } while (0)
 
@@ -176,7 +179,7 @@ static gmac *getmac(key *k, const char *app)
   if ((q = key_getattr(0, k, "mac")) != 0) {
     dstr_puts(&d, q);
     p = d.buf;
-  } else if (strncmp(k->type, app, n) == 0 && k->type[n] == '-') {
+  } else if (STRNCMP(k->type, ==, app, n) && k->type[n] == '-') {
     dstr_puts(&d, k->type);
     p = d.buf + n + 1;
   } else
@@ -256,7 +259,7 @@ static int cmd_gen(int argc, char *argv[])
       /* --- Fetch an expiry time --- */
 
       case 'e':
-       if (strcmp(optarg, "forever") == 0)
+       if (STRCMP(optarg, ==, "forever"))
          c.exp = KEXP_FOREVER;
        else if ((c.exp = get_date(optarg, 0)) == -1)
          die(EXIT_FAILURE, "bad expiry date: `%s'", optarg);
@@ -485,7 +488,7 @@ static int cmd_verify(int argc, char *argv[])
     GH_HASH(h, argv[optind + 1], strlen(argv[optind + 1]));
   t = GH_DONE(h, 0);
 
-  if (memcmp(t, d.buf + COOKIE_SZ, cbits / 8) != 0) {
+  if (!ct_memeq(t, d.buf + COOKIE_SZ, cbits / 8)) {
     if (v) printf("FAIL bad authentication token\n");
     goto fail;
   }