summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2011-05-03 16:42:17 -0700
committerJeremy Allison <jra@samba.org>2011-05-04 12:12:15 -0700
commitdf023b8657cab232df88d3656aa5d87676bb7254 (patch)
treeacaedf7d93de593d4d843f80e7c03ea6f1ec99a7
parenta3e913ae8bfaa88f5b571f3347f3357a9ff02ed1 (diff)
downloadsamba-df023b8657cab232df88d3656aa5d87676bb7254.tar.gz
samba-df023b8657cab232df88d3656aa5d87676bb7254.tar.bz2
samba-df023b8657cab232df88d3656aa5d87676bb7254.zip
Tidy up some missing checks for NULL in strlcpy.
-rw-r--r--lib/util/string_wrappers.h2
-rw-r--r--libcli/auth/smbencrypt.c2
-rw-r--r--source3/client/clitar.c2
3 files changed, 3 insertions, 3 deletions
diff --git a/lib/util/string_wrappers.h b/lib/util/string_wrappers.h
index 4a5f51d96b..80d0b9932a 100644
--- a/lib/util/string_wrappers.h
+++ b/lib/util/string_wrappers.h
@@ -42,7 +42,7 @@ size_t __unsafe_string_function_usage_here_size_t__(void);
#endif /* HAVE_COMPILER_WILL_OPTIMIZE_OUT_FNS */
#define strlcpy_base(dest, src, base, size) \
- strlcpy(dest, src, size-PTR_DIFF(dest,base))
+ strlcpy((dest), (src) ? (src) : "", (size)-PTR_DIFF((dest),(base)))
/* String copy functions - macro hell below adds 'type checking' (limited,
but the best we can do in C) */
diff --git a/libcli/auth/smbencrypt.c b/libcli/auth/smbencrypt.c
index c59bc515ba..0cd836302b 100644
--- a/libcli/auth/smbencrypt.c
+++ b/libcli/auth/smbencrypt.c
@@ -134,7 +134,7 @@ bool E_deshash(const char *passwd, uint8_t p16[16])
tmpbuf = strupper_talloc(mem_ctx, passwd);
if (tmpbuf == NULL) {
/* Too many callers don't check this result, we need to fill in the buffer with something */
- strlcpy((char *)dospwd, passwd, sizeof(dospwd));
+ strlcpy((char *)dospwd, passwd ? passwd : "", sizeof(dospwd));
E_P16(dospwd, p16);
return false;
}
diff --git a/source3/client/clitar.c b/source3/client/clitar.c
index 61af481e85..80968a64d7 100644
--- a/source3/client/clitar.c
+++ b/source3/client/clitar.c
@@ -180,7 +180,7 @@ static void writetarheader(int f, const char *aname, uint64_t size, time_t mtime
/* write out a "standard" tar format header */
hb.dbuf.name[NAMSIZ-1]='\0';
- strlcpy(hb.dbuf.mode, amode, sizeof(hb.dbuf.mode));
+ strlcpy(hb.dbuf.mode, amode ? amode : "", sizeof(hb.dbuf.mode));
oct_it((uint64_t)0, 8, hb.dbuf.uid);
oct_it((uint64_t)0, 8, hb.dbuf.gid);
oct_it((uint64_t) size, 13, hb.dbuf.size);