]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
mlmmj-send: accept file descriptor number as -s argument
authorBaptiste Daroussin <bapt@FreeBSD.org>
Tue, 7 Mar 2023 17:05:56 +0000 (18:05 +0100)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Tue, 7 Mar 2023 17:11:09 +0000 (18:11 +0100)
ChangeLog
src/mlmmj-send.c

index 0ebd4877ef626726de7fdd1a91de6644dcccee63..803e5c15819d9737ff66ff43582f896a7498850f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 1.4.0-a3
  o Fix a potential crash with mail without separator between headers and body
+ o mlmmj-send: accept file descriptor number as -s argument
 1.4.0-a2
  o Fix a crash with forged probe emails
  o mlmmj-send does not need anymore absolute path
index 28c530fedf7fa38518d6dcbac738813b1d8c4885..bd3c10034bf6edbdec572c4ada112b6677d76a5d 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <sys/limits.h>
 #include <unistd.h>
 #include <errno.h>
 #include <string.h>
@@ -386,6 +387,7 @@ int main(int argc, char **argv)
        struct mail mail = { 0 };
        struct ml ml;
        int subdirfd, mailfd;
+       const char *errp;
 
        log_set_name(argv[0]);
        ml_init(&ml);
@@ -506,7 +508,8 @@ int main(int argc, char **argv)
                mail.addtohdr = statctrl(ml.ctrlfd, "addtohdr");
                /* FALLTHROUGH */
        case '4': /* sending mails to subfile */
-               if((subfd = open(subfilename, O_RDONLY)) < 0) {
+               subfd = strtoim(subfilename, 0, INT_MAX, &errp);
+               if (errp != NULL && (subfd = open(subfilename, O_RDONLY)) < 0) {
                        log_error(LOG_ARGS, "Could not open '%s':",
                                            subfilename);
                        exit(EXIT_FAILURE);