warning fix artifact.c
artifact.c: In function 'dump_artifact_info':
artifact.c:1088:37: warning: '%s' directive writing up to 255 bytes into a region of size 218 [-Wformat-overflow=]
1088 | Sprintf(buf, " %-36.36s%s", artiname(m), buf2);
| ^~ ~~~~
In file included from ../include/config.h:652,
from ../include/hack.h:10,
from artifact.c:6:
../include/global.h:255:24: note: 'sprintf' output between 39 and 294 bytes into a destination of size 256
255 | #define Sprintf (void) sprintf
artifact.c:1088:13: note: in expansion of macro 'Sprintf'
1088 | Sprintf(buf, " %-36.36s%s", artiname(m), buf2);
| ^~~~~~~
This commit is contained in:
@@ -1067,7 +1067,8 @@ dump_artifact_info(winid tmpwin)
|
||||
|
||||
putstr(tmpwin, iflags.menu_headings, "Artifacts");
|
||||
for (m = 1; m <= NROFARTIFACTS; ++m) {
|
||||
Sprintf(buf2, "[%s%s%s%s%s%s%s%s%s]", /* 9 bits overall */
|
||||
Snprintf(buf2, sizeof buf2,
|
||||
"[%s%s%s%s%s%s%s%s%s]", /* 9 bits overall */
|
||||
artiexist[m].exists ? "exists;" : "",
|
||||
artiexist[m].found ? " hero knows;" : "",
|
||||
/* .exists and .found have different punctuation because
|
||||
@@ -1085,7 +1086,7 @@ dump_artifact_info(winid tmpwin)
|
||||
else
|
||||
#else
|
||||
/* "The Platinum Yendorian Express Card" is 35 characters */
|
||||
Sprintf(buf, " %-36.36s%s", artiname(m), buf2);
|
||||
Snprintf(buf, sizeof buf, " %-36.36s%s", artiname(m), buf2);
|
||||
#endif
|
||||
putstr(tmpwin, 0, buf);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user