More precaution about arbitrary console output
[infodrom/newmail] / mbox.c
diff --git a/mbox.c b/mbox.c
index 4f9d2a6..5860abb 100644 (file)
--- a/mbox.c
+++ b/mbox.c
@@ -217,14 +217,18 @@ int inspect_mbox(char *path, char *prefix, off_t size, int opt_flags)
     if (inheader) {
       if (strlen(buf) == 0) {
        inheader = 0;
-       newmail = 1;
 
        if (strlen(from))
          stringcopy (realfrom, realname(from), sizeof(realfrom));
-       else
+       else if (strlen(from_))
          stringcopy (realfrom, reduce_from_(from_), sizeof(realfrom));
+       else
+         realfrom[0] = '\0';
 
-       emit (prefix, realfrom, subject, priority, opt_flags);
+       if (realfrom[0] != '\0' || subject[0] != '\0') {
+         emit (prefix, realfrom, subject, priority, opt_flags);
+         newmail = 1;
+       }
 
 #ifdef FROM_DETECTION
        from_[0] = from[0] = to[0] = subject[0] = '\0';