Subject: Re: bin/36725: fsplit segfaults when user doesnt have correct permissions
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org,>
From: Kevin Massey <new.security@gmail.com>
List: netbsd-bugs
Date: 08/03/2007 19:20:02
The following reply was made to PR bin/36725; it has been noted by GNATS.

From: "Kevin Massey" <new.security@gmail.com>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/36725: fsplit segfaults when user doesnt have correct permissions
Date: Fri, 3 Aug 2007 15:16:05 -0400

 oh yea true well heres a new patch that fixes this problem for now.
 
 Index: fsplit.c
 ===================================================================
 RCS file: /cvsroot/src/usr.bin/fsplit/fsplit.c,v
 retrieving revision 1.11
 diff -u -r1.11 fsplit.c
 --- fsplit.c    30 Oct 2004 17:27:28 -0000      1.11
 +++ fsplit.c    3 Aug 2007 19:14:31 -0000
 @@ -122,6 +122,12 @@
 
         /*  scan -e options */
         while ( argc > 1  && argv[1][0] == '-' && argv[1][1] == 'e') {
 +
 +               if((access(".", W_OK)) !=0) {
 +                       fprintf(stderr, "Incorrect access user cannot
 write to directory\n");
 +                       exit(1);
 +               }
 +
                 extr = TRUE;
                 ptr = argv[1] + 2;
                 if(!*ptr) {
 @@ -145,10 +151,20 @@
                 if ((ifp = fopen(argv[1], "r")) == NULL) {
                         fprintf(stderr, "fsplit: cannot open %s\n", argv[1]);
                         exit(1);
 +               } else if((access(".", W_OK)) !=0) {
 +                       fprintf(stderr, "Incorrect access user cannot
 write to directory\n");
 +                       exit(1);
                 }
         }
 -       else
 +       else {
 +               if((access(".", W_OK)) !=0) {
 +                       fprintf(stderr, "Incorrent access user cannot
 write to directory\n");
 +                       exit(1);
 +               }
 +
                 ifp = stdin;
 +       }
 +
      for(;;) {
         /* look for a temp file that doesn't correspond to an existing file */
         get_name(x, 3);