From patchwork Sat Sep 20 17:54:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jozsef Kadlecsik X-Patchwork-Id: 391536 X-Patchwork-Delegate: kadlec@blackhole.kfki.hu Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 1EFBA14012C for ; Sun, 21 Sep 2014 03:54:28 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757038AbaITRy2 (ORCPT ); Sat, 20 Sep 2014 13:54:28 -0400 Received: from smtp1.kfki.hu ([148.6.0.26]:34452 "EHLO smtp1.kfki.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756232AbaITRy1 (ORCPT ); Sat, 20 Sep 2014 13:54:27 -0400 Received: from localhost (localhost [127.0.0.1]) by smtp1.kfki.hu (Postfix) with ESMTP id A00393C800D9; Sat, 20 Sep 2014 19:54:23 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at smtp1.kfki.hu Received: from smtp1.kfki.hu ([127.0.0.1]) by localhost (smtp1.kfki.hu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id OsHpig2U8i9N; Sat, 20 Sep 2014 19:54:21 +0200 (CEST) Received: from blackhole.kfki.hu (blackhole.kfki.hu [148.6.0.114]) by smtp1.kfki.hu (Postfix) with ESMTP id 3CC9C3C800D7; Sat, 20 Sep 2014 19:54:21 +0200 (CEST) Received: by blackhole.kfki.hu (Postfix, from userid 1000) id 32CAB207A2; Sat, 20 Sep 2014 19:54:47 +0200 (CEST) Date: Sat, 20 Sep 2014 19:54:47 +0200 (CEST) From: Jozsef Kadlecsik To: Stig Thormodsrud cc: netfilter-devel@vger.kernel.org Subject: Re: ipset save issue In-Reply-To: Message-ID: References: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org On Thu, 18 Sep 2014, Stig Thormodsrud wrote: > I know the max group name length is 32 characters, but I'm running > into a problem with "save" if the group name is 29 characters. For > example: > > ubnt@ERL:~$ sudo ipset create A234567890123456789 bitmap:port range 1-65535 > ubnt@ERL:~$ sudo ipset add A234567890123456789 4512-65535 > ubnt@ERL:~$ sudo ipset save A234567890123456789 > file > ipset v6.21.1: Internal error at printing to output buffer > ubnt@ERL:~$ > > But if I change it to 28 characters it works: > > ubnt@ERL:~$ sudo ipset create A23456789012345678 bitmap:port range 1-65535 > ubnt@ERL:~$ sudo ipset add A23456789012345678 4512-65535 > ubnt@ERL:~$ sudo ipset save A23456789012345678 > file > ubnt@ERL:~$ > ubnt@ERL:~$ sudo ipset -V > ipset v6.21.1, protocol version: 6 > > Ideas? That's a strange (v)sprintf issue: instead of reporting the length of the string which would have been written, it simply returns an error code. The patch below fixes it and it'll be in the next release in a few days: Best regards, Jozsef - E-mail : kadlec@blackhole.kfki.hu, kadlecsik.jozsef@wigner.mta.hu PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt Address : Wigner Research Centre for Physics, Hungarian Academy of Sciences H-1525 Budapest 114, POB. 49, Hungary --- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/lib/session.c b/lib/session.c index cbef026..da162b0 100644 --- a/lib/session.c +++ b/lib/session.c @@ -716,13 +716,7 @@ retry: fmt, args); va_end(args); - if (ret < 0) { - ipset_err(session, - "Internal error at printing to output buffer"); - longjmp(printf_failure, 1); - } - - if (ret >= IPSET_OUTBUFLEN - len) { + if (ret < 0 || ret >= IPSET_OUTBUFLEN - len) { /* Buffer was too small, push it out and retry */ D("print buffer and try again: %u", len); if (loop++) { @@ -750,13 +744,7 @@ retry: ret = fn(session->outbuf + len, IPSET_OUTBUFLEN - len, session->data, opt, session->envopts); - if (ret < 0) { - ipset_err(session, - "Internal error at printing to output buffer"); - longjmp(printf_failure, 1); - } - - if (ret >= IPSET_OUTBUFLEN - len) { + if (ret < 0 || ret >= IPSET_OUTBUFLEN - len) { /* Buffer was too small, push it out and retry */ D("print buffer and try again: %u", len); if (loop++) {