From patchwork Wed Aug 17 17:50:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Dickson X-Patchwork-Id: 9286297 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D2D0F60459 for ; Wed, 17 Aug 2016 17:57:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB7E82974B for ; Wed, 17 Aug 2016 17:57:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C048029753; Wed, 17 Aug 2016 17:57:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62D462974B for ; Wed, 17 Aug 2016 17:57:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752774AbcHQR5J (ORCPT ); Wed, 17 Aug 2016 13:57:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37560 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752435AbcHQR5J (ORCPT ); Wed, 17 Aug 2016 13:57:09 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 65E0381243 for ; Wed, 17 Aug 2016 17:50:32 +0000 (UTC) Received: from steved.boston.devel.redhat.com (vpn-57-39.rdu2.redhat.com [10.10.57.39]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u7HHoVBG026611 for ; Wed, 17 Aug 2016 13:50:32 -0400 From: Steve Dickson To: Linux NFS Mailing list Subject: [PATCH] nss_getpwnam: correctly check for negative values in unsigned ints. Date: Wed, 17 Aug 2016 13:50:30 -0400 Message-Id: <1471456230-10624-1-git-send-email-steved@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 17 Aug 2016 17:50:32 +0000 (UTC) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP commit e22368f6 introduce a couple checks for negative buffer lengths. The variables are unsigned ints so UINT_MAX should be used. Signed-off-by: Steve Dickson --- nss.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nss.c b/nss.c index 8e9412d..47c6b14 100644 --- a/nss.c +++ b/nss.c @@ -44,6 +44,7 @@ #include #include #include +#include #include "nfsidmap.h" #include "nfsidmap_internal.h" #include "cfg.h" @@ -171,7 +172,7 @@ static struct passwd *nss_getpwnam(const char *name, const char *domain, int *er char *localname; int err = ENOMEM; - if (buflen < 0) + if (buflen > UINT_MAX) goto err; buf = malloc(sizeof(*buf) + buflen); @@ -240,7 +241,7 @@ static int nss_name_to_gid(char *name, gid_t *gid) goto out; err = -ENOMEM; - if (buflen < 0) + if (buflen > UINT_MAX) goto out; do {