From 63f86cb56c83610c2294a1d98658923bca18c4b7 Mon Sep 17 00:00:00 2001 From: Vadim Zhukov Date: Fri, 17 May 2013 12:38:30 +0400 Subject: [PATCH] Fix potential overflow problems when formatting some types Some system "pseudo" types, like time_t, are mapped to different "real" types on different platforms. Even more, those "real" types could have different size, too. For example, "long" is 64-bit on Linux/x86-64 but 32-bit on OpenBSD/amd64. So a few formatting nits are seen only on some platforms. Thanks to strict compilation rules of Samba4, those were noted on OpenBSD during compilation. BUG: https://bugzilla.samba.org/show_bug.cgi?id=9889 --- examples/libsmbclient/teststat.c | 16 ++++++++-------- examples/libsmbclient/teststat2.c | 16 ++++++++-------- examples/libsmbclient/testutime.c | 16 ++++++++-------- source3/lib/sysquotas_nfs.c | 4 ++-- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/examples/libsmbclient/teststat.c b/examples/libsmbclient/teststat.c index f36639e..f95468e 100644 --- a/examples/libsmbclient/teststat.c +++ b/examples/libsmbclient/teststat.c @@ -47,10 +47,10 @@ int main(int argc, char * argv[]) return 1; } - printf("\nSAMBA\n mtime:%lu/%s ctime:%lu/%s atime:%lu/%s\n", - st.st_mtime, ctime_r(&st.st_mtime, m_time), - st.st_ctime, ctime_r(&st.st_ctime, c_time), - st.st_atime, ctime_r(&st.st_atime, a_time)); + printf("\nSAMBA\n mtime:%lld/%s ctime:%lld/%s atime:%llu/%s\n", + (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time), + (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time), + (long long)st.st_atime, ctime_r(&st.st_atime, a_time)); if (pLocalPath != NULL) { @@ -60,10 +60,10 @@ int main(int argc, char * argv[]) return 1; } - printf("LOCAL\n mtime:%lu/%s ctime:%lu/%s atime:%lu/%s\n", - st.st_mtime, ctime_r(&st.st_mtime, m_time), - st.st_ctime, ctime_r(&st.st_ctime, c_time), - st.st_atime, ctime_r(&st.st_atime, a_time)); + printf("LOCAL\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n", + (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time), + (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time), + (long long)st.st_atime, ctime_r(&st.st_atime, a_time)); } return 0; diff --git a/examples/libsmbclient/teststat2.c b/examples/libsmbclient/teststat2.c index fcd3e30..883052f 100644 --- a/examples/libsmbclient/teststat2.c +++ b/examples/libsmbclient/teststat2.c @@ -47,10 +47,10 @@ static int gettime(const char * pUrl, return 1; } - printf("SAMBA\n mtime:%lu/%s ctime:%lu/%s atime:%lu/%s\n", - st.st_mtime, ctime_r(&st.st_mtime, m_time), - st.st_ctime, ctime_r(&st.st_ctime, c_time), - st.st_atime, ctime_r(&st.st_atime, a_time)); + printf("SAMBA\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n", + (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time), + (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time), + (long long)st.st_atime, ctime_r(&st.st_atime, a_time)); /* check the stat on this file */ @@ -60,10 +60,10 @@ static int gettime(const char * pUrl, return 1; } - printf("LOCAL\n mtime:%lu/%s ctime:%lu/%s atime:%lu/%s\n", - st.st_mtime, ctime_r(&st.st_mtime, m_time), - st.st_ctime, ctime_r(&st.st_ctime, c_time), - st.st_atime, ctime_r(&st.st_atime, a_time)); + printf("LOCAL\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n", + (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time), + (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time), + (long long)st.st_atime, ctime_r(&st.st_atime, a_time)); return 0; diff --git a/examples/libsmbclient/testutime.c b/examples/libsmbclient/testutime.c index 2b3c40b..7077d20 100644 --- a/examples/libsmbclient/testutime.c +++ b/examples/libsmbclient/testutime.c @@ -47,10 +47,10 @@ int main(int argc, char * argv[]) return 1; } - printf("Before\n mtime:%lu/%s ctime:%lu/%s atime:%lu/%s\n", - st.st_mtime, ctime_r(&st.st_mtime, m_time), - st.st_ctime, ctime_r(&st.st_ctime, c_time), - st.st_atime, ctime_r(&st.st_atime, a_time)); + printf("Before\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n", + (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time), + (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time), + (long long)st.st_atime, ctime_r(&st.st_atime, a_time)); utimbuf.actime = t; /* unchangable (wont change) */ utimbuf.modtime = t; /* this one should succeed */ @@ -66,10 +66,10 @@ int main(int argc, char * argv[]) return 1; } - printf("After\n mtime:%lu/%s ctime:%lu/%s atime:%lu/%s\n", - st.st_mtime, ctime_r(&st.st_mtime, m_time), - st.st_ctime, ctime_r(&st.st_ctime, c_time), - st.st_atime, ctime_r(&st.st_atime, a_time)); + printf("After\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n", + (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time), + (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time), + (long long)st.st_atime, ctime_r(&st.st_atime, a_time)); return 0; } diff --git a/source3/lib/sysquotas_nfs.c b/source3/lib/sysquotas_nfs.c index 63f114b..5c1f7dc 100644 --- a/source3/lib/sysquotas_nfs.c +++ b/source3/lib/sysquotas_nfs.c @@ -154,8 +154,8 @@ int sys_get_nfs_quota(const char *path, const char *bdev, gq_args.gqa_uid = id.uid; DEBUG(10, ("sys_get_nfs_quotas: Asking for quota of path '%s' on " - "host '%s', rpcprog '%i', rpcvers '%i', network '%s'\n", - host, testpath+1, RQUOTAPROG, RQUOTAVERS, "udp")); + "host '%s', rpcprog '%lld', rpcvers '%lld', network '%s'\n", + host, testpath+1, (long long)RQUOTAPROG, (long long)RQUOTAVERS, "udp")); clnt = clnt_create(host, RQUOTAPROG, RQUOTAVERS, "udp"); if (clnt == NULL) { -- 1.8.2.2