]>
Commit | Line | Data |
---|---|---|
9f8b3f1f JB |
1 | gcc's -Werror=stringop-truncation tries to be too smart, but actually it isn't. |
2 | Take len just after initialization, before call to mkstemp() (which doesn't change string length); | |
3 | now gcc doesn't complain. | |
4 | ||
5 | --- pinfo-0.6.13/src/utils.c.orig 2019-02-16 21:23:32.000000000 +0100 | |
6 | +++ pinfo-0.6.13/src/utils.c 2021-10-03 07:45:00.428038370 +0200 | |
7 | @@ -848,10 +848,10 @@ char * | |
8 | make_tempfile() | |
9 | { | |
10 | char *filename; | |
11 | - size_t len; | |
12 | ||
13 | /* TODO: fix hardcoded /tmp */ | |
14 | char tmpfile_template[] = "/tmp/pinfo.XXXXXX"; | |
15 | + size_t len = strlen(tmpfile_template)+1; | |
16 | ||
17 | /* create a tmpfile */ | |
18 | int fd = mkstemp(tmpfile_template); | |
19 | @@ -864,7 +864,6 @@ make_tempfile() | |
20 | } | |
21 | ||
22 | /* allocate a new string and copy the filename there */ | |
23 | - len = strlen(tmpfile_template)+1; | |
24 | filename = xmalloc(len+1); /* guarenteerd to be set to \0's */ | |
25 | strncpy(filename, tmpfile_template, len); | |
26 |