From patchwork Fri Oct 19 12:20:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1618241 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 09C323FC1A for ; Fri, 19 Oct 2012 12:21:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757457Ab2JSMVA (ORCPT ); Fri, 19 Oct 2012 08:21:00 -0400 Received: from mail-yh0-f46.google.com ([209.85.213.46]:60915 "EHLO mail-yh0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754045Ab2JSMVA (ORCPT ); Fri, 19 Oct 2012 08:21:00 -0400 Received: by mail-yh0-f46.google.com with SMTP id m54so44174yhm.19 for ; Fri, 19 Oct 2012 05:20:59 -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=biDwWU7mWJQcN3fKfldTtLlP746h0PZsszxdhgZdn5r+glcP18VqP90C0ubqdWgoqK UNtus+BwPc7TqXDkvuJGUYkfMB1IJ3TyJd0hgcPEVUeDE5PWYfG00TzCxLbjxzvjj8Oi /3foJqXxGgzmfrhyAkx99lQZajyOqGYUXOzjHGmbU+D1ST61sNck7R5UROukkgizYiVq ZpfZpPIQj5eIB1j57utkzJH+iVKsChLhWXiul8zs2fp47fyPsqpljIdsMMM6TcpZHtz5 kqlaq5V2x8wouyBMGoHUHPur+6PfbgjiyXok6MBUHKFxyDcgIN+zTyk/pqJcVCJiU476 FL/A== Received: by 10.236.124.231 with SMTP id x67mr894165yhh.41.1350649259815; Fri, 19 Oct 2012 05:20:59 -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 o9sm504022anp.14.2012.10.19.05.20.58 (version=SSLv3 cipher=OTHER); Fri, 19 Oct 2012 05:20:59 -0700 (PDT) From: Jeff Layton To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org Subject: [PATCH v2 3/9] cifs: fix the format specifiers in sid_to_str Date: Fri, 19 Oct 2012 08:20:44 -0400 Message-Id: <1350649250-5343-4-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1350649250-5343-1-git-send-email-jlayton@redhat.com> References: <1350649250-5343-1-git-send-email-jlayton@redhat.com> X-Gm-Message-State: ALoCoQkcccNKrSjlXG6YQM7VUqRz40RgZITT3nX9124dwT2Q6lhJwzcRiJm6O93tjtaaeHCkBOMe 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); } }