Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coverity report for core.c #1106

Open
mcuee opened this issue Apr 3, 2022 · 1 comment
Open

Coverity report for core.c #1106

mcuee opened this issue Apr 3, 2022 · 1 comment
Labels
core Related to common codes Coverity Coverity or other Static Code Analysis Tools

Comments

@mcuee
Copy link
Member

mcuee commented Apr 3, 2022

1 new defect(s) introduced to libusb/libusb found with Coverity Scan.
1 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.

New defect(s) Reported-by: Coverity Scan
Showing 1 of 1 defect(s)

** CID 351373:  Memory - corruptions  (OVERRUN)
/libusb/core.c: 2646 in log_v()

________________________________________________________________________________________________________
*** CID 351373:  Memory - corruptions  (OVERRUN)
/libusb/core.c: 2646 in log_v()
2640                    text_len = (int)sizeof(buf) - header_len;
2641            }
2642            if (header_len + text_len + (int)sizeof(USBI_LOG_LINE_END) >= (int)sizeof(buf)) {
2643                    /* Need to truncate the text slightly to fit on the terminator. */
2644                    text_len -= (header_len + text_len + (int)sizeof(USBI_LOG_LINE_END)) - (int)sizeof(buf);
2645            }
>>>     CID 351373:  Memory - corruptions  (OVERRUN)
>>>     "strcpy" will overrun its first argument "buf + header_len + text_len" which can accommodate 1 bytes.  The length of the second argument ""\n"" is 2 bytes, including the terminating null.
2646            strcpy(buf + header_len + text_len, USBI_LOG_LINE_END);
2647     
2648            log_str(level, buf);
2649     
2650            /* Per-context log handler */
2651     #ifndef ENABLE_DEBUG_LOGGING
@mcuee mcuee added core Related to common codes Coverity Coverity or other Static Code Analysis Tools labels Apr 3, 2022
@benzea
Copy link

benzea commented Apr 3, 2022

I have a patch for this one in #1067 (i.e. 3c792a9).

I never understood the warning though. I think coverity is just confused and takes a branch incorrectly for some reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Related to common codes Coverity Coverity or other Static Code Analysis Tools
Projects
None yet
Development

No branches or pull requests

2 participants