Skip to content

eBPF-based security platform

bpm: call a package state entry without a name malformed

Daniel Borkmann3c82eef620be
diff --git a/testing/unit/bpm_state.c b/testing/unit/bpm_state.c
index be4e8d90..777f59f0 100644
--- a/testing/unit/bpm_state.c
+++ b/testing/unit/bpm_state.c
@@ -53,6 +53,9 @@ static void state_refuses_an_entry_out_of_place(void)
ASSERT_EQ(bpm_state_emit(&in, 1, buf, sizeof(buf), &len), 0);
EXPECT_EQ(bpm_state_parse(buf, len, out, &n), -EINVAL);
EXPECT_EQ(bpm_state_parse("{\"schema\":1}", 12, out, &n), -EINVAL);
+ in.name[0] = '\0';
+ ASSERT_EQ(bpm_state_emit(&in, 1, buf, sizeof(buf), &len), 0);
+ EXPECT_EQ(bpm_state_parse(buf, len, out, &n), -EINVAL);
}
static const struct unit_case cases[] = {
diff --git a/util/bpm_state.c b/util/bpm_state.c
index 40059295..1d7688c7 100644
--- a/util/bpm_state.c
+++ b/util/bpm_state.c
@@ -28,10 +28,10 @@ static int on_state_entry(void *ud)
struct state_sink *s = ud;
char expected[PATH_MAX];
- if (s->n >= BPM_MAX_STATE || !s->scratch.name[0] ||
- !s->scratch.version[0])
+ if (s->n >= BPM_MAX_STATE)
return -E2BIG;
- if (!bpm_name_ok(s->scratch.name) ||
+ if (!s->scratch.name[0] || !s->scratch.version[0] ||
+ !bpm_name_ok(s->scratch.name) ||
!bpm_version_ok(s->scratch.version) ||
!bpm_name_ok(s->scratch.source))
return -EINVAL;