From patchwork Tue Jan 29 12:17:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 2061281 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id C9BAD3FCD5 for ; Tue, 29 Jan 2013 12:17:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752391Ab3A2MRg (ORCPT ); Tue, 29 Jan 2013 07:17:36 -0500 Received: from mail-ye0-f169.google.com ([209.85.213.169]:65186 "EHLO mail-ye0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751624Ab3A2MRf (ORCPT ); Tue, 29 Jan 2013 07:17:35 -0500 Received: by mail-ye0-f169.google.com with SMTP id l13so31906yen.14 for ; Tue, 29 Jan 2013 04:17:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=RY6Ey12PoUrrInnDA7bdXkF8NegmfvjW5maDAtPLv4k=; b=LDqRu9hnWtwbBruNqDHn2UF9trLQOYZ+BTsqxpCV1gnhVS86wPiMcHo5gKTScAxMW0 n1tJtjQV1YSrTW0xbcjgBtKvM/51HfvvGpT5zsi1BrY1h46fbTwc+mwRDCAdQlclNwSE AiehSmtERnW17cVjH0VW+k1ijYspcDtSTu/mH/A8UYXd2V6eTnhRIk/gqcfo2PEKbzLd uB4MEt88KkAFiPPfSR94+i5B+EPoYgOEcoHDBclkltoXCN5ecflRqEQ/IL7P9wNUDqOq karurtadtLR8d0jACZ/vrKLSeJ6Fjk3M6w0WnZqvDvsTlVOgXZB+alG9a47meNrDmehX D+DQ== X-Received: by 10.236.130.235 with SMTP id k71mr757681yhi.57.1359461855329; Tue, 29 Jan 2013 04:17:35 -0800 (PST) Received: from salusa.poochiereds.net (cpe-107-015-113-143.nc.res.rr.com. [107.15.113.143]) by mx.google.com with ESMTPS id d30sm13245319yhc.4.2013.01.29.04.17.33 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 29 Jan 2013 04:17:34 -0800 (PST) From: Jeff Layton To: linux-cifs@vger.kernel.org Cc: jiali@redhat.com Subject: [PATCH] setcifsacl: fix infinite loop in getnumcaces Date: Tue, 29 Jan 2013 07:17:29 -0500 Message-Id: <1359461849-9164-1-git-send-email-jlayton@samba.org> X-Mailer: git-send-email 1.7.11.7 X-Gm-Message-State: ALoCoQnKfQ/X+j+Mdisf91/ulYHqfYgZfoLrYUUOLJEZ+jbeabjtEuQFzkfrTlaVSliSdvs7WHbZ Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org Jian pointed out that this loop can cycle infinitely when the string contains a ','. Also, fix typo in manpage that shows a trailing ',' in one example. Reported-by: Jian Li Signed-off-by: Jeff Layton --- setcifsacl.1.in | 2 +- setcifsacl.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/setcifsacl.1.in b/setcifsacl.1.in index 5ede36a..d53a6ec 100644 --- a/setcifsacl.1.in +++ b/setcifsacl.1.in @@ -94,7 +94,7 @@ Set an ACL .br setcifsacl -S "ACL:CIFSTESTDOM\\Administrator:0x0/0x0/FULL, .br -ACL:CIFSTESTDOM\\user2:0x0/0x0/FULL," +ACL:CIFSTESTDOM\\user2:0x0/0x0/FULL" .PP .SH "NOTES" .PP diff --git a/setcifsacl.c b/setcifsacl.c index 211c1af..7f92b91 100644 --- a/setcifsacl.c +++ b/setcifsacl.c @@ -642,8 +642,10 @@ get_numcaces(const char *aces) const char *current; current = aces; - while((current = strchr(current, ','))) + while((current = strchr(current, ','))) { + ++current; ++num; + } return num; }