From patchwork Thu Feb 9 23:04:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Sorenson X-Patchwork-Id: 9565651 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 23C9D6020C for ; Thu, 9 Feb 2017 23:13:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16BEC2855A for ; Thu, 9 Feb 2017 23:13:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B6D52855E; Thu, 9 Feb 2017 23:13:59 +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.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 9DC002855A for ; Thu, 9 Feb 2017 23:13:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751566AbdBIXN5 (ORCPT ); Thu, 9 Feb 2017 18:13:57 -0500 Received: from mail-qk0-f177.google.com ([209.85.220.177]:36254 "EHLO mail-qk0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751305AbdBIXN4 (ORCPT ); Thu, 9 Feb 2017 18:13:56 -0500 Received: by mail-qk0-f177.google.com with SMTP id 11so21581785qkl.3 for ; Thu, 09 Feb 2017 15:13:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=ZNmgB3qAUjekEO/DyEU2jZKRCo/pLuvLsRCDVytn17k=; b=dcnoijKmbJRGYC7i+GKVsVrDN4/rKg6bsPzb9QjRc6Am5vjNn2nI07U5tPVMpUYywp JMuzmZbue9FM+xXAuqG4AQJRRg2SW7Hb0BVCgXtr+EZ3sYxEIk60CQJrTodpXnSAVyKu bIRDXcw2TF3ds78SA6BqUTrEPTAXQW6YF+djnCi5LyGxx4ow17wdKA4uEfWQO67+x6MO 3yPInw4/LN0TCLP/5oMLg3qy7XMQ35ukPdeb+raQIgpnCD/5iumRPRBEdjj0CVkSA02P GZknc8p2q4Vk75dgeEdnX9Y6+U4XdT3W2VWSyjuPeDVkwWLhPNAXJHOKVbaTmGSV0nfa NP2g== X-Gm-Message-State: AMke39niZpMv92HVsuDubtLeXkktW0F5aFD0SWK8/dv1QDPU/Vk26dLAUIrUUj1gEP1oGqpo X-Received: by 10.55.18.76 with SMTP id c73mr5446719qkh.119.1486681441788; Thu, 09 Feb 2017 15:04:01 -0800 (PST) Received: from hut.sorenson.redhat.com (198-0-247-150-static.hfc.comcastbusiness.net. [198.0.247.150]) by smtp.gmail.com with ESMTPSA id m85sm10416047qkl.28.2017.02.09.15.04.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Feb 2017 15:04:01 -0800 (PST) To: linux-nfs@vger.kernel.org From: Frank Sorenson Subject: [nfs-utils PATCH V2 2/2] Duplicate upcall string for use in error messages Message-ID: <778cd9e3-7b3a-654d-5fdd-bc0f63743041@redhat.com> Date: Thu, 9 Feb 2017 17:04:00 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 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 Author: Frank Sorenson Date: 2017-02-09 16:51:44 -0600 gssd: Duplicate the upcall string for error messages strsep() modifies the input string, so error messages may output only part of the upcall string. Make a copy of the upcall string, and use that in any error messages. Signed-off-by: Frank Sorenson --- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c index 30c6ace..4fc81c3 100644 --- a/utils/gssd/gssd_proc.c +++ b/utils/gssd/gssd_proc.c @@ -729,10 +729,17 @@ handle_gssd_upcall(struct clnt_upcall_info *info) char *target = NULL; char *service = NULL; char *enctypes = NULL; + char *upcall_str; char *pbuf = info->lbuf; printerr(2, "\n%s: '%s' (%s)\n", __func__, info->lbuf, clp->relpath); + upcall_str = strdup(info->lbuf); + if (upcall_str == NULL) { + printerr(0, "ERROR: malloc failure\n"); + goto out_nomem; + } + while ((p = strsep(&pbuf, " "))) { if (!strncmp(p, "mech=", strlen("mech="))) mech = p + strlen("mech="); @@ -749,7 +756,7 @@ handle_gssd_upcall(struct clnt_upcall_info *info) if (!mech || strlen(mech) < 1) { printerr(0, "WARNING: handle_gssd_upcall: " "failed to find gss mechanism name " - "in upcall string '%s'\n", info->lbuf); + "in upcall string '%s'\n", upcall_str); goto out; } @@ -762,7 +769,7 @@ handle_gssd_upcall(struct clnt_upcall_info *info) if (!uidstr) { printerr(0, "WARNING: handle_gssd_upcall: " "failed to find uid " - "in upcall string '%s'\n", info->lbuf); + "in upcall string '%s'\n", upcall_str); goto out; } @@ -775,7 +782,7 @@ handle_gssd_upcall(struct clnt_upcall_info *info) if (target && strlen(target) < 1) { printerr(0, "WARNING: handle_gssd_upcall: " "failed to parse target name " - "in upcall string '%s'\n", info->lbuf); + "in upcall string '%s'\n", upcall_str); goto out; } @@ -790,7 +797,7 @@ handle_gssd_upcall(struct clnt_upcall_info *info) if (service && strlen(service) < 1) { printerr(0, "WARNING: handle_gssd_upcall: " "failed to parse service type " - "in upcall string '%s'\n", info->lbuf); + "in upcall string '%s'\n", upcall_str); goto out; } @@ -803,6 +810,8 @@ handle_gssd_upcall(struct clnt_upcall_info *info) do_error_downcall(clp->gssd_fd, uid, -EACCES); } out: + free(upcall_str); +out_nomem: free(info); return; }