avb_str_concat: Fail if 0 is passed for buf_size. am: b73cea24f8 am: b5f275d3b5
Change-Id: I73b5a2a012f7cc6784ab784e96e3939b09fb3e30
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;