INN commit: trunk (4 files)
INN Commit
rra at isc.org
Sun Apr 3 13:30:46 UTC 2016
Date: Sunday, April 3, 2016 @ 06:30:45
Author: iulius
Revision: 10000
Fix leaks and dereferences; improve readability (reported by cppcheck)
Modified:
trunk/contrib/mlockfile.c
trunk/contrib/pullart.c
trunk/frontends/feedone.c
trunk/storage/buffindexed/buffindexed.c
-----------------------------------+
contrib/mlockfile.c | 4 ++++
contrib/pullart.c | 14 ++++++++++----
frontends/feedone.c | 1 -
storage/buffindexed/buffindexed.c | 6 +++---
4 files changed, 17 insertions(+), 8 deletions(-)
Modified: contrib/mlockfile.c
===================================================================
--- contrib/mlockfile.c 2016-04-03 13:28:46 UTC (rev 9999)
+++ contrib/mlockfile.c 2016-04-03 13:30:45 UTC (rev 10000)
@@ -151,6 +151,7 @@
if (errno != 0) {
fprintf(stderr, "%s: can't parse offset `%s' - %s\n",
progname, at, strerror(errno));
+ free(ml);
return EX_USAGE;
}
if (*end == ':') {
@@ -160,6 +161,7 @@
if (errno != 0) {
fprintf(stderr, "%s: can't parse length `%s' - %s\n",
progname, at, strerror(errno));
+ free(ml);
return EX_USAGE;
}
}
@@ -166,6 +168,7 @@
if (*end != '\0') {
fprintf(stderr, "%s: unrecognised separator `%c'\n",
progname, *end);
+ free(ml);
return EX_USAGE;
}
}
@@ -179,5 +182,6 @@
inn_lock_files(ml);
poll(NULL, 0, interval);
}
+ free(ml);
return EX_OSERR;
}
Modified: contrib/pullart.c
===================================================================
--- contrib/pullart.c 2016-04-03 13:28:46 UTC (rev 9999)
+++ contrib/pullart.c 2016-04-03 13:30:45 UTC (rev 10000)
@@ -105,6 +105,7 @@
if (Infile==NULL)
{
printf ("Cannot open input file.\n");
+ free(obuffer);
return 1;
}
@@ -111,14 +112,18 @@
if (argc>=4) header = argv[HEADER];
if (argc>=5) string = argv[STRING];
-if (*header=='\0') header=NULL;
-if (*string=='\0') string=NULL;
+if (header != NULL && *header == '\0') {
+ header = NULL;
+}
+if (string != NULL && *string == '\0') {
+ string = NULL;
+}
/*test*/
printf ("filename <%s>\n", argv[INFILE]);
printf ("fileprefix <%s>\n", argv[FILEPREFIX]);
-printf ("header <%s>\n", header);
-printf ("string <%s>\n", string);
+printf ("header <%s>\n", header != NULL ? header : NULL);
+printf ("string <%s>\n", string != NULL ? string : NULL);
/* Skip first 0x38000 16byte buffers */
@@ -194,6 +199,7 @@
}
fclose (Infile);
+ free(obuffer);
return 0;
}
Modified: frontends/feedone.c
===================================================================
--- frontends/feedone.c 2016-04-03 13:28:46 UTC (rev 9999)
+++ frontends/feedone.c 2016-04-03 13:30:45 UTC (rev 10000)
@@ -83,7 +83,6 @@
bool PostMode;
/* Set defaults. */
- mesgid[0] = '\0';
PostMode = false;
message_program_name = "feedone";
Modified: storage/buffindexed/buffindexed.c
===================================================================
--- storage/buffindexed/buffindexed.c 2016-04-03 13:28:46 UTC (rev 9999)
+++ storage/buffindexed/buffindexed.c 2016-04-03 13:30:45 UTC (rev 10000)
@@ -607,7 +607,7 @@
*/
for (; ovbuff != (OVBUFF *)NULL; ovbuff = ovbuff->next) {
if (ovbuff->fd < 0) {
- if ((fd = open(ovbuff->path, ovbuffmode & OV_WRITE ? O_RDWR : O_RDONLY)) < 0) {
+ if ((fd = open(ovbuff->path, (ovbuffmode & OV_WRITE) ? O_RDWR : O_RDONLY)) < 0) {
syswarn("buffindexed: ERROR opening '%s'", ovbuff->path);
return false;
} else {
@@ -633,7 +633,7 @@
rpx = (OVBUFFHEAD *)ovbuff->bitfield;
/* lock the buffer */
- ovlock(ovbuff, ovbuffmode & OV_WRITE ? INN_LOCK_WRITE : INN_LOCK_READ);
+ ovlock(ovbuff, (ovbuffmode & OV_WRITE) ? INN_LOCK_WRITE : INN_LOCK_READ);
if (pread(ovbuff->fd, &dpx, sizeof(OVBUFFHEAD), 0) < 0) {
syswarn("buffindexed: cant read from %s", ovbuff->path);
@@ -1016,7 +1016,7 @@
if (Needunlink && unlink(groupfn) == 0) {
notice("buffindexed: all buffers are brandnew, unlink '%s'", groupfn);
}
- GROUPfd = open(groupfn, ovbuffmode & OV_WRITE ? O_RDWR | O_CREAT : O_RDONLY, 0660);
+ GROUPfd = open(groupfn, (ovbuffmode & OV_WRITE) ? O_RDWR | O_CREAT : O_RDONLY, 0660);
if (GROUPfd < 0) {
syswarn("buffindexed: Could not create %s", groupfn);
free(groupfn);
More information about the inn-committers
mailing list