gcc 10 --enable-asan warnings
Open
Nobody has claimed this yet.
maintenance/cleanup
- Dominant language
- C
- Stars
- 13.6k
- Forks
- 2.6k
- PR merge metrics
- No merged PRs in 30d
Description
gcc 10 gives warnings about snprintf. It does not give warnings like gcc 11 in #4637.
$ gcc --version
gcc (Debian 10.2.1-6) 10.2.1 20210110
dynamic_fmt.c: In function ‘prepare’:
dynamic_fmt.c:1156:36: warning: ‘$$F’ directive output may be truncated writing 3 bytes into a region of size between 1 and 1024 [-Wformat-truncation=]
1156 | snprintf(ct2, sizeof(ct2), "%s$$F%d%s", cpBuilding, i, split_fields[i]);
| ^~~
dynamic_fmt.c:1156:33: note: directive argument in the range [0, 9]
1156 | snprintf(ct2, sizeof(ct2), "%s$$F%d%s", cpBuilding, i, split_fields[i]);
| ^~~~~~~~~~~
dynamic_fmt.c:1156:6: note: ‘snprintf’ output 5 or more bytes (assuming 1028) into a destination of size 1024
1156 | snprintf(ct2, sizeof(ct2), "%s$$F%d%s", cpBuilding, i, split_fields[i]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
krb5pa-sha1_fmt_plug.c: In function ‘split’:
krb5pa-sha1_fmt_plug.c:287:37: warning: ‘$’ directive output may be truncated writing 1 byte into a region of size between 0 and 374 [-Wformat-truncation=]
287 | snprintf(out, sizeof(out), "%s%s$%s$%s$%s$%s", FORMAT_TAG, e, u, r, s, tc);
| ^
krb5pa-sha1_fmt_plug.c:287:2: note: ‘snprintf’ output 13 or more bytes (assuming 515) into a destination of size 383
287 | snprintf(out, sizeof(out), "%s%s$%s$%s$%s$%s", FORMAT_TAG, e, u, r, s, tc);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
opencl_common.c: In function ‘opencl_driver_info’:
opencl_common.c:358:48: warning: ‘%s’ directive output may be truncated writing up to 2111 bytes into a region of size between 51 and 2098 [-Wformat-truncation=]
358 | snprintf(buf, sizeof(buf), "%s - AMDGPU-Pro %s", dname, name);
| ^~
opencl_common.c:358:4: note: ‘snprintf’ output between 15 and 4173 bytes into a destination of size 2112
358 | snprintf(buf, sizeof(buf), "%s - AMDGPU-Pro %s", dname, name);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
opencl_common.c:356:45: warning: ‘%s’ directive output may be truncated writing up to 2111 bytes into a region of size between 54 and 2101 [-Wformat-truncation=]
356 | snprintf(buf, sizeof(buf), "%s - Crimson %s", dname, name);
| ^~
opencl_common.c:356:4: note: ‘snprintf’ output between 12 and 4170 bytes into a destination of size 2112
356 | snprintf(buf, sizeof(buf), "%s - Crimson %s", dname, name);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
opencl_common.c:354:46: warning: ‘%s’ directive output may be truncated writing up to 2111 bytes into a region of size between 53 and 2100 [-Wformat-truncation=]
354 | snprintf(buf, sizeof(buf), "%s - Catalyst %s", dname, name);
| ^~
opencl_common.c:354:4: note: ‘snprintf’ output between 13 and 4171 bytes into a destination of size 2112
354 | snprintf(buf, sizeof(buf), "%s - Catalyst %s", dname, name);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
opencl_krb5pa-sha1_fmt_plug.c: In function ‘split’:
opencl_krb5pa-sha1_fmt_plug.c:445:37: warning: ‘$’ directive output may be truncated writing 1 byte into a region of size between 0 and 274 [-Wformat-truncation=]
445 | snprintf(out, sizeof(out), "%s%s$%s$%s$%s$%s", FORMAT_TAG, e, u, r, s, tc);
| ^
opencl_krb5pa-sha1_fmt_plug.c:445:2: note: ‘snprintf’ output 13 or more bytes (assuming 339) into a destination of size 283
445 | snprintf(out, sizeof(out), "%s%s$%s$%s$%s$%s", FORMAT_TAG, e, u, r, s, tc);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the GCC 10 warnings with the --enable-asan configuration, then inspect the snprintf call sites in dynamic_fmt.c, krb5pa-sha1_fmt_plug.c, opencl_common.c, and opencl_krb5pa-sha1_fmt_plug.c. Determine which reported truncation warnings require changes and verify the build no longer emits the relevant warnings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100