From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACCE1C54EBE for ; Mon, 9 Jan 2023 11:26:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236729AbjAIL0O (ORCPT ); Mon, 9 Jan 2023 06:26:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236912AbjAIL0J (ORCPT ); Mon, 9 Jan 2023 06:26:09 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17EBC167CE for ; Mon, 9 Jan 2023 03:26:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673263569; x=1704799569; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=3qWXvBiMwic5hXKXKXJ43zm4Wa3xTBKTNHaKUocqVo4=; b=gB4Oq549qGczHE/YStje1ezFyv0ATpIk4NVvwJiYZC8KYx8Bf2oKfj12 LEErneJ6zZAiqzJ1jAMpY87Pt2f6Uv4N/c+5fkJUNFAKS1+YqVZx6D2GV zmSdttqyJt/5dDdNiXaz/FyhlxzhMNO7F9USvNGYywCwfkYNnYuJATzXM RndNM18kOoQmcjB23RWJ0kXBkUInycTEITUIap0Li+mxuwD1dDHozLFn3 PNHV0+jOZGOtZ0jhwZupn3393Ps9Ycye0QjHo7PFBhDlekv1zwEpb8vlw MTpS2EU4n2uNpjYyUjm3xMA1Gf46d6QTc17C4MgXLd1qYqFoiMktxvi6H Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10584"; a="350063960" X-IronPort-AV: E=Sophos;i="5.96,311,1665471600"; d="scan'208";a="350063960" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jan 2023 03:26:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10584"; a="719907230" X-IronPort-AV: E=Sophos;i="5.96,311,1665471600"; d="scan'208";a="719907230" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga008.fm.intel.com with ESMTP; 09 Jan 2023 03:26:06 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1pEqI1-006Mdc-0n; Mon, 09 Jan 2023 13:26:05 +0200 Date: Mon, 9 Jan 2023 13:26:04 +0200 From: Andy Shevchenko To: Sergey Shtylyov Cc: Petr Mladek , Steven Rostedt , Sergey Senozhatsky , Rasmus Villemoes , linux-kernel@vger.kernel.org Subject: Re: [PATCH] vsprintf: fix possible NULL pointer deref in vsnprintf() Message-ID: References: <1f4d159e-5382-3c75-bd5e-42337ecd8c28@omp.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 09, 2023 at 01:23:40PM +0200, Andy Shevchenko wrote: > On Fri, Jan 06, 2023 at 12:16:31AM +0300, Sergey Shtylyov wrote: ... > > + /* > > + * C99 allows @buf to be NULL when @size is 0. We treat such NULL as if > > + * @buf pointed to 0-sized buffer, so we can both avoid a NULL pointer > > + * dereference and still return # of characters that would be written > > + * if @buf pointed to a valid buffer... > > + */ > > + if (!buf) > > + size = 0; > > Do we have test cases for that? This still stays... > And what's wrong to print "(null)" ? Have you checked if your patch makes any > regressions to those cases? ...but this paragraph is not for the case (I mixed it with the arguments to be NULL). -- With Best Regards, Andy Shevchenko