[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [magicmail-users] a minor bug has been found



> just compiled the new magic-smtpd-0.8.4-2
> and found a minor bug.
> If you run magic-smtpd -s AND /var/qmail/control/badmailfrom file is empty,
> the program is seg faulted. Below i put strace output:

    I have fixed this bug in the CVS version, and this fix will be
included in the next release.  For now, the obvious workaround is to not
have a badmailfrom that is empty.  If there is some reason someone needs
a 0 byte badmailfrom file, I have attached a patch which will resolve
this issue.

    Thanks,
      Josh

-- 
Josh Wilsdon <josh@wizard.ca> Programmer Analyst
Wizard IT Services - http://www.wizard.ca
Linux Support Specialist - http://linuxmagic.com
Unix Administration, Website Hosting, Network Services, Programming
(604) 589-0037 Beautiful British Columbia, Canada
LinuxMagic is a TradeMark of Wizard Tower TechnoServices Ltd.
--------------------------------------------------------
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to which
they are addressed.  If you have received this email in error please
notify the system manager.  Please note that any views or opinions
presented in this email are solely those of the author and do not
necessarily represent those of the company.
diff -u -r1.12 load_controls.c
--- load_controls.c	12 Jan 2006 00:56:17 -0000	1.12
+++ load_controls.c	7 Feb 2006 19:36:20 -0000
@@ -751,6 +727,7 @@
  *
  *  -1 could not open file
  *  -2 memory allocation failure
+ *  -3 nothing read
  * >=0 number of lines read
  *
  * Side Effects:
@@ -787,6 +764,12 @@
         }
     }
 
+    if (outsize == 0) {
+        /* nothing read */
+        close(fd);
+        return (-3);
+    }
+
     /*if (nread == -1) {
         printf("DEBUG: read(): %s\n", strerror(errno));
     }*/
@@ -895,7 +878,9 @@
     }
 
     value = *out;
-    if (value[strlen(value) - 1] == '\n') {
+    assert(value != NULL);
+
+    if ((strlen(value) > 0) && (value[strlen(value) - 1] == '\n')) {
         value[strlen(value) - 1] = '\0';
     }