summaryrefslogtreecommitdiff
path: root/net/driftnet
diff options
context:
space:
mode:
authorhubertf <hubertf@pkgsrc.org>2004-03-08 18:57:43 +0000
committerhubertf <hubertf@pkgsrc.org>2004-03-08 18:57:43 +0000
commit244e5122ec15acfce9904ed501e8a112c8990d29 (patch)
treea7f1de891d9abbdab05830667cea6abae2fd3e98 /net/driftnet
parent491c5d65f1273341e2e8ccb1b08de53a51a121d4 (diff)
downloadpkgsrc-244e5122ec15acfce9904ed501e8a112c8990d29.tar.gz
Try to plug file descriptor leak. Bump to 0.1.6nb4.
Diffstat (limited to 'net/driftnet')
-rw-r--r--net/driftnet/Makefile4
-rw-r--r--net/driftnet/patches/patch-ab87
2 files changed, 89 insertions, 2 deletions
diff --git a/net/driftnet/Makefile b/net/driftnet/Makefile
index 35c1ab87e49..5728c026006 100644
--- a/net/driftnet/Makefile
+++ b/net/driftnet/Makefile
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.8 2003/07/17 22:51:07 grant Exp $
+# $NetBSD: Makefile,v 1.9 2004/03/08 18:57:43 hubertf Exp $
#
DISTNAME= driftnet-0.1.6
-PKGREVISION= 3
+PKGREVISION= 4
CATEGORIES= net graphics
MASTER_SITES= http://www.ex-parrot.com/~chris/driftnet/
diff --git a/net/driftnet/patches/patch-ab b/net/driftnet/patches/patch-ab
new file mode 100644
index 00000000000..32c998c00b5
--- /dev/null
+++ b/net/driftnet/patches/patch-ab
@@ -0,0 +1,87 @@
+$NetBSD: patch-ab,v 1.1 2004/03/08 18:57:43 hubertf Exp $
+
+This patch tries to plug the file descriptor leak in driftnet 0.1.6.
+It's probably not perfect, but better than nothing.
+
+ - Hubert Feyrer <hubertf@NetBSD.org>
+
+--- img.c.orig Tue Jul 9 21:26:41 2002
++++ img.c Sun Mar 7 10:44:27 2004
+@@ -14,6 +14,7 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include <errno.h>
+
+ #include "img.h"
+
+@@ -117,30 +118,40 @@
+ int i;
+ if (type == unknown) {
+ I->err = IE_UNKNOWNTYPE;
++ if (feof(I->fp)) fclose(I->fp);
+ return 0;
+ } else if (!I->fp) {
+ I->err = IE_NOSTREAM;
++ if (feof(I->fp)) fclose(I->fp);
+ return 0;
+- } else if (howmuch == none) return 1;
++ } else if (howmuch == none) {
++ if (feof(I->fp)) fclose(I->fp);
++ return 1;
++ }
+ else for (i = 0; i < NUMFILEDRVS; ++i)
+ if (filedrvs[i].type == type) {
+ int r;
+ if (howmuch == header && filedrvs[i].loadhdr) {
+ r = filedrvs[i].loadhdr(I);
+ if (r) I->load = howmuch;
++ if (feof(I->fp)) fclose(I->fp);
+ return r;
+ } else if (filedrvs[i].loadimg) {
+ /* May have to load header first. */
+- if (I->load != header && filedrvs[i].loadhdr && !filedrvs[i].loadhdr(I))
++ if (I->load != header && filedrvs[i].loadhdr && !filedrvs[i].loadhdr(I)) {
++ if (feof(I->fp)) fclose(I->fp);
+ return 0;
++ }
+ I->load = header;
+ r = filedrvs[i].loadimg(I);
+ if (r) I->load = full;
++ if (feof(I->fp)) fclose(I->fp);
+ return r;
+ }
+ }
+
+ I->err = IE_UNKNOWNTYPE;
++ if (feof(I->fp)) fclose(I->fp);
+ return 0;
+ }
+
+@@ -160,6 +171,7 @@
+ I->fp = fopen(name, "rb");
+ if (!I->fp) {
+ I->err = IE_SYSERROR;
++ fprintf(stderr, "HF: fopen('%s') failed: %s\n", name, strerror(errno));
+ return 0;
+ }
+
+@@ -172,13 +184,17 @@
+ char *q;
+ for (q = filedrvs[i].suffices; *q; q += strlen(q) + 1)
+ if (strcasecmp(p, q) == 0) {
++ int r;
+ I->type = filedrvs[i].type;
+- return img_load(I, howmuch, I->type);
++ r = img_load(I, howmuch, I->type);
++ if (feof(I->fp)) fclose(I->fp);
++ return r;
+ }
+ }
+ } else return img_load(I, howmuch, type);
+
+ I->err = IE_UNKNOWNTYPE;
++ if (feof(I->fp)) fclose(I->fp);
+ return 0;
+ }
+