INN commit: trunk (36 files)
INN Commit
rra at isc.org
Fri Nov 6 21:47:12 UTC 2009
Date: Friday, November 6, 2009 @ 13:47:11
Author: iulius
Revision: 8709
* Add a new "unsigned long" type to the configuration parser.
It will properly warn the user when a variable contains
a negative integer. It will prevent INN from crashing
at several places (like a xmalloc(-5) which in fact
allocates 4GB of memory on a 32-bit architecture).
* Modify lots of casts (some are now useless, others needed).
* Also update the test suite, adding case tests for unsigned
integers and lists.
Added:
trunk/tests/data/config/warn-list
trunk/tests/data/config/warn-uint
Modified:
trunk/doc/pod/inn.conf.pod
trunk/frontends/inews.c
trunk/frontends/rnews.c
trunk/include/inn/confparse.h
trunk/include/inn/innconf.h
trunk/innd/art.c
trunk/innd/cc.c
trunk/innd/chan.c
trunk/innd/icd.c
trunk/innd/innd.c
trunk/innd/innd.h
trunk/innd/keywords.c
trunk/innd/nc.c
trunk/innd/status.c
trunk/innd/wip.c
trunk/innfeed/endpoint.c
trunk/innfeed/main.c
trunk/lib/confparse.c
trunk/lib/innconf.c
trunk/nnrpd/cache.c
trunk/nnrpd/commands.c
trunk/nnrpd/group.c
trunk/nnrpd/line.c
trunk/nnrpd/misc.c
trunk/nnrpd/newnews.c
trunk/nnrpd/nnrpd.c
trunk/nnrpd/nnrpd.h
trunk/nnrpd/perm.c
trunk/nnrpd/post.c
trunk/storage/buffindexed/buffindexed.c
trunk/storage/cnfs/cnfs.c
trunk/storage/tradindexed/tradindexed.c
trunk/tests/innd/artparse-t.c
trunk/tests/lib/confparse-t.c
-----------------------------------+
doc/pod/inn.conf.pod | 2
frontends/inews.c | 6
frontends/rnews.c | 8
include/inn/confparse.h | 3
include/inn/innconf.h | 101 ++++-----
innd/art.c | 23 +-
innd/cc.c | 24 +-
innd/chan.c | 18 -
innd/icd.c | 2
innd/innd.c | 12 -
innd/innd.h | 10
innd/keywords.c | 4
innd/nc.c | 11 -
innd/status.c | 16 -
innd/wip.c | 6
innfeed/endpoint.c | 4
innfeed/main.c | 2
lib/confparse.c | 84 ++++++-
lib/innconf.c | 389 ++++++++++++++++++++----------------
nnrpd/cache.c | 2
nnrpd/commands.c | 10
nnrpd/group.c | 4
nnrpd/line.c | 4
nnrpd/misc.c | 28 +-
nnrpd/newnews.c | 6
nnrpd/nnrpd.c | 14 -
nnrpd/nnrpd.h | 12 -
nnrpd/perm.c | 12 -
nnrpd/post.c | 6
storage/buffindexed/buffindexed.c | 6
storage/cnfs/cnfs.c | 4
storage/tradindexed/tradindexed.c | 6
tests/data/config/warn-list | 4
tests/data/config/warn-uint | 25 ++
tests/innd/artparse-t.c | 2
tests/lib/confparse-t.c | 145 ++++++++++---
36 files changed, 621 insertions(+), 394 deletions(-)
Modified: doc/pod/inn.conf.pod
===================================================================
--- doc/pod/inn.conf.pod 2009-11-06 18:11:01 UTC (rev 8708)
+++ doc/pod/inn.conf.pod 2009-11-06 21:47:11 UTC (rev 8709)
@@ -142,6 +142,8 @@
is C<10>, which means that an incoming article will be rejected if its
posting date is farther in the past than ten days.
+In order to disable that check on date, you can set this parameter to C<0>.
+
The number on the C</remember/> line in F<expire.ctl> should probably
be one more than that number in order to take into account articles
whose posting date is one day into the future.
Modified: frontends/inews.c
===================================================================
--- frontends/inews.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ frontends/inews.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -1019,9 +1019,9 @@
SigLines = 0;
ProcessHeaders(AddOrg, i + SigLines, pwp);
Length = strlen(article);
- if ((innconf->localmaxartsize > 0)
- && (Length > (size_t)innconf->localmaxartsize))
- die("article is larger than local limit of %ld bytes",
+ if ((innconf->localmaxartsize != 0)
+ && (Length > innconf->localmaxartsize))
+ die("article is larger than local limit of %lu bytes",
innconf->localmaxartsize);
/* Do final checks. */
Modified: frontends/rnews.c
===================================================================
--- frontends/rnews.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ frontends/rnews.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -77,7 +77,7 @@
/* Get a child. */
for (i = 0; (pid = fork()) < 0; i++) {
- if (i == innconf->maxforks) {
+ if (i == (long) innconf->maxforks) {
syswarn("cannot fork %s, spooling", path);
return -1;
}
@@ -917,11 +917,11 @@
/* Open the link to the server. */
if (remoteServer != NULL) {
- if (!OpenRemote(remoteServer,port,buff,sizeof(buff)))
+ if (!OpenRemote(remoteServer, port, buff, sizeof(buff)))
CantConnect(buff,mode,fd);
} else if (innconf->nnrpdposthost != NULL) {
if (!OpenRemote(innconf->nnrpdposthost,
- (port != NNTP_PORT) ? port : innconf->nnrpdpostport,
+ (port != NNTP_PORT) ? (unsigned) port : innconf->nnrpdpostport,
buff, sizeof(buff)))
CantConnect(buff, mode, fd);
}
@@ -930,7 +930,7 @@
/* If server rejected us, no point in continuing. */
if (buff[0])
CantConnect(buff, mode, fd);
- if (!OpenRemote(NULL, (port != NNTP_PORT) ? port : innconf->port,
+ if (!OpenRemote(NULL, (port != NNTP_PORT) ? (unsigned) port : innconf->port,
buff, sizeof(buff)))
CantConnect(buff, mode, fd);
}
Modified: include/inn/confparse.h
===================================================================
--- include/inn/confparse.h 2009-11-06 18:11:01 UTC (rev 8708)
+++ include/inn/confparse.h 2009-11-06 21:47:11 UTC (rev 8709)
@@ -50,7 +50,8 @@
unchanged and that parameter wasn't set (or was set to an invalid value for
the expected type). */
bool config_param_boolean(struct config_group *, const char *, bool *);
-bool config_param_integer(struct config_group *, const char *, long *);
+bool config_param_signed_number(struct config_group *, const char *, long *);
+bool config_param_unsigned_number(struct config_group *, const char *, unsigned long *);
bool config_param_real(struct config_group *, const char *, double *);
bool config_param_string(struct config_group *, const char *, const char **);
bool config_param_list(struct config_group *, const char *,
Modified: include/inn/innconf.h
===================================================================
--- include/inn/innconf.h 2009-11-06 18:11:01 UTC (rev 8708)
+++ include/inn/innconf.h 2009-11-06 21:47:11 UTC (rev 8709)
@@ -16,7 +16,8 @@
** This structure is organized in the same order as the variables contained
** in it are mentioned in the inn.conf documentation, and broken down into
** the same sections. Note that due to the implementation, only three types
-** of variables are permissible here: char *, bool, and long.
+** of variables are permissible here: char *, bool, struc vector *, long
+** and unsigned long.
*/
struct innconf {
/* General Settings */
@@ -30,20 +31,20 @@
char *runasgroup; /* Group to run under */
/* Feed Configuration */
- long artcutoff; /* Max accepted article age */
+ unsigned long artcutoff; /* Max accepted article age */
char *bindaddress; /* Which interface IP to bind to */
char *bindaddress6; /* Which interface IPv6 to bind to */
bool dontrejectfiltered; /* Don't reject filtered article? */
- long hiscachesize; /* Size of the history cache in kB */
+ unsigned long hiscachesize; /* Size of the history cache in kB */
bool ignorenewsgroups; /* Propagate cmsgs by affected group? */
bool immediatecancel; /* Immediately cancel timecaf messages? */
- long linecountfuzz; /* Check linecount and reject if off by more */
- long maxartsize; /* Reject articles bigger than this */
- long maxconnections; /* Max number of incoming NNTP connections */
+ unsigned long linecountfuzz;/* Check linecount and reject if off by more */
+ unsigned long maxartsize; /* Reject articles bigger than this */
+ unsigned long maxconnections; /* Max number of incoming NNTP connections */
char *pathalias; /* Prepended Host for the Path: line */
char *pathcluster; /* Appended Host for the Path: line */
bool pgpverify; /* Verify control messages with pgpverify? */
- long port; /* Which port innd should listen on */
+ unsigned long port; /* Which port innd should listen on */
bool refusecybercancels; /* Reject message IDs with "<cancel."? */
bool remembertrash; /* Put unwanted article IDs into history */
char *sourceaddress; /* Source IP for outgoing NNTP connections */
@@ -51,14 +52,14 @@
bool verifycancels; /* Verify cancels against article author */
bool verifygroups; /* Check if all newsgroups exist */
bool wanttrash; /* Put unwanted articles in junk */
- long wipcheck; /* How long to defer other copies of article */
- long wipexpire; /* How long to keep pending article record */
+ unsigned long wipcheck; /* How long to defer other copies of article */
+ unsigned long wipexpire; /* How long to keep pending article record */
/* History settings */
char *hismethod; /* Which history method to use */
/* Article Storage */
- long cnfscheckfudgesize; /* Additional CNFS integrity checking */
+ unsigned long cnfscheckfudgesize; /* Additional CNFS integrity checking */
bool enableoverview; /* Store overview info for articles? */
struct vector
*extraoverviewadvertised; /* Extra overview fields for LIST OVERVIEW.FMT */
@@ -67,7 +68,7 @@
bool groupbaseexpiry; /* Do expiry by newsgroup? */
bool mergetogroups; /* Refile articles from to.* into to */
bool nfswriter; /* Use NFS writer functionality */
- long overcachesize; /* fd size cache for tradindexed */
+ unsigned long overcachesize; /* fd size cache for tradindexed */
char *ovgrouppat; /* Newsgroups to store overview for */
char *ovmethod; /* Which overview method to use */
bool storeonxref; /* SMstore use Xref to detemine class? */
@@ -78,14 +79,14 @@
/* Reading */
bool allownewnews; /* Allow use of the NEWNEWS command */
bool articlemmap; /* Use mmap to read articles? */
- long clienttimeout; /* How long nnrpd can be inactive */
- long initialtimeout; /* How long nnrpd waits for first command */
- long msgidcachesize; /* Number of entries in the message ID cache */
+ unsigned long clienttimeout; /* How long nnrpd can be inactive */
+ unsigned long initialtimeout; /* How long nnrpd waits for first command */
+ unsigned long msgidcachesize; /* Number of entries in the message ID cache */
bool nfsreader; /* Use NFS reader functionality */
- long nfsreaderdelay; /* Delay applied to article arrival */
+ unsigned long nfsreaderdelay; /* Delay applied to article arrival */
bool nnrpdcheckart; /* Check article existence before returning? */
char *nnrpdflags; /* Arguments to pass when spawning nnrpd */
- long nnrpdloadlimit; /* Maximum getloadvg() we allow */
+ unsigned long nnrpdloadlimit; /* Maximum getloadvg() we allow */
bool noreader; /* Refuse to fork nnrpd for readers? */
bool readerswhenstopped; /* Allow nnrpd when server is paused */
bool readertrack; /* Use the reader tracking system? */
@@ -93,9 +94,9 @@
/* Reading -- Keyword Support */
bool keywords; /* Generate keywords in overview? */
- long keyartlimit; /* Max article size for keyword generation */
- long keylimit; /* Max allocated space for keywords */
- long keymaxwords; /* Max count of interesting words */
+ unsigned long keyartlimit; /* Max article size for keyword generation */
+ unsigned long keylimit; /* Max allocated space for keywords */
+ unsigned long keymaxwords; /* Max count of interesting words */
/* Posting */
bool addnntppostingdate; /* Add NNTP-Posting-Date: to posts */
@@ -103,11 +104,11 @@
bool checkincludedtext; /* Reject if too much included text */
char *complaints; /* Address for X-Complaints-To: */
char *fromhost; /* Host for the From: line */
- long localmaxartsize; /* Max article size of local postings */
+ unsigned long localmaxartsize; /* Max article size of local postings */
char *moderatormailer; /* Default host to mail moderated articles */
bool nnrpdauthsender; /* Add authenticated Sender: header? */
char *nnrpdposthost; /* Host postings should be forwarded to */
- long nnrpdpostport; /* Port postings should be forwarded to */
+ unsigned long nnrpdpostport; /* Port postings should be forwarded to */
char *organization; /* Data for the Organization: header */
bool spoolfirst; /* Spool all posted articles? */
bool strippostcc; /* Strip To:, Cc: and Bcc: from posts */
@@ -115,10 +116,10 @@
/* Posting -- Exponential Backoff */
bool backoffauth; /* Backoff by user, not IP address */
char *backoffdb; /* Directory for backoff databases */
- long backoffk; /* Multiple for the sleep time */
- long backoffpostfast; /* Upper time limit for fast posting */
- long backoffpostslow; /* Lower time limit for slow posting */
- long backofftrigger; /* Number of postings before triggered */
+ unsigned long backoffk; /* Multiple for the sleep time */
+ unsigned long backoffpostfast; /* Upper time limit for fast posting */
+ unsigned long backoffpostslow; /* Lower time limit for slow posting */
+ unsigned long backofftrigger; /* Number of postings before triggered */
/* Reading and posting -- SSL and TLS support */
#ifdef HAVE_SSL
@@ -130,45 +131,45 @@
/* Monitoring */
bool doinnwatch; /* Start innwatch from rc.news? */
- long innwatchbatchspace; /* Minimum free space in pathoutgoing */
- long innwatchlibspace; /* Minimum free space in pathdb */
- long innwatchloload; /* Load times 100 at which to restart */
- long innwatchhiload; /* Load times 100 at which to throttle */
- long innwatchpauseload; /* Load times 100 at which to pause */
- long innwatchsleeptime; /* Seconds to wait between checks */
- long innwatchspoolnodes; /* Minimum free inodes in patharticles */
- long innwatchspoolspace; /* Minimum free space in patharticles */
+ unsigned long innwatchbatchspace; /* Minimum free space in pathoutgoing */
+ unsigned long innwatchlibspace; /* Minimum free space in pathdb */
+ unsigned long innwatchloload; /* Load times 100 at which to restart */
+ unsigned long innwatchhiload; /* Load times 100 at which to throttle */
+ unsigned long innwatchpauseload; /* Load times 100 at which to pause */
+ unsigned long innwatchsleeptime; /* Seconds to wait between checks */
+ unsigned long innwatchspoolnodes; /* Minimum free inodes in patharticles */
+ unsigned long innwatchspoolspace; /* Minimum free space in patharticles */
/* Logging */
bool docnfsstat; /* Run cnfsstat in the background? */
- long incominglogfrequency; /* Checkpoint log after this many articles */
+ unsigned long incominglogfrequency; /* Checkpoint log after this many articles */
bool logartsize; /* Log article sizes? */
bool logcancelcomm; /* Log ctlinnd cancel commands to syslog? */
- long logcycles; /* How many old logs scanlogs should keep */
+ unsigned long logcycles; /* How many old logs scanlogs should keep */
bool logipaddr; /* Log by host IP address? */
bool logsitename; /* Log outgoing site names? */
bool logstatus; /* Send a status report to syslog? */
bool nnrpdoverstats; /* Log overview statistics? */
bool nntplinklog; /* Put storage token into the log? */
- long status; /* Status file update interval */
+ unsigned long status; /* Status file update interval */
char *stathist; /* Filename for history profiler outputs */
- long timer; /* Performance monitoring interval */
+ unsigned long timer; /* Performance monitoring interval */
/* System Tuning */
- long badiocount; /* Failure count before dropping channel */
- long blockbackoff; /* Multiplier for sleep in EAGAIN writes */
- long chaninacttime; /* Wait before noticing inactive channels */
- long chanretrytime; /* How long before channel restarts */
- long datamovethreshold; /* Threshold to extend buffer or move data */
- long icdsynccount; /* Articles between active & history updates */
- long keepmmappedthreshold; /* Threshold for keeping mmap in buffindexed */
- long maxcmdreadsize; /* Max NNTP command read size used by innd */
- long maxforks; /* Give up after this many fork failure */
+ unsigned long badiocount; /* Failure count before dropping channel */
+ unsigned long blockbackoff; /* Multiplier for sleep in EAGAIN writes */
+ unsigned long chaninacttime;/* Wait before noticing inactive channels */
+ unsigned long chanretrytime;/* How long before channel restarts */
+ unsigned long datamovethreshold; /* Threshold to extend buffer or move data */
+ unsigned long icdsynccount; /* Articles between active & history updates */
+ unsigned long keepmmappedthreshold; /* Threshold for keeping mmap in buffindexed */
+ unsigned long maxcmdreadsize; /* Max NNTP command read size used by innd */
+ unsigned long maxforks; /* Give up after this many fork failure. */
long nicekids; /* Child processes get niced to this */
- long nicenewnews; /* If NEWNEWS command is used, nice to this */
- long nicennrpd; /* nnrpd is niced to this */
- long pauseretrytime; /* Seconds before seeing if pause is ended */
- long peertimeout; /* How long peers can be inactive */
+ unsigned long nicenewnews; /* If NEWNEWS command is used, nice to this */
+ unsigned long nicennrpd; /* nnrpd is niced to this */
+ unsigned long pauseretrytime; /* Seconds before seeing if pause is ended */
+ unsigned long peertimeout; /* How long peers can be inactive */
long rlimitnofile; /* File descriptor limit to set */
/* Paths */
Modified: innd/art.c
===================================================================
--- innd/art.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ innd/art.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -273,7 +273,7 @@
ARTheadertree = ARTbuildtree(table, 0, ARRAY_SIZE(ARTheaders));
free(table);
- /* Get our Path name, kill trailing !. */
+ /* Get our Path name, kill trailing! */
ARTpathme = xstrdup(Path.data);
ARTpathme[Path.used - 1] = '\0';
@@ -716,8 +716,8 @@
}
/*
-** Check Message-ID format based on RFC 822 grammar, except that (as per
-** RFC 1036) whitespace, non-printing, and '>' characters are excluded.
+** Check message-ID format based on RFC 5322 grammar, except that (as per
+** USEFOR, RFC 5536) whitespace, non-printing, and '>' characters are excluded.
** Based on code by Paul Eggert posted to news.software.b on 22-Nov-90
** in <#*tyo2'~n at twinsun.com>, with additional e-mail discussion.
** Thanks, Paul.
@@ -728,7 +728,7 @@
int c;
const char *p;
- /* Check the length of the message ID. */
+ /* Check the length of the message-ID. */
if (MessageID == NULL || strlen(MessageID) > NNTP_MAXLEN_MSGID)
return false;
@@ -853,16 +853,16 @@
const char *msgid;
size = cp->Next - cp->Start;
- if (innconf->maxartsize > 0 && size > (size_t) innconf->maxartsize) {
+ if (innconf->maxartsize != 0 && size > innconf->maxartsize) {
if (cp->State == CSgotarticle || cp->State == CSgotlargearticle)
cp->State = CSgotlargearticle;
else
cp->State = CSeatarticle;
}
if (cp->State == CSgotlargearticle) {
- notice("%s internal rejecting huge article (%lu > %ld)", CHANname(cp),
+ notice("%s internal rejecting huge article (%lu > %lu)", CHANname(cp),
(unsigned long) size, innconf->maxartsize);
- ARTerror(cp, "Article of %lu bytes exceeds local limit of %ld bytes",
+ ARTerror(cp, "Article of %lu bytes exceeds local limit of %lu bytes",
(unsigned long) size, innconf->maxartsize);
/* Write a local cancel entry so nobody else gives it to us. */
@@ -1097,11 +1097,12 @@
return false;
}
- if (innconf->linecountfuzz && HDR_FOUND(HDR__LINES)) {
+ if (innconf->linecountfuzz != 0 && HDR_FOUND(HDR__LINES)) {
p = HDR(HDR__LINES);
i = data->Lines;
- if ((delta = i - atoi(p)) != 0 && abs(delta) > innconf->linecountfuzz) {
- sprintf(buff, "%d Linecount %s != %d +- %ld",
+ if ((delta = i - atoi(p)) != 0
+ && (unsigned long) abs(delta) > innconf->linecountfuzz) {
+ sprintf(buff, "%d Linecount %s != %d +- %lu",
ihave ? NNTP_FAIL_IHAVE_REJECT : NNTP_FAIL_TAKETHIS_REJECT,
MaxLength(p, p), i, innconf->linecountfuzz);
TMRstop(TMR_ARTCLEAN);
@@ -1120,7 +1121,7 @@
TMRstop(TMR_ARTCLEAN);
return false;
}
- if (innconf->artcutoff) {
+ if (innconf->artcutoff != 0) {
long cutoff = innconf->artcutoff * 24 * 60 * 60;
if (data->Posted < Now.tv_sec - cutoff) {
Modified: innd/cc.c
===================================================================
--- innd/cc.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ innd/cc.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -839,7 +839,7 @@
/* Server parameters. */
for (count = 0, index = 0; CHANiter(&index, CTnntp) != NULL; )
count++;
- buffer_sprintf(&CCreply, true, "Parameters c %ld i %ld (%d) l %ld o %d"
+ buffer_sprintf(&CCreply, true, "Parameters c %lu i %lu (%d) l %lu o %d"
" t %ld H %d T %d X %ld %s %s\n",
innconf->artcutoff, innconf->maxconnections, count,
innconf->maxartsize, MaxOutgoing, (long) TimeOut.tv_sec,
@@ -1090,16 +1090,16 @@
return BADVAL;
break;
case 'c':
- innconf->artcutoff = atoi(p);
- syslog(L_NOTICE, "%s changed -c %ld", LogName, innconf->artcutoff);
+ innconf->artcutoff = strtoul(p, NULL, 10);
+ syslog(L_NOTICE, "%s changed -c %lu", LogName, innconf->artcutoff);
break;
case 'i':
- innconf->maxconnections = atoi(p);
- syslog(L_NOTICE, "%s changed -i %ld", LogName, innconf->maxconnections);
+ innconf->maxconnections = strtoul(p, NULL, 10);
+ syslog(L_NOTICE, "%s changed -i %lu", LogName, innconf->maxconnections);
break;
case 'l':
- innconf->maxartsize = atol(p);
- syslog(L_NOTICE, "%s changed -l %ld", LogName, innconf->maxartsize);
+ innconf->maxartsize = strtoul(p, NULL, 10);
+ syslog(L_NOTICE, "%s changed -l %lu", LogName, innconf->maxartsize);
break;
case 'n':
if (!CCparsebool('n', (bool *)&innconf->readerswhenstopped, *p))
@@ -1615,7 +1615,7 @@
static const char *
CCtimer(char *av[])
{
- int value;
+ unsigned long value;
char *p;
if (strcmp(av[0], "off") == 0)
@@ -1625,10 +1625,10 @@
if (!CTYPE(isdigit, *p))
return "1 parameter should be a number or 'off'";
}
- value = atoi(av[0]);
+ value = strtoul(av[0], NULL, 10);
}
innconf->timer = value;
- if (innconf->timer)
+ if (innconf->timer != 0)
TMRinit(TMR_MAX);
else
TMRinit(0);
@@ -1654,7 +1654,7 @@
static const char *
CCstatus(char *av[])
{
- int value;
+ unsigned long value;
char *p;
if (strcmp(av[0], "off") == 0)
@@ -1664,7 +1664,7 @@
if (!CTYPE(isdigit, *p))
return "1 parameter should be a number or 'off'";
}
- value = atoi(av[0]);
+ value = strtoul(av[0], NULL, 10);
}
innconf->status = value;
return NULL;
Modified: innd/chan.c
===================================================================
--- innd/chan.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ innd/chan.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -247,7 +247,7 @@
notice("%s trace %s", name, flag ? "on" : "off");
cp->Tracing = flag;
if (flag) {
- notice("%s trace badwrites %d blockwrites %d badreads %d", name,
+ notice("%s trace badwrites %lu blockwrites %lu badreads %lu", name,
cp->BadWrites, cp->BlockedWrites, cp->BadReads);
network_sockaddr_sprint(addr, sizeof(addr),
(struct sockaddr *) &cp->Address);
@@ -787,8 +787,8 @@
FIXME: A better approach would be to limit the number of commands we
process for each channel. */
- if (innconf->maxcmdreadsize <= 0 || cp->State != CSgetcmd
- || bp->left < (unsigned long) innconf->maxcmdreadsize)
+ if (innconf->maxcmdreadsize == 0 || cp->State != CSgetcmd
+ || bp->left < innconf->maxcmdreadsize)
maxbyte = bp->left;
else
maxbyte = innconf->maxcmdreadsize;
@@ -906,7 +906,7 @@
static void
CHANwritesleep(CHANNEL *cp, const char *name)
{
- int bad, delay;
+ unsigned long bad, delay;
bad = ++(cp->BlockedWrites);
if (bad > innconf->badiocount)
@@ -924,7 +924,7 @@
return;
}
delay = bad * innconf->blockbackoff;
- warn("%s blocked sleeping %d", name, delay);
+ warn("%s blocked sleeping %lu", name, delay);
SCHANadd(cp, Now.tv_sec + delay, NULL, CHANwakeup, NULL);
}
@@ -1116,7 +1116,7 @@
CHANNEL *cp;
fd_set rdfds, wrfds;
struct timeval tv;
- long silence;
+ unsigned long silence;
const char *name;
time_t last_sync;
int fd = 0;
@@ -1133,10 +1133,10 @@
rdfds = channels.read_set;
wrfds = channels.write_set;
tv = TimeOut;
- if (innconf->timer) {
+ if (innconf->timer != 0) {
unsigned long now = TMRnow();
- if (now < 1000 * (unsigned long)(innconf->timer))
+ if (now < 1000 * innconf->timer)
tv.tv_sec = innconf->timer - now / 1000;
else {
TMRsummary("ME", timer_name);
@@ -1167,7 +1167,7 @@
gettimeofday(&Now, NULL);
if (Now.tv_sec > last_sync + TimeOut.tv_sec) {
HISsync(History);
- if (ICDactivedirty) {
+ if (ICDactivedirty != 0) {
ICDwriteactive();
ICDactivedirty = 0;
}
Modified: innd/icd.c
===================================================================
--- innd/icd.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ innd/icd.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -108,7 +108,7 @@
HISsync(History);
SMflushcacheddata(SM_ALL);
- if (ICDactivedirty) {
+ if (ICDactivedirty != 0) {
ICDwriteactive();
ICDactivedirty = 0;
}
Modified: innd/innd.c
===================================================================
--- innd/innd.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ innd/innd.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -422,7 +422,7 @@
AnyIncoming = true;
break;
case 'c':
- innconf->artcutoff = atoi(optarg);
+ innconf->artcutoff = strtoul(optarg, NULL, 10);
break;
case 'C':
DoCancels = false;
@@ -437,10 +437,10 @@
RemoteLimit = atoi(optarg);
break;
case 'i':
- innconf->maxconnections = atoi(optarg);
+ innconf->maxconnections = strtoul(optarg, NULL, 10);
break;
case 'l':
- innconf->maxartsize = atol(optarg);
+ innconf->maxartsize = strtoul(optarg, NULL, 10);
break;
case 'm':
if (ModeReason)
@@ -473,7 +473,7 @@
MaxOutgoing = atoi(optarg);
break;
case 'P':
- innconf->port = atoi(optarg);
+ innconf->port = strtoul(optarg, NULL, 10);
break;
case 'r':
ShouldRenumber = true;
@@ -598,7 +598,7 @@
Otherwise, we use insane amounts of memory for the channel table.
FIXME: Get rid of this hard-coded constant. */
if (i > 5000) {
- int max;
+ unsigned long max;
max = innconf->maxconnections + MaxOutgoing + 20;
if (max < 5000)
@@ -650,7 +650,7 @@
NCsetup();
ARTsetup();
ICDsetup(true);
- if (innconf->timer)
+ if (innconf->timer != 0)
TMRinit(TMR_MAX);
/* Initialize the storage subsystem. */
Modified: innd/innd.h
===================================================================
--- innd/innd.h 2009-11-06 18:11:01 UTC (rev 8708)
+++ innd/innd.h 2009-11-06 21:47:11 UTC (rev 8709)
@@ -353,13 +353,13 @@
unsigned long Ihave_Deferred;
unsigned long Ihave_SendIt;
unsigned long Ihave_Cybercan;
- int Reported;
+ unsigned long Reported;
long Received;
long Refused;
long Rejected;
- int BadWrites;
- int BadReads;
- int BlockedWrites;
+ unsigned long BadWrites;
+ unsigned long BadReads;
+ unsigned long BlockedWrites;
int BadCommands;
time_t LastActive;
time_t NextLog;
@@ -625,7 +625,7 @@
EXTERN FILE * Log;
extern char LogName[];
extern int ErrorCount;
-EXTERN int ICDactivedirty;
+EXTERN unsigned long ICDactivedirty;
EXTERN int MaxOutgoing;
EXTERN int nGroups;
EXTERN SITEIDX nSites;
Modified: innd/keywords.c
===================================================================
--- innd/keywords.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ innd/keywords.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -100,7 +100,7 @@
size_t bodylen) /* Article body length. */
{
- int word_count, word_length, word_index, distinct_words;
+ unsigned long word_count, word_index, word_length, distinct_words;
int last;
char *text, *orig_text, *text_end, *this_word, *chase, *punc;
static struct word_entry *word_vec;
@@ -140,7 +140,7 @@
/* Now figure acceptable extents, and copy body to working string.
* (Memory-intensive for hefty articles: limit to non-ABSURD articles.) */
- if ((bodylen < 100) || (bodylen > (size_t) innconf->keyartlimit)) /* Too small/big to bother. */
+ if ((bodylen < 100) || (bodylen > innconf->keyartlimit)) /* Too small/big to bother. */
return;
/* Nul-terminate the body. orig_text will be freed later. */
Modified: innd/nc.c
===================================================================
--- innd/nc.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ innd/nc.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -114,7 +114,7 @@
#undef COMMAND
/* Number of open connections. */
-static int NCcount;
+static unsigned long NCcount;
static char *NCquietlist[] = { INND_QUIET_BADLIST };
static const char NCterm[] = "\r\n";
@@ -737,7 +737,8 @@
syslog(L_TRACE, "%s will read batch of size %d",
CHANname(cp), cp->XBatchSize);
- if (cp->XBatchSize <= 0 || ((innconf->maxartsize != 0) && (innconf->maxartsize < cp->XBatchSize))) {
+ if (cp->XBatchSize <= 0 || ((innconf->maxartsize != 0) &&
+ (innconf->maxartsize < (unsigned long) cp->XBatchSize))) {
syslog(L_NOTICE, "%s got bad xbatch size %d",
CHANname(cp), cp->XBatchSize);
NCwritereply(cp, NNTP_XBATCH_BADSIZE);
@@ -1296,8 +1297,8 @@
TMRstop(TMR_ARTPARSE);
if (cp->State == CSgetbody || cp->State == CSgetheader ||
cp->State == CSeatarticle) {
- if (cp->Next - cp->Start > (unsigned long) innconf->datamovethreshold
- || (innconf->maxartsize > 0 && cp->Size > innconf->maxartsize)) {
+ if (cp->Next - cp->Start > innconf->datamovethreshold
+ || (innconf->maxartsize != 0 && cp->Size > innconf->maxartsize)) {
/* avoid buffer extention for ever */
movedata = true;
} else {
@@ -1656,7 +1657,7 @@
}
/* See if we have too many channels. */
- if (!IsLocal && innconf->maxconnections &&
+ if (!IsLocal && innconf->maxconnections != 0 &&
NCcount >= innconf->maxconnections && !RCnolimit(cp)) {
/* Recount, just in case we got out of sync. */
for (NCcount = 0, i = 0; CHANiter(&i, CTnntp) != NULL; )
Modified: innd/status.c
===================================================================
--- innd/status.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ innd/status.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -139,7 +139,7 @@
#if defined(HTML_STATUS)
/* HTML Header */
- fprintf (F,"<HTML>\n<HEAD>\n<META HTTP-EQUIV=\"Refresh\" CONTENT=\"%ld;\">\n",
+ fprintf (F,"<HTML>\n<HEAD>\n<META HTTP-EQUIV=\"Refresh\" CONTENT=\"%lu;\">\n",
innconf->status < MIN_REFRESH ? MIN_REFRESH : innconf->status);
fprintf (F, "<TITLE>%s: incoming feeds</TITLE>\n", innconf->pathhost);
fprintf (F, "</HEAD>\n<BODY>\n<PRE>\n") ;
@@ -269,16 +269,16 @@
fprintf (F, "\n\nConfiguration file: %s\n\n", INN_PATH_CONFIG);
fprintf (F, "Global configuration parameters:\n");
- fprintf (F, " Largest Article: %ld bytes\n", innconf->maxartsize);
+ fprintf (F, " Largest Article: %lu bytes\n", innconf->maxartsize);
fprintf (F, " Max Incoming connections: ");
- if (innconf->maxconnections)
- fprintf (F, "%ld\n", innconf->maxconnections);
+ if (innconf->maxconnections != 0)
+ fprintf (F, "%lu\n", innconf->maxconnections);
else
fprintf (F, "unlimited\n");
fprintf (F, " Max Outgoing file feeds: %d\n", MaxOutgoing);
fprintf (F, " Cutoff: ");
- if (innconf->artcutoff)
- fprintf (F, "%ld days\n", innconf->artcutoff);
+ if (innconf->artcutoff != 0)
+ fprintf (F, "%lu days\n", innconf->artcutoff);
else
fprintf (F, "none\n");
fprintf (F, " Timeout period: %ld seconds\n",
@@ -399,11 +399,11 @@
{
unsigned now;
- if (!innconf->status)
+ if (innconf->status == 0)
return;
now = STATUSgettime();
- if (now - STATUSlast_time > (unsigned)(innconf->status * 1000)) {
+ if (now - STATUSlast_time > (innconf->status * 1000)) {
STATUSsummary();
STATUSlast_time = now;
}
Modified: innd/wip.c
===================================================================
--- innd/wip.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ innd/wip.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -106,7 +106,7 @@
WIPinprogress(const char *msgid, CHANNEL *cp, bool Precommit)
{
WIP *wp;
- int i;
+ unsigned long i;
if ((wp = WIPbyid(msgid)) != NULL) {
if(wp->Chan->ArtBeg == 0)
@@ -117,9 +117,9 @@
i = WIP_ARTMAX;
}
- if ((Now.tv_sec - wp->Timestamp) < (i + innconf->wipcheck))
+ if ((Now.tv_sec - wp->Timestamp) < (time_t) (i + innconf->wipcheck))
return true;
- if ((Now.tv_sec - wp->Timestamp) > (i + innconf->wipexpire)) {
+ if ((Now.tv_sec - wp->Timestamp) > (time_t) (i + innconf->wipexpire)) {
for (i = 0 ; i < PRECOMMITCACHESIZE ; i++) {
if (wp->Chan->PrecommitWIP[i] == wp) {
wp->Chan->PrecommitWIP[i] = (WIP *)NULL;
Modified: innfeed/endpoint.c
===================================================================
--- innfeed/endpoint.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ innfeed/endpoint.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -633,11 +633,11 @@
TMRstop(TMR_IDLE);
timePasses () ;
- if (innconf->timer)
+ if (innconf->timer != 0)
{
unsigned long now = TMRnow () ;
if (last_summary == 0
- || (long) (now - last_summary) > (innconf->timer * 1000))
+ || (now - last_summary) > (innconf->timer * 1000))
{
TMRsummary ("ME", timer_name) ;
last_summary = now;
Modified: innfeed/main.c
===================================================================
--- innfeed/main.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ innfeed/main.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -444,7 +444,7 @@
if (setfdlimit (innconf->rlimitnofile) < 0)
syswarn ("ME oserr setrlimit(RLIM_NOFILE,%ld)", innconf->rlimitnofile) ;
- if (innconf->timer > 0)
+ if (innconf->timer != 0)
TMRinit (TMR_MAX) ;
configHosts (talkToSelf) ;
Modified: lib/confparse.c
===================================================================
--- lib/confparse.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ lib/confparse.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -114,7 +114,8 @@
enum value_type {
VALUE_UNKNOWN,
VALUE_BOOL,
- VALUE_INTEGER,
+ VALUE_NUMBER,
+ VALUE_UNUMBER,
VALUE_REAL,
VALUE_STRING,
VALUE_LIST,
@@ -134,7 +135,8 @@
enum value_type type;
union {
bool boolean;
- long integer;
+ long signed_number;
+ unsigned long unsigned_number;
double real;
char *string;
struct vector *list;
@@ -181,7 +183,8 @@
/* Parameter type conversion functions. All take the parameter, the file, and
a pointer to where the result can be placed. */
static bool convert_boolean(struct config_parameter *, const char *, void *);
-static bool convert_integer(struct config_parameter *, const char *, void *);
+static bool convert_signed_number(struct config_parameter *, const char *, void *);
+static bool convert_unsigned_number(struct config_parameter *, const char *, void *);
static bool convert_real(struct config_parameter *, const char *, void *);
static bool convert_string(struct config_parameter *, const char *, void *);
static bool convert_list(struct config_parameter *, const char *, void *);
@@ -1305,14 +1308,14 @@
** successful and false otherwise.
*/
static bool
-convert_integer(struct config_parameter *param, const char *file,
- void *result)
+convert_signed_number(struct config_parameter *param, const char *file,
+ void *result)
{
long *value = result;
char *p;
- if (param->type == VALUE_INTEGER) {
- *value = param->value.integer;
+ if (param->type == VALUE_NUMBER) {
+ *value = param->value.signed_number;
return true;
} else if (param->type != VALUE_UNKNOWN) {
warn("%s:%u: %s is not an integer", file, param->line, param->key);
@@ -1334,19 +1337,67 @@
/* Do the actual conversion with strtol. */
errno = 0;
- param->value.integer = strtol(param->raw_value, NULL, 10);
+ param->value.signed_number = strtol(param->raw_value, NULL, 10);
if (errno != 0) {
warn("%s:%u: %s doesn't convert to an integer", file, param->line,
param->key);
return false;
}
- *value = param->value.integer;
- param->type = VALUE_INTEGER;
+ *value = param->value.signed_number;
+ param->type = VALUE_NUMBER;
return true;
}
/*
+** Convert a given parameter value to an unsigned integer, returning true
+** if successful and false otherwise.
+*/
+static bool
+convert_unsigned_number(struct config_parameter *param, const char *file,
+ void *result)
+{
+ unsigned long *value = result;
+ char *p;
+
+ if (param->type == VALUE_UNUMBER) {
+ *value = param->value.unsigned_number;
+ return true;
+ } else if (param->type != VALUE_UNKNOWN) {
+ warn("%s:%u: %s is not an integer", file, param->line, param->key);
+ return false;
+ }
+
+ /* Do a syntax check even though strtoul would do some of this for us,
+ * since otherwise some syntax errors may go silently undetected. */
+ p = param->raw_value;
+ if (*p == '-') {
+ warn("%s:%u: %s is not a positive integer", file, param->line, param->key);
+ return false;
+ }
+ for (; *p != '\0'; p++)
+ if (*p < '0' || *p > '9')
+ break;
+ if (*p != '\0') {
+ warn("%s:%u: %s is not an integer", file, param->line, param->key);
+ return false;
+ }
+
+ /* Do the actual conversion with strtoul. */
+ errno = 0;
+ param->value.unsigned_number = strtoul(param->raw_value, NULL, 10);
+ if (errno != 0) {
+ warn("%s:%u: %s doesn't convert to a positive integer", file, param->line,
+ param->key);
+ return false;
+ }
+ *value = param->value.unsigned_number;
+ param->type = VALUE_UNUMBER;
+ return true;
+}
+
+
+/*
** Convert a given parameter value to a real number, returning true if
** successful and false otherwise.
*/
@@ -1530,13 +1581,20 @@
}
bool
-config_param_integer(struct config_group *group, const char *key,
- long *result)
+config_param_signed_number(struct config_group *group, const char *key,
+ long *result)
{
- return group_parameter_get(group, key, result, convert_integer);
+ return group_parameter_get(group, key, result, convert_signed_number);
}
bool
+config_param_unsigned_number(struct config_group *group, const char *key,
+ unsigned long *result)
+{
+ return group_parameter_get(group, key, result, convert_unsigned_number);
+}
+
+bool
config_param_real(struct config_group *group, const char *key, double *result)
{
return group_parameter_get(group, key, result, convert_real);
Modified: lib/innconf.c
===================================================================
--- lib/innconf.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ lib/innconf.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -10,7 +10,7 @@
** When adding new inn.conf parameters, make sure to add them in all of the
** following places:
**
-** * The table in this file.
+** * The table in this file
** * include/inn/innconf.h
** * doc/pod/inn.conf.pod (and regenerate doc/man/inn.conf.5)
** * Add the default value to samples/inn.conf.in
@@ -43,6 +43,7 @@
enum type {
TYPE_BOOLEAN,
TYPE_NUMBER,
+ TYPE_UNUMBER,
TYPE_STRING,
TYPE_LIST
};
@@ -53,7 +54,8 @@
enum type type;
struct {
bool boolean;
- long integer;
+ long signed_number;
+ unsigned long unsigned_number;
const char *string;
const struct vector *list;
} defaults;
@@ -64,16 +66,18 @@
#define K(name) (#name), offsetof(struct innconf, name)
-#define BOOL(def) TYPE_BOOLEAN, { (def), 0, NULL, NULL }
-#define NUMBER(def) TYPE_NUMBER, { 0, (def), NULL, NULL }
-#define STRING(def) TYPE_STRING, { 0, 0, (def), NULL }
-#define LIST(def) TYPE_LIST, { 0, 0, NULL, (def) }
+#define BOOL(def) TYPE_BOOLEAN, { (def), 0, 0, NULL, NULL }
+#define NUMBER(def) TYPE_NUMBER, { 0, (def), 0, NULL, NULL }
+#define UNUMBER(def) TYPE_UNUMBER, { 0, 0, (def), NULL, NULL }
+#define STRING(def) TYPE_STRING, { 0, 0, 0, (def), NULL }
+#define LIST(def) TYPE_LIST, { 0, 0, 0, NULL, (def) }
/* Accessor macros to get a pointer to a value inside a struct. */
-#define CONF_BOOL(conf, offset) (bool *) (void *)((char *) (conf) + (offset))
-#define CONF_LONG(conf, offset) (long *) (void *)((char *) (conf) + (offset))
-#define CONF_STRING(conf, offset) (char **) (void *)((char *) (conf) + (offset))
-#define CONF_LIST(conf, offset) (struct vector **)(void *)((char *) (conf) + (offset))
+#define CONF_BOOL(conf, offset) (bool *) (void *)((char *) (conf) + (offset))
+#define CONF_NUMBER(conf, offset) (long *) (void *)((char *) (conf) + (offset))
+#define CONF_UNUMBER(conf, offset) (unsigned long *) (void *)((char *) (conf) + (offset))
+#define CONF_STRING(conf, offset) (char **) (void *)((char *) (conf) + (offset))
+#define CONF_LIST(conf, offset) (struct vector **)(void *)((char *) (conf) + (offset))
/* Special notes:
@@ -106,166 +110,166 @@
*/
const struct config config_table[] = {
- { K(domain), STRING (NULL) },
- { K(enableoverview), BOOL (true) },
- { K(extraoverviewadvertised), LIST (NULL) },
- { K(extraoverviewhidden), LIST (NULL) },
- { K(fromhost), STRING (NULL) },
- { K(groupbaseexpiry), BOOL (true) },
- { K(mailcmd), STRING (NULL) },
- { K(maxforks), NUMBER (10) },
- { K(mta), STRING (NULL) },
- { K(nicekids), NUMBER (4) },
- { K(ovmethod), STRING (NULL) },
- { K(pathhost), STRING (NULL) },
- { K(rlimitnofile), NUMBER (-1) },
- { K(server), STRING (NULL) },
- { K(sourceaddress), STRING (NULL) },
- { K(sourceaddress6), STRING (NULL) },
- { K(timer), NUMBER (0) },
+ { K(domain), STRING (NULL) },
+ { K(enableoverview), BOOL (true) },
+ { K(extraoverviewadvertised), LIST (NULL) },
+ { K(extraoverviewhidden), LIST (NULL) },
+ { K(fromhost), STRING (NULL) },
+ { K(groupbaseexpiry), BOOL (true) },
+ { K(mailcmd), STRING (NULL) },
+ { K(maxforks), UNUMBER (10) },
+ { K(mta), STRING (NULL) },
+ { K(nicekids), NUMBER (4) },
+ { K(ovmethod), STRING (NULL) },
+ { K(pathhost), STRING (NULL) },
+ { K(rlimitnofile), NUMBER (-1) },
+ { K(server), STRING (NULL) },
+ { K(sourceaddress), STRING (NULL) },
+ { K(sourceaddress6), STRING (NULL) },
+ { K(timer), UNUMBER (0) },
- { K(runasuser), STRING (RUNASUSER) },
- { K(runasgroup), STRING (RUNASGROUP) },
+ { K(runasuser), STRING (RUNASUSER) },
+ { K(runasgroup), STRING (RUNASGROUP) },
- { K(patharchive), STRING (NULL) },
- { K(patharticles), STRING (NULL) },
- { K(pathbin), STRING (NULL) },
- { K(pathcontrol), STRING (NULL) },
- { K(pathdb), STRING (NULL) },
- { K(pathetc), STRING (NULL) },
- { K(pathfilter), STRING (NULL) },
- { K(pathhttp), STRING (NULL) },
- { K(pathincoming), STRING (NULL) },
- { K(pathlog), STRING (NULL) },
- { K(pathnews), STRING (NULL) },
- { K(pathoutgoing), STRING (NULL) },
- { K(pathoverview), STRING (NULL) },
- { K(pathrun), STRING (NULL) },
- { K(pathspool), STRING (NULL) },
- { K(pathtmp), STRING (NULL) },
+ { K(patharchive), STRING (NULL) },
+ { K(patharticles), STRING (NULL) },
+ { K(pathbin), STRING (NULL) },
+ { K(pathcontrol), STRING (NULL) },
+ { K(pathdb), STRING (NULL) },
+ { K(pathetc), STRING (NULL) },
+ { K(pathfilter), STRING (NULL) },
+ { K(pathhttp), STRING (NULL) },
+ { K(pathincoming), STRING (NULL) },
+ { K(pathlog), STRING (NULL) },
+ { K(pathnews), STRING (NULL) },
+ { K(pathoutgoing), STRING (NULL) },
+ { K(pathoverview), STRING (NULL) },
+ { K(pathrun), STRING (NULL) },
+ { K(pathspool), STRING (NULL) },
+ { K(pathtmp), STRING (NULL) },
/* The following settings are specific to innd. */
- { K(artcutoff), NUMBER (10) },
- { K(badiocount), NUMBER (5) },
- { K(bindaddress), STRING (NULL) },
- { K(bindaddress6), STRING (NULL) },
- { K(blockbackoff), NUMBER (120) },
- { K(chaninacttime), NUMBER (600) },
- { K(chanretrytime), NUMBER (300) },
- { K(datamovethreshold), NUMBER (8192) },
- { K(dontrejectfiltered), BOOL (false) },
- { K(hiscachesize), NUMBER (256) },
- { K(icdsynccount), NUMBER (10) },
- { K(ignorenewsgroups), BOOL (false) },
- { K(incominglogfrequency), NUMBER (200) },
- { K(linecountfuzz), NUMBER (0) },
- { K(logartsize), BOOL (true) },
- { K(logcancelcomm), BOOL (false) },
- { K(logipaddr), BOOL (true) },
- { K(logsitename), BOOL (true) },
- { K(logstatus), BOOL (false) },
- { K(maxartsize), NUMBER (1000000) },
- { K(maxconnections), NUMBER (50) },
- { K(mergetogroups), BOOL (false) },
- { K(nntplinklog), BOOL (false) },
- { K(noreader), BOOL (false) },
- { K(pathalias), STRING (NULL) },
- { K(pathcluster), STRING (NULL) },
- { K(pauseretrytime), NUMBER (300) },
- { K(peertimeout), NUMBER (3600) },
- { K(port), NUMBER (119) },
- { K(readerswhenstopped), BOOL (false) },
- { K(refusecybercancels), BOOL (false) },
- { K(remembertrash), BOOL (true) },
- { K(stathist), STRING (NULL) },
- { K(status), NUMBER (0) },
- { K(verifycancels), BOOL (false) },
- { K(verifygroups), BOOL (false) },
- { K(wanttrash), BOOL (false) },
- { K(wipcheck), NUMBER (5) },
- { K(wipexpire), NUMBER (10) },
- { K(xrefslave), BOOL (false) },
+ { K(artcutoff), UNUMBER (10) },
+ { K(badiocount), UNUMBER (5) },
+ { K(bindaddress), STRING (NULL) },
+ { K(bindaddress6), STRING (NULL) },
+ { K(blockbackoff), UNUMBER (120) },
+ { K(chaninacttime), UNUMBER (600) },
+ { K(chanretrytime), UNUMBER (300) },
+ { K(datamovethreshold), UNUMBER (8192) },
+ { K(dontrejectfiltered), BOOL (false) },
+ { K(hiscachesize), UNUMBER (256) },
+ { K(icdsynccount), UNUMBER (10) },
+ { K(ignorenewsgroups), BOOL (false) },
+ { K(incominglogfrequency), UNUMBER (200) },
+ { K(linecountfuzz), UNUMBER (0) },
+ { K(logartsize), BOOL (true) },
+ { K(logcancelcomm), BOOL (false) },
+ { K(logipaddr), BOOL (true) },
+ { K(logsitename), BOOL (true) },
+ { K(logstatus), BOOL (false) },
+ { K(maxartsize), UNUMBER (1000000) },
+ { K(maxconnections), UNUMBER (50) },
+ { K(mergetogroups), BOOL (false) },
+ { K(nntplinklog), BOOL (false) },
+ { K(noreader), BOOL (false) },
+ { K(pathalias), STRING (NULL) },
+ { K(pathcluster), STRING (NULL) },
+ { K(pauseretrytime), UNUMBER (300) },
+ { K(peertimeout), UNUMBER (3600) },
+ { K(port), UNUMBER (119) },
+ { K(readerswhenstopped), BOOL (false) },
+ { K(refusecybercancels), BOOL (false) },
+ { K(remembertrash), BOOL (true) },
+ { K(stathist), STRING (NULL) },
+ { K(status), UNUMBER (0) },
+ { K(verifycancels), BOOL (false) },
+ { K(verifygroups), BOOL (false) },
+ { K(wanttrash), BOOL (false) },
+ { K(wipcheck), UNUMBER (5) },
+ { K(wipexpire), UNUMBER (10) },
+ { K(xrefslave), BOOL (false) },
/* The following settings are specific to nnrpd. */
- { K(addnntppostingdate), BOOL (true) },
- { K(addnntppostinghost), BOOL (true) },
- { K(allownewnews), BOOL (true) },
- { K(backoffauth), BOOL (false) },
- { K(backoffdb), STRING (NULL) },
- { K(backoffk), NUMBER (1) },
- { K(backoffpostfast), NUMBER (0) },
- { K(backoffpostslow), NUMBER (1) },
- { K(backofftrigger), NUMBER (10000) },
- { K(checkincludedtext), BOOL (false) },
- { K(clienttimeout), NUMBER (1800) },
- { K(complaints), STRING (NULL) },
- { K(initialtimeout), NUMBER (10) },
- { K(keyartlimit), NUMBER (100000) },
- { K(keylimit), NUMBER (512) },
- { K(keymaxwords), NUMBER (250) },
- { K(keywords), BOOL (false) },
- { K(localmaxartsize), NUMBER (1000000) },
- { K(maxcmdreadsize), NUMBER (BUFSIZ) },
- { K(msgidcachesize), NUMBER (16000) },
- { K(moderatormailer), STRING (NULL) },
- { K(nfsreader), BOOL (false) },
- { K(nfsreaderdelay), NUMBER (60) },
- { K(nicenewnews), NUMBER (0) },
- { K(nicennrpd), NUMBER (0) },
- { K(nnrpdflags), STRING ("") },
- { K(nnrpdauthsender), BOOL (false) },
- { K(nnrpdloadlimit), NUMBER (16) },
- { K(nnrpdoverstats), BOOL (false) },
- { K(organization), STRING (NULL) },
- { K(readertrack), BOOL (false) },
- { K(spoolfirst), BOOL (false) },
- { K(strippostcc), BOOL (false) },
+ { K(addnntppostingdate), BOOL (true) },
+ { K(addnntppostinghost), BOOL (true) },
+ { K(allownewnews), BOOL (true) },
+ { K(backoffauth), BOOL (false) },
+ { K(backoffdb), STRING (NULL) },
+ { K(backoffk), UNUMBER (1) },
+ { K(backoffpostfast), UNUMBER (0) },
+ { K(backoffpostslow), UNUMBER (1) },
+ { K(backofftrigger), UNUMBER (10000) },
+ { K(checkincludedtext), BOOL (false) },
+ { K(clienttimeout), UNUMBER (1800) },
+ { K(complaints), STRING (NULL) },
+ { K(initialtimeout), UNUMBER (10) },
+ { K(keyartlimit), UNUMBER (100000) },
+ { K(keylimit), UNUMBER (512) },
+ { K(keymaxwords), UNUMBER (250) },
+ { K(keywords), BOOL (false) },
+ { K(localmaxartsize), UNUMBER (1000000) },
+ { K(maxcmdreadsize), UNUMBER (BUFSIZ) },
+ { K(msgidcachesize), UNUMBER (16000) },
+ { K(moderatormailer), STRING (NULL) },
+ { K(nfsreader), BOOL (false) },
+ { K(nfsreaderdelay), UNUMBER (60) },
+ { K(nicenewnews), UNUMBER (0) },
+ { K(nicennrpd), UNUMBER (0) },
+ { K(nnrpdflags), STRING ("") },
+ { K(nnrpdauthsender), BOOL (false) },
+ { K(nnrpdloadlimit), UNUMBER (16) },
+ { K(nnrpdoverstats), BOOL (false) },
+ { K(organization), STRING (NULL) },
+ { K(readertrack), BOOL (false) },
+ { K(spoolfirst), BOOL (false) },
+ { K(strippostcc), BOOL (false) },
#ifdef HAVE_SSL
- { K(tlscafile), STRING ("") },
- { K(tlscapath), STRING (NULL) },
- { K(tlscertfile), STRING (NULL) },
- { K(tlskeyfile), STRING (NULL) },
+ { K(tlscafile), STRING ("") },
+ { K(tlscapath), STRING (NULL) },
+ { K(tlscertfile), STRING (NULL) },
+ { K(tlskeyfile), STRING (NULL) },
#endif /* HAVE_SSL */
/* The following settings are used by nnrpd and rnews. */
- { K(nnrpdposthost), STRING (NULL) },
- { K(nnrpdpostport), NUMBER (119) },
+ { K(nnrpdposthost), STRING (NULL) },
+ { K(nnrpdpostport), UNUMBER (119) },
/* The following settings are specific to the storage subsystem. */
- { K(articlemmap), BOOL (true) },
- { K(cnfscheckfudgesize), NUMBER (0) },
- { K(immediatecancel), BOOL (false) },
- { K(keepmmappedthreshold), NUMBER (1024) },
- { K(nfswriter), BOOL (false) },
- { K(nnrpdcheckart), BOOL (true) },
- { K(overcachesize), NUMBER (64) },
- { K(ovgrouppat), STRING (NULL) },
- { K(storeonxref), BOOL (true) },
- { K(tradindexedmmap), BOOL (true) },
- { K(useoverchan), BOOL (false) },
- { K(wireformat), BOOL (false) },
+ { K(articlemmap), BOOL (true) },
+ { K(cnfscheckfudgesize), UNUMBER (0) },
+ { K(immediatecancel), BOOL (false) },
+ { K(keepmmappedthreshold), UNUMBER (1024) },
+ { K(nfswriter), BOOL (false) },
+ { K(nnrpdcheckart), BOOL (true) },
+ { K(overcachesize), UNUMBER (64) },
+ { K(ovgrouppat), STRING (NULL) },
+ { K(storeonxref), BOOL (true) },
+ { K(tradindexedmmap), BOOL (true) },
+ { K(useoverchan), BOOL (false) },
+ { K(wireformat), BOOL (false) },
/* The following settings are specific to the history subsystem. */
- { K(hismethod), STRING (NULL) },
+ { K(hismethod), STRING (NULL) },
/* The following settings are specific to rc.news. */
- { K(docnfsstat), BOOL (false) },
- { K(innflags), STRING (NULL) },
- { K(pgpverify), BOOL (false) },
+ { K(docnfsstat), BOOL (false) },
+ { K(innflags), STRING (NULL) },
+ { K(pgpverify), BOOL (false) },
/* The following settings are specific to innwatch. */
- { K(doinnwatch), BOOL (true) },
- { K(innwatchbatchspace), NUMBER (4000) },
- { K(innwatchlibspace), NUMBER (25000) },
- { K(innwatchloload), NUMBER (1000) },
- { K(innwatchhiload), NUMBER (2000) },
- { K(innwatchpauseload), NUMBER (1500) },
- { K(innwatchsleeptime), NUMBER (600) },
- { K(innwatchspoolnodes), NUMBER (200) },
- { K(innwatchspoolspace), NUMBER (25000) },
+ { K(doinnwatch), BOOL (true) },
+ { K(innwatchbatchspace), UNUMBER (4000) },
+ { K(innwatchlibspace), UNUMBER (25000) },
+ { K(innwatchloload), UNUMBER (1000) },
+ { K(innwatchhiload), UNUMBER (2000) },
+ { K(innwatchpauseload), UNUMBER (1500) },
+ { K(innwatchsleeptime), UNUMBER (600) },
+ { K(innwatchspoolnodes), UNUMBER (200) },
+ { K(innwatchspoolspace), UNUMBER (25000) },
/* The following settings are specific to scanlogs. */
- { K(logcycles), NUMBER (3) },
+ { K(logcycles), UNUMBER (3) },
};
@@ -385,7 +389,8 @@
{
unsigned int i, j;
bool *bool_ptr;
- long *long_ptr;
+ long *signed_number_ptr;
+ unsigned long *unsigned_number_ptr;
const char *char_ptr;
char **string;
const struct vector *vector_ptr;
@@ -401,10 +406,15 @@
*bool_ptr = config_table[i].defaults.boolean;
break;
case TYPE_NUMBER:
- long_ptr = CONF_LONG(config, config_table[i].location);
- if (!config_param_integer(group, config_table[i].name, long_ptr))
- *long_ptr = config_table[i].defaults.integer;
+ signed_number_ptr = CONF_NUMBER(config, config_table[i].location);
+ if (!config_param_signed_number(group, config_table[i].name, signed_number_ptr))
+ *signed_number_ptr = config_table[i].defaults.signed_number;
break;
+ case TYPE_UNUMBER:
+ unsigned_number_ptr = CONF_UNUMBER(config, config_table[i].location);
+ if (!config_param_unsigned_number(group, config_table[i].name, unsigned_number_ptr))
+ *unsigned_number_ptr = config_table[i].defaults.unsigned_number;
+ break;
case TYPE_STRING:
if (!config_param_string(group, config_table[i].name, &char_ptr))
char_ptr = config_table[i].defaults.string;
@@ -447,7 +457,7 @@
innconf_validate(struct config_group *group)
{
bool okay = true;
- long threshold;
+ unsigned long threshold;
if (GetFQDN(innconf->domain) == NULL) {
warn("hostname does not resolve or domain not set in inn.conf");
@@ -471,7 +481,7 @@
}
threshold = innconf->datamovethreshold;
- if (threshold <= 0 || threshold > 1024 * 1024) {
+ if (threshold > 1024 * 1024) {
config_error_param(group, "datamovethreshold",
"maximum value for datamovethreshold is 1MB");
innconf->datamovethreshold = 1024 * 1024;
@@ -641,11 +651,11 @@
/*
-** Print a single integer value with appropriate quoting.
+** Print a single signed integer value with appropriate quoting.
*/
static void
-print_number(FILE *file, const char *key, long value,
- enum innconf_quoting quoting)
+print_signed_number(FILE *file, const char *key, long value,
+ enum innconf_quoting quoting)
{
char *upper, *p;
@@ -671,6 +681,36 @@
/*
+** Print a single unsigned integer value with appropriate quoting.
+*/
+static void
+print_unsigned_number(FILE *file, const char *key, unsigned long value,
+ enum innconf_quoting quoting)
+{
+ char *upper, *p;
+
+ switch (quoting) {
+ case INNCONF_QUOTE_NONE:
+ fprintf(file, "%lu\n", value);
+ break;
+ case INNCONF_QUOTE_SHELL:
+ upper = xstrdup(key);
+ for (p = upper; *p != '\0'; p++)
+ *p = toupper(*p);
+ fprintf(file, "%s=%lu; export %s;\n", upper, value, upper);
+ free(upper);
+ break;
+ case INNCONF_QUOTE_PERL:
+ fprintf(file, "$%s = %lu;\n", key, value);
+ break;
+ case INNCONF_QUOTE_TCL:
+ fprintf(file, "set inn_%s %lu\n", key, value);
+ break;
+ }
+}
+
+
+/*
** Print a single string value with appropriate quoting.
*/
static void
@@ -828,7 +868,8 @@
print_parameter(FILE *file, size_t i, enum innconf_quoting quoting)
{
bool bool_val;
- long long_val;
+ long signed_number_val;
+ unsigned long unsigned_number_val;
const char *string_val;
const struct vector *list_val;
@@ -838,9 +879,13 @@
print_boolean(file, config_table[i].name, bool_val, quoting);
break;
case TYPE_NUMBER:
- long_val = *CONF_LONG(innconf, config_table[i].location);
- print_number(file, config_table[i].name, long_val, quoting);
+ signed_number_val = *CONF_NUMBER(innconf, config_table[i].location);
+ print_signed_number(file, config_table[i].name, signed_number_val, quoting);
break;
+ case TYPE_UNUMBER:
+ unsigned_number_val = *CONF_UNUMBER(innconf, config_table[i].location);
+ print_unsigned_number(file, config_table[i].name, unsigned_number_val, quoting);
+ break;
case TYPE_STRING:
string_val = *CONF_STRING(innconf, config_table[i].location);
print_string(file, config_table[i].name, string_val, quoting);
@@ -899,7 +944,8 @@
{
unsigned int i, j;
bool bool1, bool2;
- long long1, long2;
+ long signed_number1, signed_number2;
+ unsigned long unsigned_number1, unsigned_number2;
const char *string1, *string2;
const struct vector *list1, *list2;
bool okay = true;
@@ -916,14 +962,23 @@
}
break;
case TYPE_NUMBER:
- long1 = *CONF_LONG(conf1, config_table[i].location);
- long2 = *CONF_LONG(conf2, config_table[i].location);
- if (long1 != long2) {
+ signed_number1 = *CONF_NUMBER(conf1, config_table[i].location);
+ signed_number2 = *CONF_NUMBER(conf2, config_table[i].location);
+ if (signed_number1 != signed_number2) {
warn("integer variable %s differs: %ld != %ld",
- config_table[i].name, long1, long2);
+ config_table[i].name, signed_number1, signed_number2);
okay = false;
}
break;
+ case TYPE_UNUMBER:
+ unsigned_number1 = *CONF_UNUMBER(conf1, config_table[i].location);
+ unsigned_number2 = *CONF_UNUMBER(conf2, config_table[i].location);
+ if (unsigned_number1 != unsigned_number2) {
+ warn("integer variable %s differs: %lu != %lu",
+ config_table[i].name, unsigned_number1, unsigned_number2);
+ okay = false;
+ }
+ break;
case TYPE_STRING:
string1 = *CONF_STRING(conf1, config_table[i].location);
string2 = *CONF_STRING(conf2, config_table[i].location);
Modified: nnrpd/cache.c
===================================================================
--- nnrpd/cache.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ nnrpd/cache.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -31,7 +31,7 @@
** (X)OVER, GROUP, (X)OVER, etc. for example doesn't blow up with
** out of memory.
*/
-static int msgcachecount;
+static unsigned long msgcachecount;
struct cache_entry {
struct node node;
Modified: nnrpd/commands.c
===================================================================
--- nnrpd/commands.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ nnrpd/commands.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -158,9 +158,9 @@
}
for (i = 0; (pid = fork()) < 0; i++) {
- if (i == innconf->maxforks) {
- Reply("%d Can't fork %s\r\n", NNTP_FAIL_ACTION,
- strerror(errno));
+ if (i == (long) innconf->maxforks) {
+ Reply("%d Can't fork %s\r\n", NNTP_FAIL_ACTION,
+ strerror(errno));
syslog(L_FATAL, "can't fork %s %m", av[0]);
return -1;
}
@@ -176,8 +176,8 @@
/* stderr goes down the pipe. */
if (pan[PIPE_WRITE] != STDERR_FILENO) {
if ((i = dup2(pan[PIPE_WRITE], STDERR_FILENO)) != STDERR_FILENO) {
- syslog(L_FATAL, "can't dup2 %d to %d got %d %m",
- pan[PIPE_WRITE], STDERR_FILENO, i);
+ syslog(L_FATAL, "can't dup2 %d to %d got %d %m",
+ pan[PIPE_WRITE], STDERR_FILENO, i);
_exit(1);
}
close(pan[PIPE_WRITE]);
Modified: nnrpd/group.c
===================================================================
--- nnrpd/group.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ nnrpd/group.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -125,7 +125,7 @@
* last nfsreaderdelay (default 60) seconds. If they did,
* don't report them as we don't want them to appear too
* soon. */
- if (innconf->nfsreader) {
+ if (innconf->nfsreader != 0) {
ARTNUM low, prev;
time_t now, arrived;
@@ -144,7 +144,7 @@
}
prev = low;
while (OVsearch(handle, &i, NULL, NULL, NULL, &arrived)) {
- if (arrived + innconf->nfsreaderdelay > now) {
+ if ((time_t) (arrived + innconf->nfsreaderdelay) > now) {
ARThigh = prev;
/* No need to update the count since it is only
* an estimate but make sure it is not too high. */
Modified: nnrpd/line.c
===================================================================
--- nnrpd/line.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ nnrpd/line.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -168,7 +168,7 @@
/* Don't grow the buffer bigger than the maximum
* article size we'll accept. */
if (PERMaccessconf->localmaxartsize > NNTP_MAXLEN_COMMAND)
- if (newsize > (unsigned)PERMaccessconf->localmaxartsize)
+ if (newsize > PERMaccessconf->localmaxartsize)
newsize = PERMaccessconf->localmaxartsize;
/* If we're trying to grow from the same size, to the
@@ -178,7 +178,7 @@
* size any more, just overwrite characters until they
* stop, then discard the whole thing. */
if (newsize == line->allocated) {
- warn("%s overflowed our line buffer (%ld), "
+ warn("%s overflowed our line buffer (%lu), "
"discarding further input", Client.host,
PERMaccessconf->localmaxartsize);
where = line->start;
Modified: nnrpd/misc.c
===================================================================
--- nnrpd/misc.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ nnrpd/misc.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -181,7 +181,7 @@
/* Read the runtime config file to get parameters. */
if ((PERMaccessconf->backoff_db == NULL) ||
- !(PERMaccessconf->backoff_k >= 0L && PERMaccessconf->backoff_postfast >= 0L && PERMaccessconf->backoff_postslow >= 1L))
+ !(PERMaccessconf->backoff_postslow >= 1L))
return;
/* Need this database for backing off. */
@@ -284,7 +284,8 @@
/* No lock. See if the file is there. */
if (stat(lockname, &st) < 0) {
syslog(L_ERROR, "%s cannot stat lock file %s", Client.host, strerror(errno));
- if (statfailed++ > 5) return(0);
+ if (statfailed++ > 5)
+ return(0);
continue;
}
@@ -292,7 +293,8 @@
* PERMaccessconf->backoff_postslow, remove it. */
statfailed = 0;
time(&now);
- if (now < st.st_ctime + PERMaccessconf->backoff_postslow) continue;
+ if (now < (time_t) (st.st_ctime + PERMaccessconf->backoff_postslow))
+ continue;
syslog(L_ERROR, "%s removing stale lock file %s", Client.host, lockname);
unlink(lockname);
}
@@ -386,7 +388,7 @@
now = time(NULL);
prevpost = 0L; prevsleep = 0L; prevn = 0L; n = 0L;
- if (!GetPostRecord(path,&prevpost,&prevsleep,&prevn)) {
+ if (!GetPostRecord(path, &prevpost, &prevsleep, &prevn)) {
syslog(L_ERROR, "%s can't get post record: %s",
Client.host, strerror(errno));
return 0;
@@ -397,7 +399,7 @@
prevn = 0L;
if (prevsleep < 0L)
prevsleep = 0L;
- if (prevsleep > PERMaccessconf->backoff_postfast)
+ if ((unsigned long) prevsleep > PERMaccessconf->backoff_postfast)
prevsleep = PERMaccessconf->backoff_postfast;
/* Compute the new sleep time. */
@@ -412,12 +414,12 @@
Client.host,n);
n = 0L;
}
- if (n < PERMaccessconf->backoff_postfast) {
- if (prevn >= PERMaccessconf->backoff_trigger) {
+ if ((unsigned long) n < PERMaccessconf->backoff_postfast) {
+ if ((unsigned long) prevn >= PERMaccessconf->backoff_trigger) {
*sleeptime = 1 + (prevsleep * PERMaccessconf->backoff_k);
}
- } else if (n < PERMaccessconf->backoff_postslow) {
- if (prevn >= PERMaccessconf->backoff_trigger) {
+ } else if ((unsigned long) n < PERMaccessconf->backoff_postslow) {
+ if ((unsigned long) prevn >= PERMaccessconf->backoff_trigger) {
*sleeptime = prevsleep;
}
} else {
@@ -426,15 +428,17 @@
prevn++;
}
- *sleeptime = ((*sleeptime) > PERMaccessconf->backoff_postfast) ? PERMaccessconf->backoff_postfast : (*sleeptime);
+ *sleeptime = ((*sleeptime) > (long) PERMaccessconf->backoff_postfast) ?
+ (long) PERMaccessconf->backoff_postfast : (*sleeptime);
/* This ought to trap this bogon. */
if ((*sleeptime) < 0L) {
- syslog(L_ERROR,"%s Negative sleeptime detected: %ld, prevsleep: %ld, N: %ld",Client.host,*sleeptime,prevsleep,n);
+ syslog(L_ERROR,"%s Negative sleeptime detected: %ld, prevsleep: %ld, N: %ld",
+ Client.host, *sleeptime, prevsleep, n);
*sleeptime = 0L;
}
/* Store the postrecord. */
- if (!StorePostRecord(path,now,*sleeptime,prevn)) {
+ if (!StorePostRecord(path, now, *sleeptime, prevn)) {
syslog(L_ERROR, "%s can't store post record: %s", Client.host, strerror(errno));
return 0;
}
Modified: nnrpd/newnews.c
===================================================================
--- nnrpd/newnews.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ nnrpd/newnews.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -165,11 +165,11 @@
time(&now);
/* Move the start time back nfsreaderdelay seconds
* as we are an NFS reader. */
- if (date >= innconf->nfsreaderdelay)
+ if (date >= (time_t) innconf->nfsreaderdelay)
date -= innconf->nfsreaderdelay;
}
while (OVsearch(handle, &artnum, &data, &len, &token, &arrived)) {
- if (innconf->nfsreader && arrived + innconf->nfsreaderdelay > now)
+ if (innconf->nfsreader != 0 && (time_t) (arrived + innconf->nfsreaderdelay) > now)
continue;
if (len == 0 || date > arrived)
continue;
@@ -285,7 +285,7 @@
}
/* Make other processes happier if someone uses NEWNEWS. */
- if (innconf->nicenewnews > 0) {
+ if (innconf->nicenewnews != 0) {
nice(innconf->nicenewnews);
innconf->nicenewnews = 0;
}
Modified: nnrpd/nnrpd.c
===================================================================
--- nnrpd/nnrpd.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ nnrpd/nnrpd.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -974,7 +974,7 @@
/* Make other processes happier if someone is reading. This allows other
* processes like overchan to keep up when there are lots of readers.
* Note that this is cumulative with nicekids. */
- if (innconf->nicennrpd > 0)
+ if (innconf->nicennrpd != 0)
nice(innconf->nicennrpd);
HISTORY = concatpath(innconf->pathdb, INN_PATH_HISTORY);
@@ -1133,8 +1133,8 @@
if (fd < 0)
continue;
- for (i = 0; i <= innconf->maxforks && (pid = fork()) < 0; i++) {
- if (i == innconf->maxforks) {
+ for (i = 0; i <= (long) innconf->maxforks && (pid = fork()) < 0; i++) {
+ if (i == (long) innconf->maxforks) {
syslog(L_FATAL, "can't fork (dropping connection): %m");
continue;
}
@@ -1175,7 +1175,7 @@
xsignal(SIGCHLD, SIG_DFL);
} else {
- if (innconf->timer)
+ if (innconf->timer != 0)
TMRinit(TMR_MAX);
STATstart = TMRnow_double();
SetupDaemon();
@@ -1195,14 +1195,14 @@
#endif /* HAVE_SSL */
/* If requested, check the load average. */
- if (innconf->nnrpdloadlimit > 0) {
+ if (innconf->nnrpdloadlimit != 0) {
double load[1];
if (getloadavg(load, 1) < 0)
warn("cannot obtain system load");
else {
- if ((int)(load[0] + 0.5) > innconf->nnrpdloadlimit) {
- syslog(L_NOTICE, "load %.2f > %ld", load[0], innconf->nnrpdloadlimit);
+ if ((unsigned long)(load[0] + 0.5) > innconf->nnrpdloadlimit) {
+ syslog(L_NOTICE, "load %.2f > %lu", load[0], innconf->nnrpdloadlimit);
Reply("%d load at %.2f, try later\r\n", NNTP_FAIL_TERMINATING,
load[0]);
ExitWithStats(1, true);
Modified: nnrpd/nnrpd.h
===================================================================
--- nnrpd/nnrpd.h 2009-11-06 18:11:01 UTC (rev 8708)
+++ nnrpd/nnrpd.h 2009-11-06 21:47:11 UTC (rev 8709)
@@ -62,20 +62,20 @@
int spoolfirst;
int checkincludedtext;
int clienttimeout;
- long localmaxartsize;
+ unsigned long localmaxartsize;
int readertrack;
int strippostcc;
int addnntppostinghost;
int addnntppostingdate;
char *nnrpdposthost;
- int nnrpdpostport;
+ unsigned long nnrpdpostport;
int nnrpdoverstats;
int backoff_auth;
char *backoff_db;
- long backoff_k;
- long backoff_postfast;
- long backoff_postslow;
- long backoff_trigger;
+ unsigned long backoff_k;
+ unsigned long backoff_postfast;
+ unsigned long backoff_postslow;
+ unsigned long backoff_trigger;
int nnrpdcheckart;
int nnrpdauthsender;
int virtualhost;
Modified: nnrpd/perm.c
===================================================================
--- nnrpd/perm.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ nnrpd/perm.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -958,7 +958,7 @@
SET_CONFIG(oldtype);
break;
case PERMlocalmaxartsize:
- curaccess->localmaxartsize = atol(tok->name);
+ curaccess->localmaxartsize = strtoul(tok->name, NULL, 10);
SET_CONFIG(oldtype);
break;
case PERMreadertrack:
@@ -984,7 +984,7 @@
SET_CONFIG(oldtype);
break;
case PERMnnrpdpostport:
- curaccess->nnrpdpostport = atoi(tok->name);
+ curaccess->nnrpdpostport = strtoul(tok->name, NULL, 10);
SET_CONFIG(oldtype);
break;
case PERMnnrpdoverstats:
@@ -1002,19 +1002,19 @@
SET_CONFIG(oldtype);
break;
case PERMbackoff_k:
- curaccess->backoff_k = atol(tok->name);
+ curaccess->backoff_k = strtoul(tok->name, NULL, 10);
SET_CONFIG(oldtype);
break;
case PERMbackoff_postfast:
- curaccess->backoff_postfast = atol(tok->name);
+ curaccess->backoff_postfast = strtoul(tok->name, NULL, 10);
SET_CONFIG(oldtype);
break;
case PERMbackoff_postslow:
- curaccess->backoff_postslow = atol(tok->name);
+ curaccess->backoff_postslow = strtoul(tok->name, NULL, 10);
SET_CONFIG(oldtype);
break;
case PERMbackoff_trigger:
- curaccess->backoff_trigger = atol(tok->name);
+ curaccess->backoff_trigger = strtoul(tok->name, NULL, 10);
SET_CONFIG(oldtype);
break;
case PERMnnrpdcheckart:
Modified: nnrpd/post.c
===================================================================
--- nnrpd/post.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ nnrpd/post.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -1023,10 +1023,10 @@
free(modgroup);
return error;
}
- if ((PERMaccessconf->localmaxartsize > 0) &&
- (strlen(article) > (unsigned)PERMaccessconf->localmaxartsize)) {
+ if ((PERMaccessconf->localmaxartsize != 0) &&
+ (strlen(article) > PERMaccessconf->localmaxartsize)) {
snprintf(Error, sizeof(Error),
- "Article is bigger than local limit of %ld bytes\n",
+ "Article is bigger than local limit of %lu bytes\n",
PERMaccessconf->localmaxartsize);
if (modgroup)
free(modgroup);
Modified: storage/buffindexed/buffindexed.c
===================================================================
--- storage/buffindexed/buffindexed.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ storage/buffindexed/buffindexed.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -114,7 +114,7 @@
header */
void * bitfield; /* Bitfield for ovbuff block in
use */
- int dirty; /* OVBUFFHEAD dirty count */
+ unsigned long dirty; /* OVBUFFHEAD dirty count */
struct _OVBUFF *next; /* next ovbuff */
int nextchunk; /* next chunk */
smcd_t *smc; /* shared mem control data */
@@ -1715,7 +1715,7 @@
}
if (count == 0)
return true;
- if (count * OV_BLOCKSIZE > innconf->keepmmappedthreshold * 1024)
+ if ((unsigned) count * OV_BLOCKSIZE > innconf->keepmmappedthreshold * 1024)
/* large retrieval, mmap is done in ovsearch() */
return true;
/* Data blocks are being mmapped, not copied. */
@@ -2321,7 +2321,7 @@
/* sync the bit field */
ovbuff = ovbufftab;
for (; ovbuff != (OVBUFF *)NULL; ovbuff = ovbuffnext) {
- if (ovbuff->dirty) {
+ if (ovbuff->dirty != 0) {
ovbuff->dirty = OVBUFF_SYNC_COUNT + 1;
ovflushhead(ovbuff);
}
Modified: storage/cnfs/cnfs.c
===================================================================
--- storage/cnfs/cnfs.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ storage/cnfs/cnfs.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -1382,7 +1382,7 @@
/* checking the bitmap to ensure cah.size is not broken was dropped */
cycsize = ntohl(cah.size);
if (innconf->cnfscheckfudgesize != 0 && innconf->maxartsize != 0 &&
- (cycsize > innconf->maxartsize + innconf->cnfscheckfudgesize)) {
+ ((unsigned) cycsize > innconf->maxartsize + innconf->cnfscheckfudgesize)) {
char buf1[24];
strlcpy(buf1, CNFSofft2hex(cycbuff->free, false), sizeof(buf1));
SMseterror(SMERR_UNDEFINED, "CNFSARTHEADER fudge size overflow");
@@ -1708,7 +1708,7 @@
}
}
if (innconf->cnfscheckfudgesize != 0 && innconf->maxartsize != 0 &&
- ((off_t) ntohl(cah.size) > innconf->maxartsize + innconf->cnfscheckfudgesize)) {
+ (ntohl(cah.size) > innconf->maxartsize + innconf->cnfscheckfudgesize)) {
art->data = NULL;
art->len = 0;
art->token = NULL;
Modified: storage/tradindexed/tradindexed.c
===================================================================
--- storage/tradindexed/tradindexed.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ storage/tradindexed/tradindexed.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -82,7 +82,7 @@
bool
tradindexed_open(int mode)
{
- unsigned int cache_size, fdlimit;
+ unsigned long cache_size, fdlimit;
if (tradindexed != NULL) {
warn("tradindexed: overview method already open");
@@ -99,8 +99,8 @@
fdlimit = getfdlimit();
if (fdlimit > 0 && fdlimit < cache_size * 2) {
warn("tradindexed: not enough file descriptors for an overview cache"
- " size of %u; increase rlimitnofile or decrease overcachesize"
- " to at most %u", cache_size, fdlimit / 2);
+ " size of %lu; increase rlimitnofile or decrease overcachesize"
+ " to at most %lu", cache_size, fdlimit / 2);
cache_size = (fdlimit > 2) ? fdlimit / 2 : 1;
}
tradindexed->cache = tdx_cache_create(cache_size);
Added: tests/data/config/warn-list
===================================================================
--- tests/data/config/warn-list (rev 0)
+++ tests/data/config/warn-list 2009-11-06 21:47:11 UTC (rev 8709)
@@ -0,0 +1,4 @@
+parameter: "\c"
+===
+config/tmp:1: unrecognized escape '\c'
+===
Property changes on: trunk/tests/data/config/warn-list
___________________________________________________________________
Added: svn:eol-style
+ native
Added: tests/data/config/warn-uint
===================================================================
--- tests/data/config/warn-uint (rev 0)
+++ tests/data/config/warn-uint 2009-11-06 21:47:11 UTC (rev 8709)
@@ -0,0 +1,25 @@
+parameter: "foo"
+===
+config/tmp:1: parameter is not an integer
+===
+# Check that line numbers are right.
+key: value; parameter: foobar
+===
+config/tmp:2: parameter is not an integer
+===
+parameter: 999999999999999999999999999999999999999999999999999999999999
+===
+config/tmp:1: parameter doesn't convert to a positive integer
+===
+parameter: -3
+===
+config/tmp:1: parameter is not a positive integer
+===
+parameter: []
+===
+config/tmp:1: parameter is not an integer
+===
+parameter: [ 10 ]
+===
+config/tmp:1: parameter is not an integer
+===
Property changes on: trunk/tests/data/config/warn-uint
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: tests/innd/artparse-t.c
===================================================================
--- tests/innd/artparse-t.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ tests/innd/artparse-t.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -151,7 +151,7 @@
message_handlers_warn(1, message_log_stderr);
}
ok(n++, okay);
- if (wirelen > (size_t) innconf->maxartsize)
+ if (wirelen > innconf->maxartsize)
expected = CSgotlargearticle;
else if (wirelen == 5)
expected = CSnoarticle;
Modified: tests/lib/confparse-t.c
===================================================================
--- tests/lib/confparse-t.c 2009-11-06 18:11:01 UTC (rev 8708)
+++ tests/lib/confparse-t.c 2009-11-06 21:47:11 UTC (rev 8709)
@@ -114,6 +114,8 @@
ok(n++, group == NULL);
ok_string(n++, expected, errors);
free(expected);
+ if (group != NULL)
+ config_free(group);
}
fclose(errfile);
unlink("config/link");
@@ -140,7 +142,8 @@
ok(n++, group != NULL);
ok_string(n++, expected, errors);
free(expected);
- config_free(group);
+ if (group != NULL)
+ config_free(group);
}
fclose(warnfile);
return n;
@@ -171,7 +174,8 @@
ok_string(n++, expected, errors);
errors_uncapture();
free(expected);
- config_free(group);
+ if (group != NULL)
+ config_free(group);
}
fclose(warnfile);
return n;
@@ -179,7 +183,8 @@
/* Test the warning test cases in config/warn-int, ensuring that they all
parse successfully and produce the expected error messages when retrieved
- as bools. Takes the current test count and returns the new test count. */
+ as signed numbers. Takes the current test count and returns the new test
+ count. */
static int
test_warnings_int(int n)
{
@@ -198,19 +203,53 @@
ok(n++, group != NULL);
ok(n++, errors == NULL);
errors_capture();
- ok(n++, !config_param_integer(group, "parameter", &l_value));
+ ok(n++, !config_param_signed_number(group, "parameter", &l_value));
ok_string(n++, expected, errors);
errors_uncapture();
free(expected);
- config_free(group);
+ if (group != NULL)
+ config_free(group);
}
fclose(warnfile);
return n;
}
+/* Test the warning test cases in config/warn-uint, ensuring that they all
+ parse successfully and produce the expected error messages when retrieved
+ as usigned numbers. Takes the current test count and returns the new test
+ count. */
+static int
+test_warnings_uint(int n)
+{
+ FILE *warnfile;
+ char *expected;
+ struct config_group *group;
+ unsigned long lu_value = 1;
+
+ warnfile = fopen("config/warn-uint", "r");
+ if (warnfile == NULL)
+ sysdie("Cannot open config/warn-uint");
+ while (parse_test_config(warnfile, &group)) {
+ expected = read_section(warnfile);
+ if (expected == NULL)
+ die("Unexpected end of file while reading error tests");
+ ok(n++, group != NULL);
+ ok(n++, errors == NULL);
+ errors_capture();
+ ok(n++, !config_param_unsigned_number(group, "parameter", &lu_value));
+ ok_string(n++, expected, errors);
+ errors_uncapture();
+ free(expected);
+ if (group != NULL)
+ config_free(group);
+ }
+ fclose(warnfile);
+ return n;
+}
+
/* Test the warning test cases in config/warn-real, ensuring that they all
parse successfully and produce the expected error messages when retrieved
- as bools. Takes the current test count and returns the new test count. */
+ as reals. Takes the current test count and returns the new test count. */
static int
test_warnings_real(int n)
{
@@ -233,7 +272,8 @@
ok_string(n++, expected, errors);
errors_uncapture();
free(expected);
- config_free(group);
+ if (group != NULL)
+ config_free(group);
}
fclose(warnfile);
return n;
@@ -241,7 +281,7 @@
/* Test the warning test cases in config/warn-string, ensuring that they all
parse successfully and produce the expected error messages when retrieved
- as bools. Takes the current test count and returns the new test count. */
+ as strings. Takes the current test count and returns the new test count. */
static int
test_warnings_string(int n)
{
@@ -264,12 +304,45 @@
ok_string(n++, expected, errors);
errors_uncapture();
free(expected);
- config_free(group);
+ if (group != NULL)
+ config_free(group);
}
fclose(warnfile);
return n;
}
+/* Test the warning test cases in config/warn-list, ensuring that they all
+ parse successfully and produce the expected error messages when retrieved
+ as lists. Takes the current test count and returns the new test count. */
+static int
+test_warnings_list(int n)
+{
+ FILE *warnfile;
+ char *expected;
+ struct config_group *group;
+ const struct vector *v_value = NULL;
+
+ warnfile = fopen("config/warn-list", "r");
+ if (warnfile == NULL)
+ sysdie("Cannot open config/warn-list");
+ while (parse_test_config(warnfile, &group)) {
+ expected = read_section(warnfile);
+ if (expected == NULL)
+ die("Unexpected end of file while reading error tests");
+ ok(n++, group != NULL);
+ ok(n++, errors == NULL);
+ errors_capture();
+ ok(n++, !config_param_list(group, "parameter", &v_value));
+ ok_string(n++, expected, errors);
+ errors_uncapture();
+ free(expected);
+ if (group != NULL)
+ config_free(group);
+ }
+ fclose(warnfile);
+ return n;
+}
+
int
main(void)
{
@@ -285,7 +358,7 @@
int n;
FILE *tmpconfig;
- test_init(345);
+ test_init(373);
if (access("../data/config/valid", F_OK) == 0)
chdir("../data");
@@ -317,17 +390,17 @@
ok(13, !b_value);
/* Integers. */
- ok(14, config_param_integer(group, "int1", &l_value));
+ ok(14, config_param_signed_number(group, "int1", &l_value));
ok(15, l_value == 0);
- ok(16, config_param_integer(group, "int2", &l_value));
+ ok(16, config_param_signed_number(group, "int2", &l_value));
ok(17, l_value == -3);
- ok(18, !config_param_integer(group, "int3", &l_value));
+ ok(18, !config_param_signed_number(group, "int3", &l_value));
ok(19, l_value == -3);
- ok(20, config_param_integer(group, "int4", &l_value));
+ ok(20, config_param_signed_number(group, "int4", &l_value));
ok(21, l_value == 5000);
- ok(22, config_param_integer(group, "int5", &l_value));
+ ok(22, config_param_signed_number(group, "int5", &l_value));
ok(23, l_value == 2147483647L);
- ok(24, config_param_integer(group, "int6", &l_value));
+ ok(24, config_param_signed_number(group, "int6", &l_value));
ok(25, l_value == (-2147483647L - 1));
/* Strings. */
@@ -427,9 +500,9 @@
ok(59, b_value);
ok(60, config_param_boolean(group, "param4", &b_value));
ok(61, !b_value);
- ok(62, config_param_integer(group, "int1", &l_value));
+ ok(62, config_param_signed_number(group, "int1", &l_value));
ok(63, l_value == 0);
- ok(64, config_param_integer(group, "int2", &l_value));
+ ok(64, config_param_signed_number(group, "int2", &l_value));
ok(65, l_value == -3);
config_free(group);
@@ -492,21 +565,21 @@
ok(97, config_param_boolean(subgroup, "value", &b_value));
subgroup = config_next_group(subgroup);
ok(98, subgroup != NULL);
- ok(99, config_param_integer(subgroup, "value", &l_value));
+ ok(99, config_param_signed_number(subgroup, "value", &l_value));
ok_int(100, 2, l_value);
subgroup = config_next_group(subgroup);
ok(101, subgroup != NULL);
- ok(102, config_param_integer(subgroup, "value", &l_value));
+ ok(102, config_param_signed_number(subgroup, "value", &l_value));
ok_int(103, 3, l_value);
subgroup = config_find_group(subgroup, "test");
ok(104, subgroup != NULL);
- ok(105, config_param_integer(subgroup, "value", &l_value));
+ ok(105, config_param_signed_number(subgroup, "value", &l_value));
ok_int(106, 2, l_value);
subgroup = config_next_group(subgroup);
ok(107, subgroup != NULL);
ok_string(108, "test", config_group_type(subgroup));
ok_string(109, "final", config_group_tag(subgroup));
- ok(110, config_param_integer(subgroup, "value", &l_value));
+ ok(110, config_param_signed_number(subgroup, "value", &l_value));
ok_int(111, 4, l_value);
subgroup = config_next_group(subgroup);
ok(112, subgroup == NULL);
@@ -514,22 +587,22 @@
ok(113, subgroup != NULL);
ok_string(114, "nest", config_group_type(subgroup));
ok_string(115, "1", config_group_tag(subgroup));
- ok(116, config_param_integer(subgroup, "param", &l_value));
+ ok(116, config_param_signed_number(subgroup, "param", &l_value));
ok_int(117, 10, l_value);
subgroup = config_next_group(subgroup);
ok(118, subgroup != NULL);
ok_string(119, "2", config_group_tag(subgroup));
- ok(120, config_param_integer(subgroup, "param", &l_value));
+ ok(120, config_param_signed_number(subgroup, "param", &l_value));
ok_int(121, 10, l_value);
subgroup = config_next_group(subgroup);
ok(122, subgroup != NULL);
ok_string(123, "3", config_group_tag(subgroup));
- ok(124, config_param_integer(subgroup, "param", &l_value));
+ ok(124, config_param_signed_number(subgroup, "param", &l_value));
ok_int(125, 10, l_value);
subgroup = config_next_group(subgroup);
ok(126, subgroup != NULL);
ok_string(127, "4", config_group_tag(subgroup));
- ok(128, config_param_integer(subgroup, "param", &l_value));
+ ok(128, config_param_signed_number(subgroup, "param", &l_value));
ok_int(129, 10, l_value);
subgroup = config_next_group(subgroup);
ok(130, subgroup == NULL);
@@ -541,24 +614,24 @@
ok(133, subgroup != NULL);
ok_string(134, "params", config_group_type(subgroup));
ok_string(135, "first", config_group_tag(subgroup));
- ok(136, config_param_integer(subgroup, "first", &l_value));
+ ok(136, config_param_signed_number(subgroup, "first", &l_value));
ok_int(137, 1, l_value);
- ok(138, !config_param_integer(subgroup, "second", &l_value));
+ ok(138, !config_param_signed_number(subgroup, "second", &l_value));
subgroup = config_next_group(subgroup);
ok(139, subgroup != NULL);
ok_string(140, "second", config_group_tag(subgroup));
- ok(141, config_param_integer(subgroup, "first", &l_value));
+ ok(141, config_param_signed_number(subgroup, "first", &l_value));
ok_int(142, 1, l_value);
- ok(143, config_param_integer(subgroup, "second", &l_value));
+ ok(143, config_param_signed_number(subgroup, "second", &l_value));
ok_int(144, 2, l_value);
subgroup = config_next_group(subgroup);
ok(145, subgroup != NULL);
ok_string(146, "third", config_group_tag(subgroup));
- ok(147, config_param_integer(subgroup, "first", &l_value));
+ ok(147, config_param_signed_number(subgroup, "first", &l_value));
ok_int(148, 1, l_value);
- ok(149, config_param_integer(subgroup, "second", &l_value));
+ ok(149, config_param_signed_number(subgroup, "second", &l_value));
ok_int(150, 2, l_value);
- ok(151, config_param_integer(subgroup, "third", &l_value));
+ ok(151, config_param_signed_number(subgroup, "third", &l_value));
ok_int(152, 3, l_value);
vector = config_params(subgroup);
ok(153, vector != NULL);
@@ -581,7 +654,7 @@
ok_string(162, "baz", s_value);
ok(163, config_param_string(subgroup, "bar", &s_value));
ok_string(164, "baz", s_value);
- ok(165, !config_param_integer(subgroup, "value", &l_value));
+ ok(165, !config_param_signed_number(subgroup, "value", &l_value));
subgroup = config_next_group(subgroup);
ok(166, subgroup != NULL);
subgroup = config_next_group(subgroup);
@@ -589,7 +662,7 @@
ok_string(168, "test", config_group_tag(subgroup));
ok(169, config_param_string(subgroup, "foo", &s_value));
ok_string(170, "baz", s_value);
- ok(171, config_param_integer(subgroup, "value", &l_value));
+ ok(171, config_param_signed_number(subgroup, "value", &l_value));
ok_int(172, 10, l_value);
config_free(group);
@@ -615,8 +688,10 @@
n = test_warnings(n);
n = test_warnings_bool(n);
n = test_warnings_int(n);
+ n = test_warnings_uint(n);
n = test_warnings_real(n);
n = test_warnings_string(n);
+ n = test_warnings_list(n);
return 0;
}
More information about the inn-committers
mailing list