bug-hurd
[Top][All Lists]
Advanced

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

Re: error checking in libnetfs


From: Neal H Walfield
Subject: Re: error checking in libnetfs
Date: 02 Apr 2002 10:22:21 -0500
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/21.1

>  The original is correct.  However, in libdiskfs/io-restrict-auth.c USER, 
> which
> is equivalent to NEW_USER, is duplicated.  Should the libnetfs implementation
> also duplicate NEW_USER so it can be free'd?

Thanks for catching this.  The libdiskfs implementation looks wrong.
Here is a patch:

2002-04-02  Neal H Walfield  <neal@cs.uml.edu>

        * io-restrict-auth.c (diskfs_S_io_restrict_auth): When checking
        the result of a function, be sure to first save the result.
        Only free USER if there was an error.


Index: io-restrict-auth.c
===================================================================
RCS file: /cvsroot/hurd/hurd/libdiskfs/io-restrict-auth.c,v
retrieving revision 1.12
diff -u -p -r1.12 io-restrict-auth.c
--- io-restrict-auth.c  16 Jun 2001 20:23:09 -0000      1.12
+++ io-restrict-auth.c  2 Apr 2002 15:13:40 -0000
@@ -1,5 +1,5 @@
 /* 
-   Copyright (C) 1994,95,96,2001 Free Software Foundation
+   Copyright (C) 1994,95,96,2001,02 Free Software Foundation
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -79,7 +79,7 @@ diskfs_S_io_restrict_auth (struct protid
       for (i = 0; i < cred->user->gids->num; i++)
        if (listmember (gids, cred->user->gids->ids[i], ngids))
          {
-           idvec_add (gvec, cred->user->gids->ids[i]);
+           err = idvec_add (gvec, cred->user->gids->ids[i]);
            if (err)
              goto out;
          }
@@ -103,8 +103,11 @@ diskfs_S_io_restrict_auth (struct protid
       *newportpoly = MACH_MSG_TYPE_MAKE_SEND;
       ports_port_deref (newpi);
     }
+
   mutex_unlock (&cred->po->np->lock);
 
-  iohelp_free_iouser (user);
+  if (err)
+    iohelp_free_iouser (user);
+
   return err;
 }

Roland: okay to apply this?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]