$NetBSD: patch-al,v 1.3 2013/03/03 01:07:24 joerg Exp $

--- portmon/portmon.c.orig	2000-04-06 19:32:26.000000000 +0000
+++ portmon/portmon.c
@@ -81,4 +81,6 @@ static char rcsid[] = "$Id: portmon.c,v 
 #endif
 
+#include <stdlib.h>
+
 #include "portmon.h"
 
@@ -181,5 +183,5 @@ main(ac, av)
 	{
 	  update_event(&v, harray[i]->status,
-		       /* value */ (u_long)(harray[i]->status),
+		       /* value */ (u_long)(harray[i]->elapsedsecs),
 		       harray[i]->testseverity) ;
 	  lseek(fdout, -(off_t)sizeof(v), SEEK_CUR);
@@ -221,5 +223,5 @@ checkports(hv, nhosts)
   fd_set rset, wset;
 
-  if (nhosts <= 0) return;
+  if (nhosts <= 0) return -1;
 
   FD_ZERO(&rset); FD_ZERO(&wset);
@@ -659,14 +661,19 @@ static char *Strcasestr(haystack, needle
     do
     {
-      if (tolower(*s1) != tolower(*s2++)  || *s1 == 0)	/* */
+      if (*s1 == 0 || tolower(*s1) != tolower(*s2++))	/* */
 	break;
       ++s1;
     } while (--n != 0);
 
-    if (n == 0 || *s1 == 0)
-      break;	/* found, break out of forever loop */
+    if (n == 0) {
+	--haystack;
+	break;		/* found, break out of forever loop */
+    }
+    if (*s1 == 0) {
+	haystack = NULL;
+	break;		/* not found, break out of forever loop */
+    }
 
   }	/* end for */
-  haystack--;
   return ((char *)haystack);
 }	/* Strcasestr() */
