avb_str_concat: Fail if 0 is passed for buf_size.
Bug: 130231426
Test: All AVB unit tests pass.
Merged-In: If27af10acebc7ae37409bee75e12b110904e46f6
Change-Id: I9bb847fa49489aa88c93f1e4ffe36cc03a767ce7
diff --git a/libavb/avb_util.c b/libavb/avb_util.c
index 938ce4e..c0064cf 100644
--- a/libavb/avb_util.c
+++ b/libavb/avb_util.c
@@ -195,6 +195,12 @@
size_t str2_len) {
uint64_t combined_len;
+ // Doesn't make sense to pass 0 for buf_size since there's
+ // no room for the terminating NUL byte.
+ if (buf_size == 0) {
+ return false;
+ }
+
if (!avb_safe_add(&combined_len, str1_len, str2_len)) {
avb_error("Overflow when adding string sizes.\n");
return false;