Skip to content

Commit

Permalink
cifs: fix the format specifiers in sid_to_str
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeff Layton authored and Steve French committed Dec 5, 2012
1 parent 30c9d6c commit ee13b2b
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions fs/cifs/cifsacl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit ee13b2b

Please sign in to comment.