pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/net/driftnet Try to plug file descriptor leak. Bump to...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/fa53af77b3a9
branches:  trunk
changeset: 470355:fa53af77b3a9
user:      hubertf <hubertf%pkgsrc.org@localhost>
date:      Mon Mar 08 18:57:43 2004 +0000

description:
Try to plug file descriptor leak. Bump to 0.1.6nb4.

diffstat:

 net/driftnet/Makefile         |   4 +-
 net/driftnet/patches/patch-ab |  87 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 89 insertions(+), 2 deletions(-)

diffs (105 lines):

diff -r 0e466167bfa3 -r fa53af77b3a9 net/driftnet/Makefile
--- a/net/driftnet/Makefile     Mon Mar 08 18:14:33 2004 +0000
+++ b/net/driftnet/Makefile     Mon Mar 08 18:57:43 2004 +0000
@@ -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 -r 0e466167bfa3 -r fa53af77b3a9 net/driftnet/patches/patch-ab
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/net/driftnet/patches/patch-ab     Mon Mar 08 18:57:43 2004 +0000
@@ -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@localhost>
+
+--- 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;
+ }
+ 



Home | Main Index | Thread Index | Old Index