From patchwork Wed Oct 17 18:08:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1607431 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 629DBDFABE for ; Wed, 17 Oct 2012 18:09:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755212Ab2JQSJO (ORCPT ); Wed, 17 Oct 2012 14:09:14 -0400 Received: from mail-gh0-f174.google.com ([209.85.160.174]:59459 "EHLO mail-gh0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756405Ab2JQSJN (ORCPT ); Wed, 17 Oct 2012 14:09:13 -0400 Received: by mail-gh0-f174.google.com with SMTP id g15so2209630ghb.19 for ; Wed, 17 Oct 2012 11:09:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=Gcg5NHvR7RB8RBnnX6SYNVqQ3NGFGfBHQPEa12YY8YI=; b=Aa109606LrECnTsK2/47+Q4lnioNkhspVt3pa7m6Q8A2Zgml1SPMP7KvEiByfyA5lk kJfrEPkGRmx7FH8VmsvAUcQOWn2daSQdTVZpdKWQEDOhhTRHLZi1GzoW5YXtDrP/uov6 SUykZloSvHbBYbw03NMttZjFgW33wmgjDWpSN3wE17d2OXqy1SYGNzoIXLiF8cq/pSFm P+KSMXGxXuQxFyY9uOXHFGomWmxLqOo6kOdE2P8ZMUUGEpFhGv37/PCn19zWopOXJBpu Mjy1A6QTgjiBOcHDe32G/olN/Y/VcuiFcJTKXtWLhZ3UlSWAL2i5EMPMAkSWp7EDcSCw SK1Q== Received: by 10.236.83.230 with SMTP id q66mr18281153yhe.118.1350497353220; Wed, 17 Oct 2012 11:09:13 -0700 (PDT) Received: from salusa.poochiereds.net (cpe-107-015-110-129.nc.res.rr.com. [107.15.110.129]) by mx.google.com with ESMTPS id k63sm9397062yhj.20.2012.10.17.11.09.11 (version=SSLv3 cipher=OTHER); Wed, 17 Oct 2012 11:09:12 -0700 (PDT) From: Jeff Layton To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, shirishpargaonkar@gmail.com Subject: [PATCH 3/7] cifs: fix the format specifiers in sid_to_str Date: Wed, 17 Oct 2012 14:08:59 -0400 Message-Id: <1350497343-7155-4-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1350497343-7155-1-git-send-email-jlayton@redhat.com> References: <1350497343-7155-1-git-send-email-jlayton@redhat.com> X-Gm-Message-State: ALoCoQnqVeb4dgXNViUFitHpMQFba9EQ34d8Y/vo05YUayQGM2/0SAU1/TaQxCPUPklG0BW81d/x Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org The format specifiers are for signed values, but these are unsigned. Given that '-' is a delimiter between fields, I don't think you'd get what you'd expect if you got a value here that would overflow the sign bit. The version and authority fields are 8 bit values so use a "hh" length modifier there. The subauths are 32 bit values, so there's no need to use a "l" length modifier there. Signed-off-by: Jeff Layton --- fs/cifs/cifsacl.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index dd8d3df..9adcdb5 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c @@ -199,27 +199,24 @@ static void sid_to_str(struct cifs_sid *sidptr, char *sidstr) { int i; - unsigned long saval; + unsigned int saval; char *strptr; strptr = sidstr; - sprintf(strptr, "%s", "S"); - strptr = sidstr + strlen(sidstr); - - sprintf(strptr, "-%d", sidptr->revision); + sprintf(strptr, "S-%hhu", sidptr->revision); strptr = sidstr + strlen(sidstr); for (i = 0; i < NUM_AUTHS; ++i) { if (sidptr->authority[i]) { - sprintf(strptr, "-%d", sidptr->authority[i]); + sprintf(strptr, "-%hhu", sidptr->authority[i]); strptr = sidstr + strlen(sidstr); } } for (i = 0; i < sidptr->num_subauth; ++i) { saval = le32_to_cpu(sidptr->sub_auth[i]); - sprintf(strptr, "-%ld", saval); + sprintf(strptr, "-%u", saval); strptr = sidstr + strlen(sidstr); } }