From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758521AbdKOPRP (ORCPT ); Wed, 15 Nov 2017 10:17:15 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:34216 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758496AbdKOPRH (ORCPT ); Wed, 15 Nov 2017 10:17:07 -0500 Subject: [PATCH v9 1/8] lib/cmdline.c: remove quotes symmetrically From: Hari Bathini To: linuxppc-dev , Andrew Morton , lkml Cc: Michael Ellerman , Ankit Kumar , Michal =?utf-8?b?U3VjaMOhbmVr?= , Mahesh J Salgaonkar Date: Wed, 15 Nov 2017 20:46:56 +0530 In-Reply-To: <151075897205.14434.9005256552409420263.stgit@hbathini.in.ibm.com> References: <151075897205.14434.9005256552409420263.stgit@hbathini.in.ibm.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 17111515-0016-0000-0000-00000501A6C7 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17111515-0017-0000-0000-0000283D6219 Message-Id: <151075900967.14434.2860376398321506569.stgit@hbathini.in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-11-15_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1711150206 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michal Suchanek Remove quotes from argument value only if there is qoute on both sides. Signed-off-by: Michal Suchanek --- lib/cmdline.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/cmdline.c b/lib/cmdline.c index 171c19b..6d398a8 100644 --- a/lib/cmdline.c +++ b/lib/cmdline.c @@ -227,14 +227,12 @@ char *next_arg(char *args, char **param, char **val) *val = args + equals + 1; /* Don't include quotes in value. */ - if (**val == '"') { - (*val)++; - if (args[i-1] == '"') - args[i-1] = '\0'; + if ((args[i-1] == '"') && ((quoted) || (**val == '"'))) { + args[i-1] = '\0'; + if (!quoted) + (*val)++; } } - if (quoted && args[i-1] == '"') - args[i-1] = '\0'; if (args[i]) { args[i] = '\0';