Menu

Array index out of bounds; 'buf' buffer size is 0 and it is accessed at offset 3. [ctuArrayIndex]

Igor Misic
2024-03-28
2024-03-28
  • Igor Misic

    Igor Misic - 2024-03-28

    Can someone help me understand this error and what to do about it?
    This is my code:
    https://github.com/IMProject/IMUtility/blob/pr-chacha20/Src/utils.c#L243
    https://github.com/IMProject/IMUtility/blob/pr-chacha20/Src/crypto/chacha20.c#L87

    This is full error:

    Src/utils.c:243:23: error: Array index out of bounds; 'buf' buffer size is 0 and it is accessed at offset 3. [ctuArrayIndex]
        value = (uint32_t)buf[3] << 24u;
                          ^
    Src/crypto/chacha20.c:87:41: note: Calling function Utils_Deserialize32LE, 1st argument is uninitialized
        uint32_t x4  = Utils_Deserialize32LE(&key[0]);
                                            ^
    Src/utils.c:243:23: note: Using argument buf
        value = (uint32_t)buf[3] << 24u;
                          ^
    make: *** [Makefile:178: cppcheck] Error 1
    

    Thanks.

     
  • Igor Misic

    Igor Misic - 2024-03-28

    It seems it was connected to cppcheck v2.9 only, after I moved to 2.13.4 I didn't get this error anymore.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.