Skip to content
Snippets Groups Projects
Commit e2000575 authored by Stephan Bosch's avatar Stephan Bosch Committed by aki.tuomi
Browse files

lib-sieve: sieve-binary-dumper - Fix crash occurring when binary blocks fail to load.

The sieve_binary_block_index/get() functions return NULL when the block index is
invalid somehow. This was not handled by the dumper, thereby causing a crash.
parent 09194118
No related branches found
No related tags found
No related merge requests found
......@@ -141,6 +141,9 @@ bool sieve_binary_dumper_run(struct sieve_binary_dumper *dumper,
struct sieve_binary_block *sblock =
sieve_binary_block_get(sbin, i);
if (sblock == NULL)
return FALSE;
sieve_binary_dumpf(
denv, "%3d: size: %zu bytes\n",
i, sieve_binary_block_get_size(sblock));
......@@ -152,6 +155,8 @@ bool sieve_binary_dumper_run(struct sieve_binary_dumper *dumper,
sieve_binary_dump_sectionf(denv, "Script metadata (block: %d)",
SBIN_SYSBLOCK_SCRIPT_DATA);
sblock = sieve_binary_block_get(sbin, SBIN_SYSBLOCK_SCRIPT_DATA);
if (sblock == NULL)
return FALSE;
T_BEGIN {
offset = 0;
......@@ -220,6 +225,9 @@ bool sieve_binary_dumper_run(struct sieve_binary_dumper *dumper,
dumper->dumpenv.sblock =
sieve_binary_block_get(sbin, SBIN_SYSBLOCK_MAIN_PROGRAM);
if (dumper->dumpenv.sblock == NULL)
return FALSE;
dumper->dumpenv.cdumper = sieve_code_dumper_create(&(dumper->dumpenv));
if (dumper->dumpenv.cdumper != NULL) {
......@@ -238,7 +246,7 @@ bool sieve_binary_dumper_run(struct sieve_binary_dumper *dumper,
* Hexdump production
*/
void sieve_binary_dumper_hexdump(struct sieve_binary_dumper *dumper,
bool sieve_binary_dumper_hexdump(struct sieve_binary_dumper *dumper,
struct ostream *stream)
{
struct sieve_binary *sbin = dumper->dumpenv.sbin;
......@@ -257,6 +265,9 @@ void sieve_binary_dumper_hexdump(struct sieve_binary_dumper *dumper,
struct sieve_binary_block *sblock =
sieve_binary_block_get(sbin, i);
if (sblock == NULL)
return FALSE;
sieve_binary_dumpf(denv, "%3d: size: %zu bytes\n",
i, sieve_binary_block_get_size(sblock));
}
......@@ -323,4 +334,5 @@ void sieve_binary_dumper_hexdump(struct sieve_binary_dumper *dumper,
str_printfa(line, "%08llx\n", (unsigned long long)offset);
o_stream_nsend(stream, str_data(line), str_len(line));
}
return TRUE;
}
......@@ -35,7 +35,7 @@ bool sieve_binary_dumper_run(struct sieve_binary_dumper *dumper,
* Hexdump production
*/
void sieve_binary_dumper_hexdump(struct sieve_binary_dumper *dumper,
bool sieve_binary_dumper_hexdump(struct sieve_binary_dumper *dumper,
struct ostream *stream);
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.