This is an automated email from Gerrit. Cody Schafer (open...@codyps.com) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/4457
-- gerrit commit c54682e3eba8a6207cf90f2a7283da7659ce696b Author: Cody P Schafer <open...@codyps.com> Date: Wed Mar 7 11:30:48 2018 -0500 jtag/hla/hla_tcl: avoid calling memcpy() with a NULL arg Doing so is undefined behavior, and is reported by ubsan: src/jtag/hla/hla_tcl.c:49:2: runtime error: null pointer passed as argument 2, which is declared to never be null #0 0x559c30e4bc98 in jim_newtap_expected_id src/jtag/hla/hla_tcl.c:49 #1 0x559c30e4cd41 in jim_hl_newtap_cmd src/jtag/hla/hla_tcl.c:129 #2 0x559c30e4d0d9 in jim_hl_newtap src/jtag/hla/hla_tcl.c:156 #3 0x559c30abb9ba in command_unknown src/helper/command.c:1030 #4 0x559c30fd9b8a in JimInvokeCommand /home/cody/d/openocd-code/jimtcl/jim.c:10364 This only occurs when we're adding the first expected id, so the right answer is to simply not copy anything. Change-Id: I8d832a08662cec41eaa50495230f267e7f866ed6 Signed-off-by: Cody P Schafer <open...@codyps.com> diff --git a/src/jtag/hla/hla_tcl.c b/src/jtag/hla/hla_tcl.c index 9378427..96f98e2 100644 --- a/src/jtag/hla/hla_tcl.c +++ b/src/jtag/hla/hla_tcl.c @@ -46,7 +46,8 @@ static int jim_newtap_expected_id(Jim_Nvp *n, Jim_GetOptInfo *goi, return JIM_ERR; } - memcpy(new_expected_ids, pTap->expected_ids, expected_len); + if (pTap->expected_ids) + memcpy(new_expected_ids, pTap->expected_ids, expected_len); new_expected_ids[pTap->expected_ids_cnt] = w; -- ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ OpenOCD-devel mailing list OpenOCD-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openocd-devel