Unverified Commit 1db6f4df authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!9285 of: module: add buffer overflow check in of_modalias()

parents 72a9f7a5 ea33f838
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -225,14 +225,15 @@ static ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len
	csize = snprintf(str, len, "of:N%pOFn%c%s", dev->of_node, 'T',
			 dev->of_node->type);
	tsize = csize;
	if (csize >= len)
		csize = len > 0 ? len - 1 : 0;
	len -= csize;
	if (str)
	str += csize;

	of_property_for_each_string(dev->of_node, "compatible", p, compat) {
		csize = strlen(compat) + 1;
		tsize += csize;
		if (csize > len)
		if (csize >= len)
			continue;

		csize = snprintf(str, len, "C%s", compat);