<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 11, 2021, 3:00 PM Chris Johns <<a href="mailto:chrisj@rtems.org">chrisj@rtems.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 12/2/21 7:27 am, Ryan Long wrote:<br>
> Fixes CID #1468682 where target is dereferenced before it has been<br>
> checked as to whether it is null or not in the<br>
> rtems_debugger_target_swbreak_control function.<br>
> ---<br>
> cpukit/libdebugger/rtems-debugger-target.c | 5 +++--<br>
> 1 file changed, 3 insertions(+), 2 deletions(-)<br>
> <br>
> diff --git a/cpukit/libdebugger/rtems-debugger-target.c b/cpukit/libdebugger/rtems-debugger-target.c<br>
> index e495170..3726a6c 100644<br>
> --- a/cpukit/libdebugger/rtems-debugger-target.c<br>
> +++ b/cpukit/libdebugger/rtems-debugger-target.c<br>
> @@ -171,17 +171,18 @@ int<br>
> rtems_debugger_target_swbreak_control(bool insert, DB_UINT addr, DB_UINT kind)<br>
> {<br>
> rtems_debugger_target* target = rtems_debugger->target;<br>
> - rtems_debugger_target_swbreak* swbreaks = target->swbreaks.block;<br>
> size_t swbreak_size;<br>
> uint8_t* loc = (void*) addr;<br>
> size_t i;<br>
> int r;<br>
> <br>
> - if (target == NULL || swbreaks == NULL || kind != target->breakpoint_size) {<br>
> + if (target == NULL || target->swbreaks.block == NULL ||<br>
> + kind != target->breakpoint_size) {<br>
> errno = EIO;<br>
> return -1;<br>
> }<br>
> <br>
> + rtems_debugger_target_swbreak* swbreaks = target->swbreaks.block;<br>
<br>
The debug server does not declare local vars in the body of functions. I would<br>
prefer the this code base stays that way if that is OK?<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Then how do you want to address the issue identified by Coverity</div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Chris<br>
<br>
> swbreak_size =<br>
> sizeof(rtems_debugger_target_swbreak) + target->breakpoint_size;<br>
> <br>
> <br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank" rel="noreferrer">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div></div></div>