Commit 2d4b51c
MB-29523: Avoid undefined behaviour upon zero-length SerialisedDocKey
As identified by UBSan, if we try to create a zero-length
SerialisedDocKey (which is valid); the current implementation passes a
null pointer to memcpy:
[ RUN ] MutationLogTest.Logging
runtime error: null pointer passed as argument 2, which is declared to never be null
#0 0x11e9309 in SerialisedDocKey::SerialisedDocKey(DocKey) kv_engine/engines/ep/src/storeddockey.h:277
#1 0x11e9309 in MutationLogEntryV2::MutationLogEntryV2(MutationLogType, unsigned short, DocKey const&) kv_engine/engines/ep/src/mutation_log_entry.h:310
#2 0x11e9309 in MutationLogEntryV2::MutationLogEntryV2(MutationLogType, unsigned short) kv_engine/engines/ep/src/mutation_log_entry.h:321
#3 0x11e9309 in MutationLogEntryV2::newEntry(unsigned char*, MutationLogType, unsigned short) kv_engine/engines/ep/src/mutation_log_entry.h:223
#4 0x11e9309 in MutationLog::commit1() kv_engine/engines/ep/src/mutation_log.cc:322
Fix by using std::copy instead.
Change-Id: I0994f1522efeb046c58da375053b6257fdc89a6a
Reviewed-on: http://review.couchbase.org/93762
Tested-by: Build Bot <[email protected]>
Reviewed-by: Trond Norbye <[email protected]>1 parent f18b981 commit 2d4b51c
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
277 | | - | |
| 277 | + | |
278 | 278 | | |
279 | 279 | | |
280 | 280 | | |
| |||
0 commit comments