From b0fa97c1588ce368d0fd490472d2a7f552c45dbf Mon Sep 17 00:00:00 2001 From: Jeremy Harris Date: Sat, 29 Oct 2016 20:51:44 +0100 Subject: [PATCH] Tidying: coverity issues --- src/src/exim_lock.c | 21 ++++++++++++++++----- src/src/sieve.c | 4 +++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/src/exim_lock.c b/src/src/exim_lock.c index 541e80f3f..074a951d1 100644 --- a/src/src/exim_lock.c +++ b/src/src/exim_lock.c @@ -357,8 +357,7 @@ for (j = 0; j < lock_retries; j++) /* Open the file for writing. */ - fd = open(filename, O_RDWR + O_APPEND); - if (fd < 0) + if ((fd = open(filename, O_RDWR + O_APPEND)) < 0) { printf("exim_lock: failed to open %s for writing: %s\n", filename, strerror(errno)); @@ -377,7 +376,6 @@ for (j = 0; j < lock_retries; j++) a timeout changes it to blocking. */ if (!use_mbx && (use_fcntl || use_flock)) - { if (apply_lock(fd, F_WRLCK, use_fcntl, lock_fcntl_timeout, use_flock, lock_flock_timeout) >= 0) { @@ -388,8 +386,8 @@ for (j = 0; j < lock_retries; j++) } break; } - else goto RETRY; /* Message already output */ - } + else + goto RETRY; /* Message already output */ /* Lock using MBX rules. This is complicated and is documented with the source of the c-client library that goes with Pine and IMAP. What has to @@ -586,12 +584,25 @@ else if (restore_times) { struct stat strestore; +#ifdef EXIM_HAVE_OPENAT + int fd = open(filename, O_RDWR); /* use fd for both get & restore */ + struct timespec tt[2]; + + fstat(fd, &strestore); + i = system(command); + tt[0] = strestore.st_atim; + tt[1] = strestore.st_mtim; + futimens(fd, tt); + close(fd); +#else struct utimbuf ut; + stat(filename, &strestore); i = system(command); ut.actime = strestore.st_atime; ut.modtime = strestore.st_mtime; utime(filename, &ut); +#endif } else i = system(command); diff --git a/src/src/sieve.c b/src/src/sieve.c index e6dde77a6..19bc5337b 100644 --- a/src/src/sieve.c +++ b/src/src/sieve.c @@ -413,7 +413,8 @@ Returns static int parse_mailto_uri(struct Sieve *filter, const uschar *uri, string_item **recipient, struct String *header, struct String *subject, struct String *body) { const uschar *start; -struct String to,hname,hvalue; +struct String to, hname; +struct String hvalue = {NULL, 0}; int capacity; string_item *new; @@ -422,6 +423,7 @@ if (Ustrncmp(uri,"mailto:",7)) filter->errmsg=US "Unknown URI scheme"; return 0; } + uri+=7; if (*uri && *uri!='?') for (;;) -- 2.25.1