Coverity ID 26083 shell.c

Joel Sherrill joel.sherrill at oarcorp.com
Thu Nov 20 00:29:30 UTC 2014


Hi

I think this also likely indicates an issue in shell.c and/or
login_prompt.c.

644
   
CID 26083 (#1 of 1): Dereference after null check
(FORWARD_NULL)4. var_deref_model: Passing null
pointer out to rtems_shell_login_prompt, which dereferences it. [hide
details
<https://scan5.coverity.com:8443/eventId=19722847-4&modelId=19722847-0&fileInstanceId=64396592&filePath=%2Fusers%2Fjoel%2Frtems-4.11-work%2Frtems%2Fcpukit%2Flibmisc%2Fshell%2Flogin_prompt.c&fileStart=150&fileEnd=209>]
645  return rtems_shell_login_prompt(in, out, env->devname, env->login_check);

Earlier in this method in shell.c, there is a test for out being NULL.
This code is outside that check so NULL could be passed into
rtems_shell_login_prompt() which uses the NULL.

The rtems_shell_login method that this code in is static and it is
invoked in only one place with stdin, stdout. My analysis is that
we should just add _Assert(in/out) and remove the "if (out)"
code that appears to be unnecessary. This would eliminate
the logic path that trips this error.

Not as much a bug as useless tests leading to a confusing
state.

Comments?

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill at OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20141119/35fedc4d/attachment.html>


More information about the devel mailing list