<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>