Skip to content

Commit d706380

Browse files
committed
posix.cfg: Improved configuration for swab().
1 parent d1b6954 commit d706380

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

cfg/posix.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5496,6 +5496,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
54965496
<leak-ignore/>
54975497
<not-overlapping-data ptr1-arg="1" ptr2-arg="2" size-arg="3"/>
54985498
<arg nr="1" direction="in">
5499+
<not-null/>
54995500
<not-uninit/>
55005501
<minsize type="argvalue" arg="3"/>
55015502
</arg>

test/cfg/posix.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,30 @@ void overlappingWriteFunction_swab(char *src, char *dest, ssize_t n)
431431
swab(src, src+3, 4);
432432
}
433433

434+
void bufferAccessOutOfBounds_swab(char *src, char *dest, ssize_t n)
435+
{
436+
// No warning shall be shown:
437+
swab(dest, src, n);
438+
char srcBuf[42] = {0};
439+
char destBuf[42] = {0};
440+
swab(srcBuf, dest, 42);
441+
// cppcheck-suppress bufferAccessOutOfBounds
442+
swab(srcBuf, dest, 43);
443+
swab(src, destBuf, 42);
444+
// cppcheck-suppress bufferAccessOutOfBounds
445+
swab(src, destBuf, 43);
446+
}
447+
448+
void nullPointer_swab(char *src, char *dest, ssize_t n)
449+
{
450+
// No warning shall be shown:
451+
swab(dest, src, n);
452+
// cppcheck-suppress nullPointer
453+
swab(NULL, dest, n);
454+
// cppcheck-suppress nullPointer
455+
swab(src, NULL, n);
456+
}
457+
434458
bool invalidFunctionArgBool_isascii(bool b, int c)
435459
{
436460
// cppcheck-suppress invalidFunctionArgBool

0 commit comments

Comments
 (0)