s3-utils: Fixed possible resource leak in net_usershare.
authorAndreas Schneider <asn@samba.org>
Wed, 19 Jan 2011 22:07:33 +0000 (23:07 +0100)
committerJeremy Allison <jra@samba.org>
Wed, 26 Jan 2011 22:20:37 +0000 (14:20 -0800)
s3-utils: Fixed possible resource leak in net_usershare.

source3/utils/net_usershare.c

index 61b2caa606a3384dde467be08ddac5e95789be27..f0ee682aee1b1610cc83186c2a84fa9e57b17c37 100644 (file)
@@ -907,6 +907,7 @@ static int net_usershare_add(struct net_context *c, int argc, const char **argv)
                          _("net usershare add: cannot lstat tmp file %s\n"),
                          full_path_tmp );
                TALLOC_FREE(ctx);
+               close(tmpfd);
                return -1;
        }
 
@@ -916,6 +917,7 @@ static int net_usershare_add(struct net_context *c, int argc, const char **argv)
                          _("net usershare add: cannot fstat tmp file %s\n"),
                          full_path_tmp );
                TALLOC_FREE(ctx);
+               close(tmpfd);
                return -1;
        }
 
@@ -925,6 +927,7 @@ static int net_usershare_add(struct net_context *c, int argc, const char **argv)
                            "file ?\n"),
                          full_path_tmp );
                TALLOC_FREE(ctx);
+               close(tmpfd);
                return -1;
        }
 
@@ -934,6 +937,7 @@ static int net_usershare_add(struct net_context *c, int argc, const char **argv)
                            "to 0644n"),
                          full_path_tmp );
                TALLOC_FREE(ctx);
+               close(tmpfd);
                return -1;
        }
 
@@ -957,6 +961,7 @@ static int net_usershare_add(struct net_context *c, int argc, const char **argv)
                        (unsigned int)to_write, full_path_tmp, strerror(errno));
                unlink(full_path_tmp);
                TALLOC_FREE(ctx);
+               close(tmpfd);
                return -1;
        }