diff options
author | Gary Lockyer <gary@catalyst.net.nz> | 2019-05-24 11:00:05 +1200 |
---|---|---|
committer | Gary Lockyer <gary@samba.org> | 2019-05-27 01:29:48 +0000 |
commit | 412afb2aef100e09eb433b8f0cae064fc2a736b7 (patch) | |
tree | 2a3eedf4bbb4bc450d31652a7d765762237c4807 /lib/util/asn1.c | |
parent | da87fa998ab71328f30bcdf5b41aee8675aee48a (diff) | |
download | samba-412afb2aef100e09eb433b8f0cae064fc2a736b7.tar.gz |
Fix ubsan null pointer passed as argument 2
Fix ubsan warning null pointer passed as argument 2 when the source
pointer is NULL. The calls to memcpy are now guarded by an
if (len > 0)
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Gary Lockyer <gary@samba.org>
Autobuild-Date(master): Mon May 27 01:29:48 UTC 2019 on sn-devel-184
Diffstat (limited to 'lib/util/asn1.c')
-rw-r--r-- | lib/util/asn1.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/util/asn1.c b/lib/util/asn1.c index affa8f1df91..70ff5f0ad88 100644 --- a/lib/util/asn1.c +++ b/lib/util/asn1.c @@ -94,8 +94,10 @@ bool asn1_write(struct asn1_data *data, const void *p, int len) data->data = newp; data->length = data->ofs+len; } - memcpy(data->data + data->ofs, p, len); - data->ofs += len; + if (len > 0) { + memcpy(data->data + data->ofs, p, len); + data->ofs += len; + } return true; } |