Package: apt-spy
Severity: minor
Tags: patch

If strstr()!=NULL, it should be sufficient to break out of the inner
loop of write_top, and continue with the next i<BESTNUMBER.

By the way, why does main() allocate space for BESTNUMBER+1 elements
of best?  I suggest allocating only the necessary amount of space, and
including the following check after the first loop of decide_best():

        if (i>=bestnumber) return;

        (Conflicts with the renaming of BESTNUMBER to bestnumber.)

Justin
diff -ur apt-spy-3.1/parse.c apt-spy-3.1.jp4/parse.c
--- apt-spy-3.1/parse.c 2005-07-08 20:48:09.000000000 -0400
+++ apt-spy-3.1.jp4/parse.c     2005-07-08 22:29:14.000000000 -0400
@@ -365,9 +365,12 @@
                rewind(infile_p);
                
                /* Read in a line... */
-               while ((line = next_entry(infile_p)) != NULL)
-                       if (strstr(line, best[i].hostname) != NULL)     /* 
Check for hostname */
+               while ((line = next_entry(infile_p)) != NULL) {
+                       if (strstr(line, best[i].hostname) != NULL) {   /* 
Check for hostname */
                                fputs(line, outfile_p);         /* if it's 
there, write to file */
+                               break;
+                       }
+               }
                
                if ((ferror(infile_p) != 0) || (ferror(outfile_p) != 0))
                        return 1;

Reply via email to