]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
modern C: use O_APPEND instead of open+lseek
authorBaptiste Daroussin <bapt@FreeBSD.org>
Thu, 20 Oct 2022 11:14:45 +0000 (13:14 +0200)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Thu, 20 Oct 2022 11:14:45 +0000 (13:14 +0200)
src/mlmmj-sub.c
src/send_list.c

index 5c8c1aefe06d374db2ac5687cd7f6c2fc8675e19..7d46f5b0dc71cda456b34852e70a0c9adba9d7dd 100644 (file)
@@ -613,7 +613,7 @@ static void subscribe_type(char *listdir, char *listaddr, char *listdelim,
                exit(EXIT_FAILURE);
        }
 
-       subfilefd = open(subfilename, O_RDWR|O_CREAT,
+       subfilefd = open(subfilename, O_RDWR|O_CREAT|O_APPEND,
                                S_IRUSR|S_IWUSR|groupwritable);
        if(subfilefd == -1) {
                log_error(LOG_ARGS, "Could not open '%s'", subfilename);
@@ -630,7 +630,6 @@ static void subscribe_type(char *listdir, char *listaddr, char *listdelim,
                exit(EXIT_FAILURE);
        }
 
-       lseek(subfilefd, 0L, SEEK_END);
        len = strlen(address);
        address[len] = '\n';
        writen(subfilefd, address, len + 1);
index 7c7b5daee7a41ffa09778e692444a7f10354d12e..73648119e729c9d3b7bea8a4ec824085d820862a 100644 (file)
@@ -196,15 +196,11 @@ void send_list(const char *listdir, const char *emailaddr,
        /* DEPRECATED */
        /* Add lists manually if they weren't encountered in the list text */
        if (!normalsls->used && !digestsls->used && !nomailsls->used) {
-               fd = open(queuefilename, O_WRONLY);
+               fd = open(queuefilename, O_WRONLY|O_APPEND);
                if(fd < 0) {
                        log_error(LOG_ARGS, "Could not open sub list mail");
                        exit(EXIT_FAILURE);
                }
-               if(lseek(fd, 0, SEEK_END) < 0) {
-                       log_error(LOG_ARGS, "Could not seek to end of file");
-                       exit(EXIT_FAILURE);
-               }
                print_subs(fd, normalsls);
                writen(fd, "\n-- \n", 5);
                print_subs(fd, nomailsls);