Commit a857d992 authored by Jan Höppner's avatar Jan Höppner Committed by Jens Axboe
Browse files

s390/dasd: Use scnprintf() instead of sprintf()



Use scnprintf() instead of sprintf() for those cases where the
destination is an array and the size of the array is known at compile
time.

This prevents theoretical buffer overflows, but also avoids that people
again and again spend time to figure out if the code is actually safe.

Signed-off-by: default avatarJan Höppner <hoeppner@linux.ibm.com>
Reviewed-by: default avatarStefan Haberland <sth@linux.ibm.com>
Signed-off-by: default avatarStefan Haberland <sth@linux.ibm.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 43198756
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -355,7 +355,8 @@ static int __init dasd_parse_range(const char *range)
	/* each device in dasd= parameter should be set initially online */
	features |= DASD_FEATURE_INITIAL_ONLINE;
	while (from <= to) {
		sprintf(bus_id, "%01x.%01x.%04x", from_id0, from_id1, from++);
		scnprintf(bus_id, sizeof(bus_id),
			  "%01x.%01x.%04x", from_id0, from_id1, from++);
		devmap = dasd_add_busid(bus_id, features);
		if (IS_ERR(devmap)) {
			rc = PTR_ERR(devmap);