Skip to content

Commit

Permalink
logging example -- fix a typo in a condition
Browse files Browse the repository at this point in the history
Found by Coverity:
```
*** CID 1456740:  Memory - illegal accesses  (OVERRUN)
/syscall_intercept-ubuntu-16.04/examples/syscall_logger.c: 700 in print_rdec()
694     static char *
695     print_rdec(char *dst, long n)
696     {
697     	dst = print_signed_dec(dst, n);
698
699     	if (n < 0 && n >= -((long)ARRAY_SIZE(error_codes))) {
>>>     CID 1456740:  Memory - illegal accesses  (OVERRUN)
>>>     Overrunning array "error_codes" of 134 8-byte elements at element index 134 (byte offset 1072) using index "-n" (which evaluates to 134).
700     		if (error_codes[-n] != NULL) {
701     			dst = print_cstr(dst, " (");
702     			dst = print_cstr(dst, error_codes[-n]);
703     			dst = print_cstr(dst, ")");
704     		}
705     	}
```
  • Loading branch information
GBuella committed Sep 15, 2017
1 parent 7149bf2 commit 9e26a71
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion examples/syscall_logger.c
Expand Up @@ -696,7 +696,7 @@ print_rdec(char *dst, long n)
{
dst = print_signed_dec(dst, n);

if (n < 0 && n >= -((long)ARRAY_SIZE(error_codes))) {
if (n < 0 && n > -((long)ARRAY_SIZE(error_codes))) {
if (error_codes[-n] != NULL) {
dst = print_cstr(dst, " (");
dst = print_cstr(dst, error_codes[-n]);
Expand Down

0 comments on commit 9e26a71

Please sign in to comment.