summaryrefslogtreecommitdiff
path: root/source3/nmbd
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@samba.org>2014-11-02 20:21:26 +0100
committerJeremy Allison <jra@samba.org>2014-11-03 23:46:04 +0100
commit30ab958f500050f49dfb9c47a3d20f901ceed52e (patch)
tree5c0e93ab1961410f3c2957256400fd4a54367b45 /source3/nmbd
parentf62d9080ad143a35c7825f187c8f7eea9def9810 (diff)
downloadsamba-30ab958f500050f49dfb9c47a3d20f901ceed52e.tar.gz
nmbd_winsserver: don't leak state_path onto talloc tos
Also check for allocation failures. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/nmbd')
-rw-r--r--source3/nmbd/nmbd_winsserver.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/source3/nmbd/nmbd_winsserver.c b/source3/nmbd/nmbd_winsserver.c
index e09d1a01764..a56ff45b981 100644
--- a/source3/nmbd/nmbd_winsserver.c
+++ b/source3/nmbd/nmbd_winsserver.c
@@ -594,14 +594,22 @@ bool initialise_wins(void)
time_t time_now = time(NULL);
XFILE *fp;
char line[1024];
+ char *db_path;
+ char *list_path;
if(!lp_we_are_a_wins_server()) {
return True;
}
+ db_path = state_path("wins.tdb");
+ if (db_path == NULL) {
+ return false;
+ }
+
/* Open the wins.tdb. */
- wins_tdb = tdb_open_log(state_path("wins.tdb"), 0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
+ wins_tdb = tdb_open_log(db_path, 0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
O_CREAT|O_RDWR, 0600);
+ TALLOC_FREE(db_path);
if (!wins_tdb) {
DEBUG(0,("initialise_wins: failed to open wins.tdb. Error was %s\n",
strerror(errno) ));
@@ -612,7 +620,15 @@ bool initialise_wins(void)
add_samba_names_to_subnet(wins_server_subnet);
- if((fp = x_fopen(state_path(WINS_LIST),O_RDONLY,0)) == NULL) {
+ list_path = state_path(WINS_LIST);
+ if (list_path == NULL) {
+ tdb_close(wins_tdb);
+ return false;
+ }
+
+ fp = x_fopen(list_path, O_RDONLY, 0);
+ TALLOC_FREE(list_path);
+ if (fp == NULL) {
DEBUG(2,("initialise_wins: Can't open wins database file %s. Error was %s\n",
WINS_LIST, strerror(errno) ));
return True;