if (rc == OK)
{
uschar temp_path[1024];
- struct dirent *entry;
- DIR *tempdir;
+ struct dirent * entry;
+ DIR * tempdir;
- (void)string_format(temp_path, 1024, "%s/scan/%s", spool_directory,
- message_id);
+ (void) string_format(temp_path, sizeof(temp_path), "%s/scan/%s",
+ spool_directory, message_id);
tempdir = opendir(CS temp_path);
- do
+ for (;;)
{
- entry = readdir(tempdir);
- if (entry == NULL) break;
- if (strncmpic(US entry->d_name,US"__rfc822_",9) == 0)
+ if (!(entry = readdir(tempdir)))
+ break;
+ if (strncmpic(US entry->d_name, US"__rfc822_", 9) == 0)
{
- (void)string_format(rfc822_file_path, 2048,"%s/scan/%s/%s", spool_directory, message_id, entry->d_name);
- debug_printf("RFC822 attachment detected: running MIME ACL for '%s'\n", rfc822_file_path);
+ (void) string_format(rfc822_file_path, sizeof(rfc822_file_path),
+ "%s/scan/%s/%s", spool_directory, message_id, entry->d_name);
+ debug_printf("RFC822 attachment detected: running MIME ACL for '%s'\n",
+ rfc822_file_path);
break;
}
- } while (1);
+ }
closedir(tempdir);
- if (entry != NULL)
+ if (entry)
{
- mbox_file = Ufopen(rfc822_file_path,"rb");
- if (mbox_file == NULL)
+ if ((mbox_file = Ufopen(rfc822_file_path, "rb")))
{
- log_write(0, LOG_PANIC,
- "acl_smtp_mime: can't open RFC822 spool file, skipping.");
- unlink(CS rfc822_file_path);
- goto END_MIME_ACL;
+ /* set RFC822 expansion variable */
+ mime_is_rfc822 = 1;
+ mime_part_count_buffer = mime_part_count;
+ goto MIME_ACL_CHECK;
}
- /* set RFC822 expansion variable */
- mime_is_rfc822 = 1;
- mime_part_count_buffer = mime_part_count;
- goto MIME_ACL_CHECK;
+ log_write(0, LOG_PANIC,
+ "acl_smtp_mime: can't open RFC822 spool file, skipping.");
+ unlink(CS rfc822_file_path);
}
}
spam_ok = 0;
/* if we scanned for this username last time, just return */
- if ( spam_ok && Ustrcmp(prev_user_name, user_name) == 0)
- if (override)
- return OK;
- else
- return spam_rc;
+ if (spam_ok && Ustrcmp(prev_user_name, user_name) == 0)
+ return override ? OK : spam_rc;
/* make sure the eml mbox file is spooled up */
mbox_file = spool_mbox(&mbox_size, NULL);
int sread = 0;
int wwritten = 0;
uschar *dkim_signature = NULL;
-off_t size = 0;
/* If we can't sign, just call the original function. */
}
}
-/* Fetch file size */
-size = lseek(dkim_fd, 0, SEEK_END);
-
-/* Rewind file */
-lseek(dkim_fd, 0, SEEK_SET);
-
#ifdef HAVE_LINUX_SENDFILE
/* We can use sendfile() to shove the file contents
to the socket. However only if we don't use TLS,
before the data finally hits the socket. */
if (tls_out.active != fd)
{
+ off_t size = lseek(dkim_fd, 0, SEEK_END); /* Fetch file size */
ssize_t copied = 0;
off_t offset = 0;
+
+ /* Rewind file */
+ lseek(dkim_fd, 0, SEEK_SET);
+
while(copied >= 0 && offset < size)
copied = sendfile(fd, dkim_fd, &offset, size - offset);
if (copied < 0)
save_errno = errno;
rc = FALSE;
}
- goto CLEANUP;
}
+else
+
#endif
-/* Send file down the original fd */
-while((sread = read(dkim_fd, sbuf, 2048)) > 0)
{
- char *p = sbuf;
- /* write the chunk */
+ /* Rewind file */
+ lseek(dkim_fd, 0, SEEK_SET);
- while (sread)
+ /* Send file down the original fd */
+ while((sread = read(dkim_fd, sbuf, 2048)) > 0)
{
+ char *p = sbuf;
+ /* write the chunk */
+
+ while (sread)
+ {
#ifdef SUPPORT_TLS
- wwritten = tls_out.active == fd
- ? tls_write(FALSE, US p, sread)
- : write(fd, p, sread);
+ wwritten = tls_out.active == fd
+ ? tls_write(FALSE, US p, sread)
+ : write(fd, p, sread);
#else
- wwritten = write(fd, p, sread);
+ wwritten = write(fd, p, sread);
#endif
- if (wwritten == -1)
- {
- /* error, bail out */
- save_errno = errno;
- rc = FALSE;
- goto CLEANUP;
+ if (wwritten == -1)
+ {
+ /* error, bail out */
+ save_errno = errno;
+ rc = FALSE;
+ goto CLEANUP;
+ }
+ p += wwritten;
+ sread -= wwritten;
}
- p += wwritten;
- sread -= wwritten;
}
- }
-if (sread == -1)
- {
- save_errno = errno;
- rc = FALSE;
- goto CLEANUP;
+ if (sread == -1)
+ {
+ save_errno = errno;
+ rc = FALSE;
+ }
}
CLEANUP: