summaryrefslogtreecommitdiffstats
path: root/src/udata.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/udata.c')
-rw-r--r--src/udata.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/udata.c b/src/udata.c
index 0cc3520..e9bfc35 100644
--- a/src/udata.c
+++ b/src/udata.c
@@ -42,6 +42,11 @@ uint32_t nftnl_udata_buf_len(const struct nftnl_udata_buf *buf)
return (uint32_t)(buf->end - buf->data);
}
+static uint32_t nftnl_udata_buf_space(const struct nftnl_udata_buf *buf)
+{
+ return buf->size - nftnl_udata_buf_len(buf);
+}
+
EXPORT_SYMBOL(nftnl_udata_buf_data);
void *nftnl_udata_buf_data(const struct nftnl_udata_buf *buf)
{
@@ -74,7 +79,8 @@ bool nftnl_udata_put(struct nftnl_udata_buf *buf, uint8_t type, uint32_t len,
{
struct nftnl_udata *attr;
- if (len > UINT8_MAX || buf->size < len + sizeof(struct nftnl_udata))
+ if (len > UINT8_MAX ||
+ nftnl_udata_buf_space(buf) < len + sizeof(struct nftnl_udata))
return false;
attr = (struct nftnl_udata *)buf->end;