ubsan: remove most sprintf calls
sprintf is implemented as snprintf(..., INT_MAX, ...) which will overflow the argument pointer for the end, then fix the end to be -1. This technically works but we know the actual buffer size in all these call sites, might as well do this properly Change-Id: I807d09f46a0221f539063fda515e1c504e658d40
This commit is contained in:
@@ -1474,9 +1474,10 @@ static void numa_distances_init()
|
||||
char buf[1024];
|
||||
char *pbuf = buf;
|
||||
|
||||
pbuf += sprintf(pbuf, "NUMA %d distances: ", i);
|
||||
pbuf += snprintf(pbuf, 1024, "NUMA %d distances: ", i);
|
||||
for (j = 0; j < ihk_mc_get_nr_numa_nodes(); ++j) {
|
||||
pbuf += sprintf(pbuf, "%d (%d), ",
|
||||
pbuf += snprintf(pbuf, 1024 - (pbuf - buf),
|
||||
"%d (%d), ",
|
||||
memory_nodes[i].nodes_by_distance[j].id,
|
||||
memory_nodes[i].nodes_by_distance[j].distance);
|
||||
}
|
||||
@@ -1519,7 +1520,8 @@ void numa_sysfs_setup(void) {
|
||||
char path[PATH_MAX];
|
||||
|
||||
for (i = 0; i < ihk_mc_get_nr_numa_nodes(); ++i) {
|
||||
sprintf(path, "/sys/devices/system/node/node%d/meminfo", i);
|
||||
snprintf(path, PATH_MAX,
|
||||
"/sys/devices/system/node/node%d/meminfo", i);
|
||||
|
||||
error = sysfs_createf(&numa_sysfs_meminfo, &memory_nodes[i],
|
||||
0444, path);
|
||||
|
||||
Reference in New Issue
Block a user