summaryrefslogtreecommitdiffstats
path: root/libcli
diff options
context:
space:
mode:
authorJeff Layton <jlayton@samba.org>2013-07-31 10:38:21 -0400
committerJeremy Allison <jra@samba.org>2013-07-31 15:16:11 -0700
commitedd3302ad46fd70a8e5472f32f41aa4d8305f4e5 (patch)
treee7f5221c98ecab6490cdce4774549439ae206dff /libcli
parent34d3639305bed5fd202114044fc76e53980dfee4 (diff)
downloadsamba-edd3302ad46fd70a8e5472f32f41aa4d8305f4e5.tar.gz
samba-edd3302ad46fd70a8e5472f32f41aa4d8305f4e5.tar.xz
samba-edd3302ad46fd70a8e5472f32f41aa4d8305f4e5.zip
libcli: fix conversion logic in dom_sid_string_buf
Signed-off-by: Jeff Layton <jlayton@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'libcli')
-rw-r--r--libcli/security/dom_sid.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/libcli/security/dom_sid.c b/libcli/security/dom_sid.c
index 5905e365bd..90f54018d9 100644
--- a/libcli/security/dom_sid.c
+++ b/libcli/security/dom_sid.c
@@ -365,23 +365,31 @@ bool dom_sid_in_domain(const struct dom_sid *domain_sid,
int dom_sid_string_buf(const struct dom_sid *sid, char *buf, int buflen)
{
int i, ofs;
- uint32_t ia;
+ uint64_t ia;
if (!sid) {
return strlcpy(buf, "(NULL SID)", buflen);
}
- ia = (sid->id_auth[5]) +
- (sid->id_auth[4] << 8 ) +
- (sid->id_auth[3] << 16) +
- (sid->id_auth[2] << 24);
-
- ofs = snprintf(buf, buflen, "S-%u-%lu",
- (unsigned int)sid->sid_rev_num, (unsigned long)ia);
+ ia = ((uint64_t)sid->id_auth[5]) +
+ ((uint64_t)sid->id_auth[4] << 8 ) +
+ ((uint64_t)sid->id_auth[3] << 16) +
+ ((uint64_t)sid->id_auth[2] << 24) +
+ ((uint64_t)sid->id_auth[1] << 32) +
+ ((uint64_t)sid->id_auth[0] << 40);
+
+ ofs = snprintf(buf, buflen, "S-%hhu-", (unsigned char)sid->sid_rev_num);
+ if (ia >= UINT32_MAX) {
+ ofs += snprintf(buf + ofs, MAX(buflen - ofs, 0), "0x%llx",
+ (unsigned long long)ia);
+ } else {
+ ofs += snprintf(buf + ofs, MAX(buflen - ofs, 0), "%llu",
+ (unsigned long long)ia);
+ }
for (i = 0; i < sid->num_auths; i++) {
- ofs += snprintf(buf + ofs, MAX(buflen - ofs, 0), "-%lu",
- (unsigned long)sid->sub_auths[i]);
+ ofs += snprintf(buf + ofs, MAX(buflen - ofs, 0), "-%u",
+ (unsigned int)sid->sub_auths[i]);
}
return ofs;
}