Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp4369656pxb; Tue, 5 Oct 2021 01:22:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQ7pYDLQkm/mrtyD5Y0yqeZc86eLt8QJq4kK0wBtndadOHhy+b5y60EB9jw5MoIWB1OiBM X-Received: by 2002:a05:6402:1d04:: with SMTP id dg4mr24317637edb.183.1633422174246; Tue, 05 Oct 2021 01:22:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633422174; cv=none; d=google.com; s=arc-20160816; b=NG6/8ZJ3cGaWE2Ak4LRXJqZ3DrvZqrv3ECSnJoj9nZGx2N1RIhW8XwvSwOK0kWECx+ +xl3NrXSHnUag1Tjv5AoXVxpmSenRLbM3BXjQ9auc5mtRHewKhATXTlTQOq1cG5TOjJg Fx2xk90HKp40lu51YBvIiliZpSaCbACB7nLb+lML7Y0S1PeF9zxv8URSzq43dhYO/Qd6 8ZeD5IV0DzmukBB0Tz4H99dDfptON4zdnuJNu7f3qg/qh4DjonhATMAQMZus7hdNEA16 lBkfot0ppQd8T70sLKM/jVWc2J3xjMN8WYhuxrzbBtyNC/n2JLRYcD+YPW9UFUdrZlCg LvhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=J0muq2VKgfHxAuq8xVWshCKwk1ULY5IJcALUOwpCnn4=; b=AQwVCQ1HT17bymzhjSe3lLeH9xXsR12wzESAGXzYA8wDvqtoq1UyLVXtIfNSgTMAxN ZARWOZEf/SM416cMJhvPUMVUyrg/Zra5twu2/qLBDa1AvfR6UMems57p2vTiNjCl6he7 UqJu7120sCUbktRw13OwTNU68XAN7vjTXt3BPGm0Urv579FEwPjdEzZ44VvsRjh0GB2P tumRmDXTANMqwp0tVYH17eMRwuu6RJBpC7v+XC1IRXI9FKYTdgC2tW5pzORkr415VtMK fdTB+15NDM+p2Fmw6PU7T+0ONaiIr1sHUVrH9OgiLcuhg6ezfYKrOtUST3Lffxftk/CC MzjA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z16si34524856edd.384.2021.10.05.01.22.29; Tue, 05 Oct 2021 01:22:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233271AbhJEIUe (ORCPT + 99 others); Tue, 5 Oct 2021 04:20:34 -0400 Received: from mga01.intel.com ([192.55.52.88]:35781 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233174AbhJEIUd (ORCPT ); Tue, 5 Oct 2021 04:20:33 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10127"; a="248943315" X-IronPort-AV: E=Sophos;i="5.85,348,1624345200"; d="scan'208";a="248943315" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2021 01:18:43 -0700 X-IronPort-AV: E=Sophos;i="5.85,348,1624345200"; d="scan'208";a="589267458" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2021 01:18:41 -0700 Received: from andy by smile with local (Exim 4.95) (envelope-from ) id 1mXfeo-008pR6-6c; Tue, 05 Oct 2021 11:18:38 +0300 Date: Tue, 5 Oct 2021 11:18:38 +0300 From: Andy Shevchenko To: Heiko Carstens Cc: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, Vasily Gorbik , Christian Borntraeger Subject: Re: [PATCH v1 1/1] s390: Use string_upper() instead of open coded variant Message-ID: References: <20211001130201.72545-1-andriy.shevchenko@linux.intel.com> 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, Oct 04, 2021 at 10:31:46PM +0200, Heiko Carstens wrote: > On Fri, Oct 01, 2021 at 04:02:01PM +0300, Andy Shevchenko wrote: ... > > + /* Segment name is limited by 8 characters + NUL */ > > + char tmp[8 + 1]; > > int i; > > > > - for (i = 0; i < 8; i++) { > > - if (name[i] == '\0') > > - break; > > - dcss_name[i] = toupper(name[i]); > > - } > > - for (; i < 8; i++) > > - dcss_name[i] = ' '; > > + /* > > + * This snprintf() call does two things: > > + * - makes a NUL-terminated copy of the input string > > + * - pads it with spaces > > + */ > > + snprintf(tmp, sizeof(tmp), "%s ", name); > > I can't say I like code where I have to count spaces in order to > verify if the code is actually correct. I understand your point, but have any idea how to make it differently and not ugly at the same time? > > + string_upper(dcss_name, tmp); ... > > static struct dcss_segment * > > segment_by_name (char *name) > > { > > - char dcss_name[9]; > > + char dcss_name[8]; > > string_upper will copy the terminating NUL-byte. By reducing the size > of dcss_name to 8 bytes this will result in stack corruption. Nope. Even in the original code this additional byte is left unused. -- With Best Regards, Andy Shevchenko