diff options
author | Jeremy Allison <jra@samba.org> | 2006-06-14 21:36:49 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:17:26 -0500 |
commit | a1e0a0e9286fbe90ca04cda9df38e72d8d18b0c1 (patch) | |
tree | 14c15c8333572c5a2e089611ee61d03010a9d2b4 /source3/nmbd | |
parent | 2b99951e7511d0ec2d928c06b05fe22b7b6572d1 (diff) | |
download | samba-a1e0a0e9286fbe90ca04cda9df38e72d8d18b0c1.tar.gz samba-a1e0a0e9286fbe90ca04cda9df38e72d8d18b0c1.tar.bz2 samba-a1e0a0e9286fbe90ca04cda9df38e72d8d18b0c1.zip |
r16230: Fix Klocwork #861 and others. localtime and asctime
can return NULL. Ensure we check all returns correctly.
Jeremy.
(This used to be commit 6c61dc8ed6d84f310ef391fb7700e93ef42c4afc)
Diffstat (limited to 'source3/nmbd')
-rw-r--r-- | source3/nmbd/nmbd_namelistdb.c | 20 | ||||
-rw-r--r-- | source3/nmbd/nmbd_winsserver.c | 6 |
2 files changed, 24 insertions, 2 deletions
diff --git a/source3/nmbd/nmbd_namelistdb.c b/source3/nmbd/nmbd_namelistdb.c index 60023a7ed5..fb32ce1aad 100644 --- a/source3/nmbd/nmbd_namelistdb.c +++ b/source3/nmbd/nmbd_namelistdb.c @@ -564,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"); } diff --git a/source3/nmbd/nmbd_winsserver.c b/source3/nmbd/nmbd_winsserver.c index 198d90f35a..29d5c41de8 100644 --- a/source3/nmbd/nmbd_winsserver.c +++ b/source3/nmbd/nmbd_winsserver.c @@ -2222,7 +2222,13 @@ void wins_write_name_record(struct name_record *namerec, XFILE *fp) char *ts, *nl; tm = localtime(&namerec->data.death_time); + if (!tm) { + return; + } ts = asctime(tm); + if (!ts) { + return; + } nl = strrchr( ts, '\n' ); if( NULL != nl ) { *nl = '\0'; |