diff options
author | Jeff Layton <jlayton@redhat.com> | 2012-11-25 08:00:38 -0500 |
---|---|---|
committer | Steve French <smfrench@gmail.com> | 2012-12-05 14:13:11 -0500 |
commit | ee13b2ba7488475b47ae8dab2eebc4f5fd6838c5 (patch) | |
tree | b31668b5c4864ad620496b098efc61f407328e2f /fs/cifs | |
parent | 30c9d6cca526243abe6c08eb6fa03db9d2b1a630 (diff) |
cifs: fix the format specifiers in sid_to_str
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.
Reviewed-by: Shirish Pargaonkar <shirishpargaonkar@gmail.com>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <smfrench@gmail.com>
Diffstat (limited to 'fs/cifs')
-rw-r--r-- | fs/cifs/cifsacl.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index dd8d3df74298..9adcdb5a1001 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c | |||
@@ -199,27 +199,24 @@ static void | |||
199 | sid_to_str(struct cifs_sid *sidptr, char *sidstr) | 199 | sid_to_str(struct cifs_sid *sidptr, char *sidstr) |
200 | { | 200 | { |
201 | int i; | 201 | int i; |
202 | unsigned long saval; | 202 | unsigned int saval; |
203 | char *strptr; | 203 | char *strptr; |
204 | 204 | ||
205 | strptr = sidstr; | 205 | strptr = sidstr; |
206 | 206 | ||
207 | sprintf(strptr, "%s", "S"); | 207 | sprintf(strptr, "S-%hhu", sidptr->revision); |
208 | strptr = sidstr + strlen(sidstr); | ||
209 | |||
210 | sprintf(strptr, "-%d", sidptr->revision); | ||
211 | strptr = sidstr + strlen(sidstr); | 208 | strptr = sidstr + strlen(sidstr); |
212 | 209 | ||
213 | for (i = 0; i < NUM_AUTHS; ++i) { | 210 | for (i = 0; i < NUM_AUTHS; ++i) { |
214 | if (sidptr->authority[i]) { | 211 | if (sidptr->authority[i]) { |
215 | sprintf(strptr, "-%d", sidptr->authority[i]); | 212 | sprintf(strptr, "-%hhu", sidptr->authority[i]); |
216 | strptr = sidstr + strlen(sidstr); | 213 | strptr = sidstr + strlen(sidstr); |
217 | } | 214 | } |
218 | } | 215 | } |
219 | 216 | ||
220 | for (i = 0; i < sidptr->num_subauth; ++i) { | 217 | for (i = 0; i < sidptr->num_subauth; ++i) { |
221 | saval = le32_to_cpu(sidptr->sub_auth[i]); | 218 | saval = le32_to_cpu(sidptr->sub_auth[i]); |
222 | sprintf(strptr, "-%ld", saval); | 219 | sprintf(strptr, "-%u", saval); |
223 | strptr = sidstr + strlen(sidstr); | 220 | strptr = sidstr + strlen(sidstr); |
224 | } | 221 | } |
225 | } | 222 | } |