]> git.ipfire.org Git - thirdparty/libnftnl.git/commitdiff
object: Fix for wrong parameter passed to snprintf callback
authorPhil Sutter <phil@nwl.cc>
Tue, 9 Mar 2021 12:29:30 +0000 (13:29 +0100)
committerPhil Sutter <phil@nwl.cc>
Mon, 15 Mar 2021 11:23:07 +0000 (12:23 +0100)
Instead of the remaining buffer length, the used buffer length was
passed to object's snprintf callback (and the final snprintf call).

Fixes: 5573d0146c1ae ("src: support for stateful objects")
Signed-off-by: Phil Sutter <phil@nwl.cc>
src/object.c

index 008badeea9b6638891ad4a82ff77584689240612..46e79168daa76efbdce3d42335fa75a3dbb3a045 100644 (file)
@@ -396,11 +396,11 @@ static int nftnl_obj_snprintf_dflt(char *buf, size_t size,
        SNPRINTF_BUFFER_SIZE(ret, remain, offset);
 
        if (obj->ops) {
-               ret = obj->ops->snprintf(buf + offset, offset, type, flags,
+               ret = obj->ops->snprintf(buf + offset, remain, type, flags,
                                         obj);
                SNPRINTF_BUFFER_SIZE(ret, remain, offset);
        }
-       ret = snprintf(buf + offset, offset, "]");
+       ret = snprintf(buf + offset, remain, "]");
        SNPRINTF_BUFFER_SIZE(ret, remain, offset);
 
        return offset;