You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/01/20 09:53:53 UTC

[GitHub] [incubator-nuttx] juniskane opened a new pull request #5288: libs/libc/misc/lib_execinfo.c: fix bad memory access

juniskane opened a new pull request #5288:
URL: https://github.com/apache/incubator-nuttx/pull/5288


   ## Summary
   Our CI system found an issue with Clang static analyzer tool:
   
   ```
   61 | FAR char **backtrace_symbols(FAR void *const *buffer, int size)
   -- | --
   62 | {
   63 | FAR char **syms;
   64 | FAR char *buf;
   65 | int i;
   66 |  
   67 | syms = backtrace_malloc(buffer, size);
   68 | if (syms != NULL((void*)0))
     | 1Assuming 'syms' is not equal to NULL→ | 1 | Assuming 'syms' is not equal to NULL | →
   1 | Assuming 'syms' is not equal to NULL | →
     | 2←Taking true branch→ | 2 | ← | Taking true branch | →
   2 | ← | Taking true branch | →
   69 | {
   70 | buf = syms[size];
     | 3←Assigned value is garbage or undefined | 3 | ← | Assigned value is garbage or undefined
   3 | ← | Assigned value is garbage or undefined
   71 | for (i = 0; i < size; i++)
   72 | {
   73 | syms[i] = buf;
   74 | buf += sprintf(buf, "%pS", buffer[i]);
   75 | buf += 1;
   76 | }
   77 | }
   78 |  
   79 | return syms;
   80 | }
   ```
   Variable `syms` points to malloc()'ed memory so `syms[size]` aka `*(syms+size)` dereferences a pointer to memory with undefined content, so initially `buf` points to random memory location.
   
   ## Impact
   Memory corruption
   
   ## Testing
   Compile testing and static analysis only. We do not use this backtrace mechanism.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #5288: libs/libc/misc/lib_execinfo.c: fix bad memory access

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged pull request #5288:
URL: https://github.com/apache/incubator-nuttx/pull/5288


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org