[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
MAX_PATH (or PATH_MAX) assumed to be ~255
From: |
Jeffrey Walton |
Subject: |
MAX_PATH (or PATH_MAX) assumed to be ~255 |
Date: |
Wed, 15 Jul 2020 12:02:09 -0400 |
Hi Everyone,
This caught my eye when running an analyzer build. For the analyzer
you can use Fedora 32 with GCC 10. Just add -fanalyzer to CFLAGS and
LDFLAGS.
call.c: In function ‘cob_resolve_internal.part.0’:
call.c:861:21: warning: ‘%s’ directive output may be truncated writing
up to 255 bytes into a region of size 242 [-Wformat-truncation=]
861 | "entry point '%s' not found", (const char *)s);
| ^~
call.c:860:4: note: ‘snprintf’ output between 25 and 280 bytes into a
destination of size 255
860 | snprintf (resolve_error_buff, (size_t)CALL_BUFF_MAX,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
861 | "entry point '%s' not found", (const char *)s);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
call.c:832:20: warning: ‘%s’ directive output may be truncated writing
up to 255 bytes into a region of size 242 [-Wformat-truncation=]
832 | "entry point '%s' not found", (const char *)s);
| ^~
call.c:831:3: note: ‘snprintf’ output between 25 and 280 bytes into a
destination of size 255
831 | snprintf (resolve_error_buff, (size_t)CALL_BUFF_MAX,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
832 | "entry point '%s' not found", (const char *)s);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I'm guessing "destination of size 255" comes from MAX_PATH or
PATH_MAX. That likely will not hold on Solaris or OS X. I believe
MAX_PATH is 4096 those OSes.
And here's another from the analyzer:
intrinsic.c:6386:3: warning: ‘strncpy’ output may be truncated copying
25 bytes from a string of length 36 [-Wstringop-truncation]
6386 | strncpy (time_format_str, datetime_format_str, COB_TIMESTR_MAX);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
intrinsic.c:6384:3: warning: ‘strncpy’ output may be truncated copying
10 bytes from a string of length 36 [-Wstringop-truncation]
6384 | strncpy (date_format_str, datetime_format_str, COB_DATESTR_MAX);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
intrinsic.c:6392:3: warning: ‘strncpy’ output may be truncated copying
10 bytes from a string of length 36 [-Wstringop-truncation]
6392 | strncpy (formatted_date, formatted_datetime, COB_DATESTR_MAX);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jeff
- MAX_PATH (or PATH_MAX) assumed to be ~255,
Jeffrey Walton <=