From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Burakov, Anatoly" Subject: Re: [PATCH v3 5/8] examples/power: add json string handling Date: Tue, 25 Sep 2018 16:31:12 +0100 Message-ID: References: <20180912144930.50578-1-david.hunt@intel.com> <20180914135406.52190-1-david.hunt@intel.com> <20180914135406.52190-6-david.hunt@intel.com> <47b4dbc6-48ca-f41c-86cb-e6f5b168ebf9@intel.com> <046d9290-55f9-8433-cbbd-b975f353fa47@intel.com> <5c1ca576-95ff-e150-7c4e-47bf4bfc255b@intel.com> <030089c0-bd02-4550-fdc3-7534d45754ba@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Cc: john.mcnamara@intel.com, stephen@networkplumber.org, lei.a.yao@intel.com, bruce.richardson@intel.com To: "Hunt, David" , dev@dpdk.org Return-path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 06FC75F25 for ; Tue, 25 Sep 2018 17:32:30 +0200 (CEST) In-Reply-To: <030089c0-bd02-4550-fdc3-7534d45754ba@intel.com> Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 25-Sep-18 4:15 PM, Hunt, David wrote: >>>> What happens if someone sends a string with a "{" or "}" inside? >>>> >>> >>> If we get to the end of the buffer without a "}", it calls the >>> library to convert, will fail, and move on.  No damage done (I hope). >>> Also, a short un-terminated (by "}") string will also exit when no >>> characters read. >>> So any invalid JSON string that's send to Jansson will fail to parse, >>> and the application will be ready for the next (hopefully valid) JSON >>> string. >> >> No, what i meant is something like this: >> >> { "json_value": "{"} >> >> According to JSON validator, this is a valid JSON string, but it will >> break your code :) >> > > You are correct if this code was designed to be a general purpose JSON > string reader. However, it's only designed to take in strings for this > sample application, and they do not expect any brace characters embedded > within quotes. So I think it's OK for this use case. Patches welcome, > though! :) > Fair enough :) > Thanks, > Dave. > > > -- Thanks, Anatoly