Convert all uses of uint8/16/32 to _t in nmbd and the include file.
[samba.git] / source3 / nmbd / nmbd_serverlistdb.c
index f3fba51f4a828999c079280a5751a7638f6c24f3..b4057193b2f23b40fcc6ad3fac016cfaab4d5864 100644 (file)
@@ -21,6 +21,9 @@
 */
 
 #include "includes.h"
+#include "system/filesys.h"
+#include "../librpc/gen_ndr/svcctl.h"
+#include "nmbd/nmbd.h"
 
 int updatecount = 0;
 
@@ -116,7 +119,11 @@ workgroup %s. This is a bug.\n", name, work->work_group));
  
        fstrcpy(servrec->serv.name,name);
        fstrcpy(servrec->serv.comment,comment);
-       strupper_m(servrec->serv.name);
+       if (!strupper_m(servrec->serv.name)) {
+               DEBUG(2,("strupper_m %s failed\n", servrec->serv.name));
+               SAFE_FREE(servrec);
+               return NULL;
+       }
        servrec->serv.type  = servertype;
 
        update_server_ttl(servrec, ttl);
@@ -176,7 +183,7 @@ void expire_servers(struct work_record *work, time_t t)
  out this server record from an earlier subnet.
 ******************************************************************/
 
-static uint32 write_this_server_name( struct subnet_record *subrec,
+static uint32_t write_this_server_name( struct subnet_record *subrec,
                                       struct work_record *work,
                                       struct server_record *servrec)
 {
@@ -214,7 +221,7 @@ static uint32 write_this_server_name( struct subnet_record *subrec,
  broadcast subnets.
 ******************************************************************/
 
-static uint32 write_this_workgroup_name( struct subnet_record *subrec, 
+static uint32_t write_this_workgroup_name( struct subnet_record *subrec,
                                          struct work_record *work)
 {
        struct subnet_record *ssub;
@@ -246,7 +253,7 @@ static uint32 write_this_workgroup_name( struct subnet_record *subrec,
   Write out the browse.dat file.
   ******************************************************************/
 
-void write_browse_list_entry(XFILE *fp, const char *name, uint32 rec_type,
+void write_browse_list_entry(XFILE *fp, const char *name, uint32_t rec_type,
                const char *local_master_browser_name, const char *description)
 {
        fstring tmp;
@@ -266,7 +273,7 @@ void write_browse_list(time_t t, bool force_write)
        struct server_record *servrec;
        char *fname;
        char *fnamenew;
-       uint32 stype;
+       uint32_t stype;
        int i;
        XFILE *fp;
        bool list_changed = force_write;
@@ -304,6 +311,7 @@ void write_browse_list(time_t t, bool force_write)
        fnamenew = talloc_asprintf(ctx, "%s.",
                                fname);
        if (!fnamenew) {
+               talloc_free(fname);
                return;
        }
 
@@ -312,6 +320,8 @@ void write_browse_list(time_t t, bool force_write)
        if (!fp) {
                DEBUG(0,("write_browse_list: Can't open file %s. Error was %s\n",
                        fnamenew,strerror(errno)));
+               talloc_free(fnamenew);
+               talloc_free(fname);
                return;
        }
 
@@ -324,6 +334,8 @@ void write_browse_list(time_t t, bool force_write)
                DEBUG(0,("write_browse_list: Fatal error - cannot find my workgroup %s\n",
                        lp_workgroup()));
                x_fclose(fp);
+               talloc_free(fnamenew);
+               talloc_free(fname);
                return;
        }
 
@@ -352,7 +364,7 @@ void write_browse_list(time_t t, bool force_write)
 
                /* Output server details, plus what workgroup they're in. */
                write_browse_list_entry(fp, my_netbios_names(i), stype,
-                       string_truncate(lp_serverstring(), MAX_SERVER_STRING_LENGTH), lp_workgroup());
+                       string_truncate(lp_server_string(talloc_tos()), MAX_SERVER_STRING_LENGTH), lp_workgroup());
        }
 
        for (subrec = FIRST_SUBNET; subrec ; subrec = NEXT_SUBNET_INCLUDING_UNICAST(subrec)) { 
@@ -360,7 +372,7 @@ void write_browse_list(time_t t, bool force_write)
 
                for (work = subrec->workgrouplist; work ; work = work->next) {
                        /* Write out a workgroup record for a workgroup. */
-                       uint32 wg_type = write_this_workgroup_name( subrec, work);
+                       uint32_t wg_type = write_this_workgroup_name( subrec, work);
 
                        if(wg_type) {
                                write_browse_list_entry(fp, work->work_group, wg_type,
@@ -371,7 +383,7 @@ void write_browse_list(time_t t, bool force_write)
                        /* Now write out any server records a workgroup may have. */
 
                        for (servrec = work->serverlist; servrec ; servrec = servrec->next) {
-                               uint32 serv_type;
+                               uint32_t serv_type;
 
                                /* We have already written our names here. */
                                if(is_myname(servrec->serv.name))
@@ -392,4 +404,6 @@ void write_browse_list(time_t t, bool force_write)
        chmod(fnamenew,0644);
        rename(fnamenew,fname);
        DEBUG(3,("write_browse_list: Wrote browse list into file %s\n",fname));
+       talloc_free(fnamenew);
+       talloc_free(fname);
 }