From patchwork Thu Apr 30 18:09:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Dickson X-Patchwork-Id: 6306781 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6425BBEEE1 for ; Thu, 30 Apr 2015 18:09:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9F4EF201EF for ; Thu, 30 Apr 2015 18:09:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B34C5201F4 for ; Thu, 30 Apr 2015 18:09:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751145AbbD3SJI (ORCPT ); Thu, 30 Apr 2015 14:09:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43958 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752095AbbD3SJG (ORCPT ); Thu, 30 Apr 2015 14:09:06 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 663E48E774 for ; Thu, 30 Apr 2015 18:09:06 +0000 (UTC) Received: from smallhat.boston.devel.redhat.com (vpn-56-224.rdu2.redhat.com [10.10.56.224]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3UI95Ua000381 for ; Thu, 30 Apr 2015 14:09:05 -0400 From: Steve Dickson To: Linux NFS Mailing list Subject: [PATCH] Handle NULL names better Date: Thu, 30 Apr 2015 14:09:03 -0400 Message-Id: <1430417344-25020-1-git-send-email-steved@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Detect when an application passes in NULL names and fail gracefully instead of crashing hard. Signed-off-by: Steve Dickson --- libnfsidmap.c | 5 ++++- nss.c | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libnfsidmap.c b/libnfsidmap.c index 833f94c..a8a9229 100644 --- a/libnfsidmap.c +++ b/libnfsidmap.c @@ -100,8 +100,11 @@ static char * toupper_str(char *s) static int id_as_chars(char *name, uid_t *id) { - long int value = strtol(name, NULL, 10); + long int value; + if (name == NULL) + return 0; + value = strtol(name, NULL, 10); if (value == 0) { /* zero value ids are valid */ if (strcmp(name, "0") != 0) diff --git a/nss.c b/nss.c index f8129fe..b3fef5a 100644 --- a/nss.c +++ b/nss.c @@ -135,6 +135,9 @@ static char *strip_domain(const char *name, const char *domain) char *l = NULL; int len; + if (name == NULL) + goto out; + c = strrchr(name, '@'); if (c == NULL && domain != NULL) goto out;