On Thursday, 13. October 2011 10:13:54 Thomas Jarosch wrote:
> Also don't mix tabs and spaces.

I guess my mail client will eat the tabs in the patch.
Here's the patch as file for easy "git am" consumption.

Cheers,
Thomas
From 6251ba2071e6adf05f630608cbf0768417ad9d3f Mon Sep 17 00:00:00 2001
From: Thomas Jarosch <thomas.jaro...@intra2net.com>
Date: Thu, 13 Oct 2011 10:04:01 +0200
Subject: [PATCH] Fix incorrect readlink() buffer handling

Also don't mix tabs and spaces.

Signed-off-by: Thomas Jarosch <thomas.jaro...@intra2net.com>
---
 timsieved/actions.c |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/timsieved/actions.c b/timsieved/actions.c
index 239d01d..347501c 100644
--- a/timsieved/actions.c
+++ b/timsieved/actions.c
@@ -474,20 +474,25 @@ static int isactive(char *name)
 {
     char filename[1024];
     char activelink[1024];
+    ssize_t link_len;
 
     snprintf(filename, 1023, "%s.bc", name);
     memset(activelink, 0, sizeof(activelink));
-    if ((readlink("defaultbc", activelink, sizeof(activelink)-1) < 0) && 
-	(errno != ENOENT)) 
+
+    link_len = readlink("defaultbc", activelink, sizeof(activelink)-1);
+    if (link_len == -1)
     {
-	syslog(LOG_ERR, "readlink(defaultbc): %m");
-	return FALSE;
+        if (errno != ENOENT)
+            syslog(LOG_ERR, "readlink(defaultbc): %m");
+
+        return FALSE;
     }
+    activelink[link_len] = '\0';
 
     if (!strcmp(filename, activelink)) {
-	return TRUE;
+        return TRUE;
     } else {
-	return FALSE;
+        return FALSE;
     }
 }
 
-- 
1.7.4.4

Reply via email to