From: Phil Sutter Date: Tue, 9 Mar 2021 12:29:30 +0000 (+0100) Subject: object: Fix for wrong parameter passed to snprintf callback X-Git-Tag: libnftnl-1.2.0~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=636fd0daf4890a785e8b165c5ce2c602e5361fcb;p=thirdparty%2Flibnftnl.git object: Fix for wrong parameter passed to snprintf callback 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 --- diff --git a/src/object.c b/src/object.c index 008badee..46e79168 100644 --- a/src/object.c +++ b/src/object.c @@ -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;