Commit ee13b2ba authored by Jeff Layton's avatar Jeff Layton Committed by Steve French

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: default avatarShirish Pargaonkar <shirishpargaonkar@gmail.com>
Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarSteve French <smfrench@gmail.com>
parent 30c9d6cc
...@@ -199,27 +199,24 @@ static void ...@@ -199,27 +199,24 @@ static void
sid_to_str(struct cifs_sid *sidptr, char *sidstr) sid_to_str(struct cifs_sid *sidptr, char *sidstr)
{ {
int i; int i;
unsigned long saval; unsigned int saval;
char *strptr; char *strptr;
strptr = sidstr; strptr = sidstr;
sprintf(strptr, "%s", "S"); sprintf(strptr, "S-%hhu", sidptr->revision);
strptr = sidstr + strlen(sidstr);
sprintf(strptr, "-%d", sidptr->revision);
strptr = sidstr + strlen(sidstr); strptr = sidstr + strlen(sidstr);
for (i = 0; i < NUM_AUTHS; ++i) { for (i = 0; i < NUM_AUTHS; ++i) {
if (sidptr->authority[i]) { if (sidptr->authority[i]) {
sprintf(strptr, "-%d", sidptr->authority[i]); sprintf(strptr, "-%hhu", sidptr->authority[i]);
strptr = sidstr + strlen(sidstr); strptr = sidstr + strlen(sidstr);
} }
} }
for (i = 0; i < sidptr->num_subauth; ++i) { for (i = 0; i < sidptr->num_subauth; ++i) {
saval = le32_to_cpu(sidptr->sub_auth[i]); saval = le32_to_cpu(sidptr->sub_auth[i]);
sprintf(strptr, "-%ld", saval); sprintf(strptr, "-%u", saval);
strptr = sidstr + strlen(sidstr); strptr = sidstr + strlen(sidstr);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment