Skip to content

Commit 35e30d7

Browse files
bazsiMrAnno
authored andcommitted
filterx/object-string: revive validation for non-zero terminated strings
This may still happen for stack allocated strings. Signed-off-by: Balazs Scheidler <balazs.scheidler@axoflow.com>
1 parent 3dae2c8 commit 35e30d7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/filterx/object-string.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ FilterXObject *filterx_string_new_translated(const gchar *str, gssize str_len, F
5353
FilterXObject *filterx_bytes_new(const gchar *str, gssize str_len);
5454
FilterXObject *filterx_protobuf_new(const gchar *str, gssize str_len);
5555

56-
/* NOTE: Consider using filterx_object_extract_string_ref() to also support message_value. */
56+
/* NOTE: Consider using filterx_object_extract_string_ref() to also support message_value.
57+
*
58+
* Also NOTE: the returned string may not be NUL terminated, although often
59+
* it will be. Generic code should handle the cases where it is not.
60+
*/
5761
static inline const gchar *
5862
filterx_string_get_value_ref(FilterXObject *s, gsize *length)
5963
{
@@ -64,6 +68,8 @@ filterx_string_get_value_ref(FilterXObject *s, gsize *length)
6468

6569
if (length)
6670
*length = self->str_len;
71+
else
72+
g_assert(self->str[self->str_len] == 0);
6773
return self->str;
6874
}
6975

0 commit comments

Comments
 (0)