fix uninitialized memory when parsing bogofilter header - bmf - bmf (Bayesian Mail Filter) 0.9.4 fork + patches
(HTM) git clone git://git.codemadness.org/bmf
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 24fa4a0c3c143c6f36f1ca08b41135156c68f9ff
(DIR) parent b627d86afb6118bb029d5601078fe972d576ab3e
(HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Thu, 8 Nov 2018 18:07:02 +0100
fix uninitialized memory when parsing bogofilter header
the memory was not guaranteed to be NUL terminated
Diffstat:
M dbh.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
---
(DIR) diff --git a/dbh.c b/dbh.c
@@ -221,7 +221,7 @@ dbtext_db_opentable(dbhtext_t * pthis, cpchar table, bool_t rdonly)
if (st.st_size == 0) {
return (dbt_t *) ptable;
}
- if ((ptable->pbuf = malloc(st.st_size)) == NULL) {
+ if ((ptable->pbuf = calloc(1, st.st_size + 1)) == NULL) {
perror("malloc()");
goto bail_uc;
}
@@ -229,6 +229,7 @@ dbtext_db_opentable(dbhtext_t * pthis, cpchar table, bool_t rdonly)
perror("read()");
goto bail_fuc;
}
+
/* XXX: bogofilter compatibility */
if (sscanf(ptable->pbuf, BOGOFILTER_HEADER, &ptable->nmsgs) != 1) {
goto bail_fuc;