{"id":812901,"url":"http://patchwork.ozlabs.org/api/patches/812901/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20170912145812.15380-1-phil@nwl.cc/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170912145812.15380-1-phil@nwl.cc>","list_archive_url":null,"date":"2017-09-12T14:58:12","name":"[iproute] ipaddress: Fix segfault in 'addr showdump'","commit_ref":null,"pull_url":null,"state":"superseded","archived":true,"hash":"ef1ac23a4cf4dc17bf597e493f9488648f13bc5c","submitter":{"id":4285,"url":"http://patchwork.ozlabs.org/api/people/4285/?format=json","name":"Phil Sutter","email":"phil@nwl.cc"},"delegate":{"id":389,"url":"http://patchwork.ozlabs.org/api/users/389/?format=json","username":"shemminger","first_name":"stephen","last_name":"hemminger","email":"shemminger@vyatta.com"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20170912145812.15380-1-phil@nwl.cc/mbox/","series":[{"id":2723,"url":"http://patchwork.ozlabs.org/api/series/2723/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=2723","date":"2017-09-12T14:58:12","name":"[iproute] ipaddress: Fix segfault in 'addr showdump'","version":1,"mbox":"http://patchwork.ozlabs.org/series/2723/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/812901/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/812901/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xs7Hk4LK4z9s4s\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 13 Sep 2017 00:59:46 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751415AbdILO6Y (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tTue, 12 Sep 2017 10:58:24 -0400","from orbyte.nwl.cc ([151.80.46.58]:47966 \"EHLO orbyte.nwl.cc\"\n\trhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP\n\tid S1751404AbdILO6X (ORCPT <rfc822;netdev@vger.kernel.org>);\n\tTue, 12 Sep 2017 10:58:23 -0400","from localhost ([::1]:42508 helo=xsao)\n\tby orbyte.nwl.cc with esmtp (Exim 4.89)\n\t(envelope-from <phil@nwl.cc>)\n\tid 1drmdq-00044a-CB; Tue, 12 Sep 2017 16:58:22 +0200"],"From":"Phil Sutter <phil@nwl.cc>","To":"Stephen Hemminger <stephen@networkplumber.org>","Cc":"netdev@vger.kernel.org, Hangbin Liu <liuhangbin@gmail.com>","Subject":"[iproute PATCH] ipaddress: Fix segfault in 'addr showdump'","Date":"Tue, 12 Sep 2017 16:58:12 +0200","Message-Id":"<20170912145812.15380-1-phil@nwl.cc>","X-Mailer":"git-send-email 2.13.1","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"Obviously, 'addr showdump' feature wasn't adjusted to json output\nsupport. As a consequence, calls to print_string() in print_addrinfo()\ntried to dereference a NULL FILE pointer.\n\nFixes: d0e720111aad2 (\"ip: ipaddress.c: add support for json output\")\nSigned-off-by: Phil Sutter <phil@nwl.cc>\n---\n ip/ipaddress.c | 18 ++++++++++++++++--\n 1 file changed, 16 insertions(+), 2 deletions(-)","diff":"diff --git a/ip/ipaddress.c b/ip/ipaddress.c\nindex 9797145023966..ee6c9f588e7ba 100644\n--- a/ip/ipaddress.c\n+++ b/ip/ipaddress.c\n@@ -1801,17 +1801,31 @@ static int show_handler(const struct sockaddr_nl *nl,\n {\n \tstruct ifaddrmsg *ifa = NLMSG_DATA(n);\n \n-\tprintf(\"if%d:\\n\", ifa->ifa_index);\n+\topen_json_object(NULL);\n+\tprint_int(PRINT_ANY, \"index\", \"if%d:\\n\", ifa->ifa_index);\n \tprint_addrinfo(NULL, n, stdout);\n+\tclose_json_object();\n \treturn 0;\n }\n \n static int ipaddr_showdump(void)\n {\n+\tint err;\n+\n \tif (ipadd_dump_check_magic())\n \t\texit(-1);\n \n-\texit(rtnl_from_file(stdin, &show_handler, NULL));\n+\tnew_json_obj(json, stdout);\n+\topen_json_object(NULL);\n+\topen_json_array(PRINT_JSON, \"addr_info\");\n+\n+\terr = rtnl_from_file(stdin, &show_handler, NULL);\n+\n+\tclose_json_array(PRINT_JSON, NULL);\n+\tclose_json_object();\n+\tdelete_json_obj();\n+\n+\texit(err);\n }\n \n static int restore_handler(const struct sockaddr_nl *nl,\n","prefixes":["iproute"]}