>Number:         172566
>Category:       misc
>Synopsis:       Fix analyzer warnings in /games
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 10 11:00:00 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Erik Cederstrand
>Release:        CURRENT
>Organization:
>Environment:
>Description:
Fix 4 warnings in /games reported by Clang Static Analyzer: 

bcd and caesar are not installed SETGID (at least on my system). Remove the 
call to setgid() as it becomes redundant.

In fortune, make sure a tail file is passed in the args if mandated in the 
logic. Bail if not.

In random(6), fix a memory leak in randomize_fd()
>How-To-Repeat:

>Fix:
Se attached patch

Patch attached with submission follows:

Index: head/games/random/randomize_fd.c
===================================================================
--- head/games/random/randomize_fd.c    (revision 241370)
+++ head/games/random/randomize_fd.c    (working copy)
@@ -207,6 +207,7 @@
                goto make_token;
        }
 
+       free(buf);
        for (i = numnode; i > 0; i--) {
                selected = random() % numnode;
 
Index: head/games/fortune/fortune/fortune.c
===================================================================
--- head/games/fortune/fortune/fortune.c        (revision 241370)
+++ head/games/fortune/fortune/fortune.c        (working copy)
@@ -576,6 +576,10 @@
        if (*head == NULL)
                *head = *tail = fp;
        else if (fp->percent == NO_PROB) {
+               if (*tail == NULL) {
+                       fprintf(stderr, "No tail file given\n");
+                       exit(1);
+               }
                (*tail)->next = fp;
                fp->prev = *tail;
                *tail = fp;
Index: head/games/bcd/bcd.c
===================================================================
--- head/games/bcd/bcd.c        (revision 241370)
+++ head/games/bcd/bcd.c        (working copy)
@@ -129,9 +129,6 @@
 {
        char cardline[80];
 
-       /* revoke setgid privileges */
-       setgid(getgid());
-
        /*
         * The original bcd prompts with a "%" when reading from stdin,
         * but this seems kind of silly.  So this one doesn't.
Index: head/games/caesar/caesar.c
===================================================================
--- head/games/caesar/caesar.c  (revision 241370)
+++ head/games/caesar/caesar.c  (working copy)
@@ -82,9 +82,6 @@
        char *inbuf;
        int obs[26], try, winner;
 
-       /* revoke setgid privileges */
-       setgid(getgid());
-
        if (argc > 1)
                printit(argv[1]);

>Release-Note:
>Audit-Trail:
>Unformatted:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to