Ensure string passed to cJSON_Parse is properly terminated
@@ -2911,7 +2911,8 @@ ikvdb_import_toc(
return err;
}
- buf = malloc(buflen);
+ /* Need an extra byte to terminate string read from TOC file */
+ buf = malloc(buflen + 1);
if (!buf) {
err = merr(ev(ENOMEM, HSE_ERR));
fclose(f);
@@ -2932,6 +2933,8 @@ ikvdb_import_toc(
return err;
}
+ buf[buflen] = '\0';
+
crc_rd = le32_to_cpu(*((u32 *)buf));
cjson_str = buf + 4;
