From patchwork Wed Feb 12 09:27:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Westphal X-Patchwork-Id: 319590 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 433262C00B0 for ; Wed, 12 Feb 2014 20:31:15 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751638AbaBLJbN (ORCPT ); Wed, 12 Feb 2014 04:31:13 -0500 Received: from Chamillionaire.breakpoint.cc ([80.244.247.6]:37574 "EHLO Chamillionaire.breakpoint.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751558AbaBLJbM (ORCPT ); Wed, 12 Feb 2014 04:31:12 -0500 Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.80) (envelope-from ) id 1WDW9v-0003VH-6I; Wed, 12 Feb 2014 10:31:11 +0100 From: Florian Westphal To: netfilter-devel@vger.kernel.org Cc: Florian Westphal Subject: [PATCH ipset 2/2] lib: don't segfault when ipset_data_get returns NULL Date: Wed, 12 Feb 2014 10:27:20 +0100 Message-Id: <1392197240-9389-2-git-send-email-fw@strlen.de> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <1392197240-9389-1-git-send-email-fw@strlen.de> References: <1392197240-9389-1-git-send-email-fw@strlen.de> Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org ipset_data_get returns NULL if the attribute is not available, causes when running 'ipset list': $ ipset -N foo hash:ip $ ipset list Segmentation fault (core dumped) Signed-off-by: Florian Westphal --- Not sure about this patch, the missing attr is IPSET_OPT_MEMSIZE. Is the kernel supposed to send it along (i am on latest nf tree)? diff --git a/lib/print.c b/lib/print.c index f81c074..9ad4bab 100644 --- a/lib/print.c +++ b/lib/print.c @@ -378,6 +378,8 @@ ipset_print_number(char *buf, unsigned int len, assert(data); number = ipset_data_get(data, opt); + if (!number) + return 0; maxsize = ipset_data_sizeof(opt, AF_INET); D("opt: %u, maxsize %zu", opt, maxsize); if (maxsize == sizeof(uint8_t))