Unix Technical Forum

Re: [patch] spamd remove dead parameter 'r', replace atoi with strtonum

This is a discussion on Re: [patch] spamd remove dead parameter 'r', replace atoi with strtonum within the mailing.openbsd.tech forums, part of the OpenBSD category; --> > Hello, > > I have some patches for spamd. > - remove parameter 'r' from getopt in main ...


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > mailing.openbsd.tech

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-18-2008, 09:21 AM
Olli Hauer
 
Posts: n/a
Default Re: [patch] spamd remove dead parameter 'r', replace atoi with strtonum

> Hello,
>
> I have some patches for spamd.
> - remove parameter 'r' from getopt in main since it is no more used
> - replace atoi(getopt) with strtonum
> - make the spamd.alloweddomains tolerant for empty lines and comments
>
> olli
>


as suggested, check first len and the isspace.
thanks to Charles.

olli

--- /usr/src/libexec/spamd/spamd.c.orig Tue Apr 24 23:21:16 2007
+++ /usr/src/libexec/spamd/spamd.c Sat Apr 21 16:25:57 2007
@@ -1058,7 +1058,7 @@
if (maxblack > maxfiles)
maxblack = maxfiles;
while ((ch =
- getopt(argc, argv, "45l:c:B:bdG:h:r:s:S:M:n:vw:y:Y:")) !=
-1) {
+ getopt(argc, argv, "45l:c:B:bdG:h:s:S:M:n:vw:y:Y:")) !=
-1) {
switch (ch) {
case '4':
nreply = "450";
@@ -1111,8 +1111,8 @@
errx(1, "-h arg too long");
break;
case 's':
- i = atoi(optarg);
- if (i < 0 || i > 10)
+ i = strtonum(optarg, 0, 10, &errstr);
+ if (errstr)
usage();
stutter = i;
break;

--- /usr/src/libexec/spamd/grey.c.orig Tue Apr 24 07:31:23 2007
+++ /usr/src/libexec/spamd/grey.c Sat Apr 21 16:26:28 2007
@@ -317,6 +317,18 @@
SLIST_REMOVE_HEAD(&match_suffix, entry);
if ((fp = fopen(alloweddomains_file, "r")) != NULL) {
while ((buf = fgetln(fp, &len))) {
+ /* strip white space-characters */
+ while (len > 0 && isspace(buf[len-1]))
+ len--;
+ while (len > 0 && isspace(*buf)) {
+ buf++;
+ len--;
+ }
+ /* jump over comments and blank lines */
+ if (*buf == '#' || *buf == '\n')
+ continue;
+ if (len == 0)
+ continue;
if (buf[len-1] == '\n')
len--;
if ((m = malloc(sizeof(struct mail_addr))) ==
NULL)
@@ -524,8 +536,7 @@
memset(&dbk, 0, sizeof(dbk));
dbk.size = strlen(key);
dbk.data = key;
- memset(&dbd, 0,
- sizeof(dbd));
+ memset(&dbd, 0, sizeof(dbd));
i = db->get(db, &dbk, &dbd, 0);
if (i == -1)
return (-1);

--- /usr/src/libexec/spamd/spamd.8.orig Tue Apr 24 23:21:16 2007
+++ /usr/src/libexec/spamd/spamd.8 Sat Apr 21 16:37:11 2007
@@ -384,6 +384,9 @@
Any destination address which does not match one of the suffixes listed
in
.Pa spamd.alloweddomains
will be trapped, exactly as if it were sent to a spamtrap address.
+Comment lines beginning with
+.Ar #
+and empty lines are ignored.
.Pp
For example, if
.Pa spamd.alloweddomains

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 02:34 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com