r16230: Fix Klocwork #861 and others. localtime and asctime
[kai/samba.git] / source3 / nmbd / nmbd_namelistdb.c
index baaf5dbd5489f2bdfa70ff61fc7dd77a3b1bae0b..fb32ce1aad1b66318d246be6cdcd2b8d8de211d1 100644 (file)
@@ -80,14 +80,13 @@ static void upcase_name( struct nmb_name *target, const struct nmb_name *source
 void remove_name_from_namelist(struct subnet_record *subrec, 
                                struct name_record *namerec )
 {
-       if (subrec == wins_server_subnet) {
+       if (subrec == wins_server_subnet) 
                remove_name_from_wins_namelist(namerec);
-               return;
-       } 
-
-       subrec->namelist_changed = True;
+       else {
+               subrec->namelist_changed = True;
+               DLIST_REMOVE(subrec->namelist, namerec);
+       }
 
-       DLIST_REMOVE(subrec->namelist, namerec);
        SAFE_FREE(namerec->data.ip);
        ZERO_STRUCTP(namerec);
        SAFE_FREE(namerec);
@@ -565,15 +564,31 @@ void dump_name_record( struct name_record *namerec, XFILE *fp)
        x_fprintf(fp,"Source = %s\nb_flags = %x\t", src_type, namerec->data.nb_flags);
 
        if(namerec->data.death_time != PERMANENT_TTL) {
+               const char *asct;
                tm = localtime(&namerec->data.death_time);
-               x_fprintf(fp, "death_time = %s\t", asctime(tm));
+               if (!tm) {
+                       return;
+               }
+               asct = asctime(tm);
+               if (!asct) {
+                       return;
+               }
+               x_fprintf(fp, "death_time = %s\t", asct);
        } else {
                x_fprintf(fp, "death_time = PERMANENT\t");
        }
 
        if(namerec->data.refresh_time != PERMANENT_TTL) {
+               const char *asct;
                tm = localtime(&namerec->data.refresh_time);
-               x_fprintf(fp, "refresh_time = %s\n", asctime(tm));
+               if (!tm) {
+                       return;
+               }
+               asct = asctime(tm);
+               if (!asct) {
+                       return;
+               }
+               x_fprintf(fp, "refresh_time = %s\n", asct);
        } else {
                x_fprintf(fp, "refresh_time = PERMANENT\n");
        }