Skip to content

Commit ee13b2b

Browse files
jtlaytonsmfrench
authored andcommitted
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>
1 parent 30c9d6c commit ee13b2b

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

‎fs/cifs/cifsacl.c‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,27 +199,24 @@ static void
199199
sid_to_str(struct cifs_sid *sidptr, char *sidstr)
200200
{
201201
int i;
202-
unsigned long saval;
202+
unsigned int saval;
203203
char *strptr;
204204

205205
strptr = sidstr;
206206

207-
sprintf(strptr, "%s", "S");
208-
strptr = sidstr + strlen(sidstr);
209-
210-
sprintf(strptr, "-%d", sidptr->revision);
207+
sprintf(strptr, "S-%hhu", sidptr->revision);
211208
strptr = sidstr + strlen(sidstr);
212209

213210
for (i = 0; i < NUM_AUTHS; ++i) {
214211
if (sidptr->authority[i]) {
215-
sprintf(strptr, "-%d", sidptr->authority[i]);
212+
sprintf(strptr, "-%hhu", sidptr->authority[i]);
216213
strptr = sidstr + strlen(sidstr);
217214
}
218215
}
219216

220217
for (i = 0; i < sidptr->num_subauth; ++i) {
221218
saval = le32_to_cpu(sidptr->sub_auth[i]);
222-
sprintf(strptr, "-%ld", saval);
219+
sprintf(strptr, "-%u", saval);
223220
strptr = sidstr + strlen(sidstr);
224221
}
225222
}

0 commit comments

Comments
 (0)