]> git.netwichtig.de Git - user/henk/code/exim.git/blobdiff - src/src/dkim.c
Fix log line corruption for DKIM status
[user/henk/code/exim.git] / src / src / dkim.c
index f0dfb8af3e23e1069c2084d6cff2580c8fcdb7c9..03efb18d4c88de1b5dbd1c6f6fcbc3a93b8ea7c1 100644 (file)
@@ -169,12 +169,12 @@ for (sig = dkim_signatures; sig; sig = sig->next)
                : sig->algo == PDKIM_ALGO_RSA_SHA1 ? "rsa-sha1" : "err",
        string_sprintf(" b=%d",
                        (int)sig->sighash.len > -1 ? sig->sighash.len * 8 : 0));
-  if ((s= sig->identity)) string_append(logmsg, &size, &ptr, 2, " i=", s);
-  if (sig->created > 0) string_append(logmsg, &size, &ptr, 1,
+  if ((s= sig->identity)) logmsg = string_append(logmsg, &size, &ptr, 2, " i=", s);
+  if (sig->created > 0) logmsg = string_append(logmsg, &size, &ptr, 1,
                                      string_sprintf(" t=%lu", sig->created));
-  if (sig->expires > 0) string_append(logmsg, &size, &ptr, 1,
+  if (sig->expires > 0) logmsg = string_append(logmsg, &size, &ptr, 1,
                                      string_sprintf(" x=%lu", sig->expires));
-  if (sig->bodylength > -1) string_append(logmsg, &size, &ptr, 1,
+  if (sig->bodylength > -1) logmsg = string_append(logmsg, &size, &ptr, 1,
                                      string_sprintf(" l=%lu", sig->bodylength));
 
   switch (sig->verify_status)
@@ -625,11 +625,12 @@ while ((dkim_signing_domain = string_nextinlist(&dkim_domain, &sep, NULL, 0)))
   if (prefix)
     pdkim_feed(ctx, prefix, Ustrlen(prefix));
 
-  lseek(fd, off, SEEK_SET);
-
-  while ((sread = read(fd, &buf, sizeof(buf))) > 0)
-    if ((pdkim_rc = pdkim_feed(ctx, buf, sread)) != PDKIM_OK)
-      goto pk_bad;
+  if (lseek(fd, off, SEEK_SET) < 0)
+    sread = -1;
+  else
+    while ((sread = read(fd, &buf, sizeof(buf))) > 0)
+      if ((pdkim_rc = pdkim_feed(ctx, buf, sread)) != PDKIM_OK)
+       goto pk_bad;
 
   /* Handle failed read above. */
   if (sread == -1)