From patchwork Fri Feb 5 21:12:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 8239431 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 377AD9F37A for ; Fri, 5 Feb 2016 21:14:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 615EE201DD for ; Fri, 5 Feb 2016 21:14:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 86112201C7 for ; Fri, 5 Feb 2016 21:14:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757374AbcBEVN3 (ORCPT ); Fri, 5 Feb 2016 16:13:29 -0500 Received: from mail-pf0-f174.google.com ([209.85.192.174]:35475 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757335AbcBEVNY (ORCPT ); Fri, 5 Feb 2016 16:13:24 -0500 Received: by mail-pf0-f174.google.com with SMTP id c10so8379439pfc.2 for ; Fri, 05 Feb 2016 13:13:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Q9af3KG0ePrQQVjJYvOe5waBOhNnBz6V3UuZxJW2F2M=; b=h+/WZPWU1FRBEQ0/62d0WaRNyEVZ++0iG57kUIAl7mjwmxARsMf/GO/XOxJ3HNpJ2z frPlJY/bYOugb6FUvxnp8irAOwqDsSaI8zSpRHBbvlRTw0jiBH+HIKkQHai7AL2k0dNw DVtLoxv2eVbmRcGCsk5P0AkSojrjTQxcNPRQ4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Q9af3KG0ePrQQVjJYvOe5waBOhNnBz6V3UuZxJW2F2M=; b=ILnsPR0VjLullcPm6GBLPkE8ogyf974eKIBzBCdNNrhDvYFGS7y4gOqm58TaowZ5cJ wAaB2ZQeGkrbQl11qKU2TN/P2YqyfD4e8SxWq0AHW7zW4W6mARg/OcyRpXzM0KrPtU53 3Zoipz5b0Nk4vjOZ26zrLS2tRwqrUZ3rBbSfmI0OJ0xkgMTdYuoUT/QvN5FdXUCoKrN7 0Cg84oElGQKVWB0X3++32ra3NrW5V0EasIEZBp0BD6PUfuW8yOFTQp7HutcNXRJZUBgw CWVcaO4Ar2+EKiWDrVnKW9aEKYusYEDlL6CBElEuYexPQnXPhyUvDciWUlS4Kj8Cqq0k FPDA== X-Gm-Message-State: AG10YOQpQIYPPgGfWDeNDs8hb6WrnPF1xhZr1J5HJ4dLEG+SH6RPKteaz3aicP/0N3ObLA== X-Received: by 10.98.93.2 with SMTP id r2mr6812260pfb.64.1454706804098; Fri, 05 Feb 2016 13:13:24 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id fc8sm26533893pab.21.2016.02.05.13.13.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Feb 2016 13:13:23 -0800 (PST) From: Kees Cook To: Andrew Morton Cc: Kees Cook , Joe Perches , Andy Shevchenko , Rasmus Villemoes , Daniel Borkmann , Amitkumar Karwar , Nishant Sarmukadam , Kalle Valo , Steve French , Michael Ellerman , Heiko Carstens , Martin Schwidefsky , x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 3/4] lib: add "on"/"off" support to kstrtobool Date: Fri, 5 Feb 2016 13:12:48 -0800 Message-Id: <1454706769-8729-4-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.6.3 In-Reply-To: <1454706769-8729-1-git-send-email-keescook@chromium.org> References: <1454706769-8729-1-git-send-email-keescook@chromium.org> Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add support for "on" and "off" when converting to boolean. Signed-off-by: Kees Cook --- v3: - add dropped descripion change, andy.shevchenko --- lib/kstrtox.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/kstrtox.c b/lib/kstrtox.c index e8ba4a013e82..d8a5cf66c316 100644 --- a/lib/kstrtox.c +++ b/lib/kstrtox.c @@ -326,9 +326,9 @@ EXPORT_SYMBOL(kstrtos8); * @s: input string * @res: result * - * This routine returns 0 iff the first character is one of 'Yy1Nn0'. - * Otherwise it will return -EINVAL. Value pointed to by res is - * updated upon finding a match. + * This routine returns 0 iff the first character is one of 'Yy1Nn0', or + * [oO][NnFf] for "on" and "off". Otherwise it will return -EINVAL. Value + * pointed to by res is updated upon finding a match. */ int kstrtobool(const char *s, bool *res) { @@ -346,6 +346,20 @@ int kstrtobool(const char *s, bool *res) case '0': *res = false; return 0; + case 'o': + case 'O': + switch (s[1]) { + case 'n': + case 'N': + *res = true; + return 0; + case 'f': + case 'F': + *res = false; + return 0; + default: + break; + } default: break; }