gallivm: Fix potential buffer overflowing in strncat.
Signed-off-by: José Fonseca <jfonseca@vmware.com>
This commit is contained in:
parent
1906d2b46b
commit
bf679ce1dc
|
@ -118,16 +118,16 @@ lp_build_print_value(struct gallivm_state *gallivm,
|
||||||
|
|
||||||
params[1] = lp_build_const_string(gallivm, msg);
|
params[1] = lp_build_const_string(gallivm, msg);
|
||||||
if (length == 1) {
|
if (length == 1) {
|
||||||
util_strncat(format, type_fmt, sizeof format);
|
util_strncat(format, type_fmt, sizeof(format) - strlen(format) - 1);
|
||||||
params[2] = value;
|
params[2] = value;
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < length; ++i) {
|
for (i = 0; i < length; ++i) {
|
||||||
util_strncat(format, type_fmt, sizeof format);
|
util_strncat(format, type_fmt, sizeof(format) - strlen(format) - 1);
|
||||||
params[2 + i] = LLVMBuildExtractElement(builder, value, lp_build_const_int32(gallivm, i), "");
|
params[2 + i] = LLVMBuildExtractElement(builder, value, lp_build_const_int32(gallivm, i), "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
util_strncat(format, "\n", sizeof format);
|
util_strncat(format, "\n", sizeof(format) - strlen(format) - 1);
|
||||||
|
|
||||||
params[0] = lp_build_const_string(gallivm, format);
|
params[0] = lp_build_const_string(gallivm, format);
|
||||||
return lp_build_print_args(gallivm, 2 + length, params);
|
return lp_build_print_args(gallivm, 2 + length, params);
|
||||||
|
|
Loading…
Reference in New Issue