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 ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| > 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 -1) { + getopt(argc, argv, "45l:c:B -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 |