[Bug 37121] New: PVS-Studio Error: String length changing

wine-bugs at winehq.org wine-bugs at winehq.org
Sat Aug 16 13:16:12 CDT 2014


https://bugs.winehq.org/show_bug.cgi?id=37121

            Bug ID: 37121
           Summary: PVS-Studio Error: String length changing
           Product: Wine
           Version: 1.7.22
          Hardware: x86-64
                OS: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: -unknown
          Assignee: wine-bugs at winehq.org
          Reporter: lukebenes at hotmail.com

PVS-Studio identifies a V692 error, An inappropriate attempt to append a null
character to a string. To determine the length of a string by 'strlen' function
correctly, a string ending with a null terminator should be used in the first
place. appdefaults.c 390

...
section[strlen(section)] = '\0'; /* remove last backslash  */
...

In this code, NULL character will actually be written into NULL character and
nothing will change. For the strlen() function to work properly, the string
must be already null-terminated. The comment suggests that the programmer
probably wanted to cut off the last backslash. Then the code should look like
this:

section[strlen(section) - 1] = '\0';

details on the V692 error here: http://www.viva64.com/en/d/0328/

-- 
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.



More information about the wine-bugs mailing list