[PATCHSET] Fix and add -Werror=strict-overflow -Wstrict-overflow=2
Andreas Schneider
asn at samba.org
Thu Dec 7 19:37:15 UTC 2017
Hello,
I've worked on a patchset to turn on:
-Werror=strict-overflow -Wstrict-overflow=2
The attached patchset fixes all the issues found with the compiler warning
turned on. The first part is pretty obvious int -> size_t but then there are
were some harder nuts to crack. I hope I got all right but a careful review
would be great!
I'm also fine opening a bug and backport them if someones thinks it is worth
to have it in 4.7.
Review much appreciated.
Thanks,
Andreas
--
Andreas Schneider GPG-ID: CC014E3D
Samba Team asn at samba.org
www.samba.org
-------------- next part --------------
>From 1531b06d9cddd3f53e315a9cd55905c9690269b6 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 20:26:40 +0100
Subject: [PATCH 01/42] heimdal: Fix size types
This fixes compilation with -Wstrict-overflow=2
Upstream pull request:
https://github.com/heimdal/heimdal/pull/354
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source4/heimdal/lib/asn1/gen.c | 4 ++--
source4/heimdal/lib/hx509/cert.c | 3 ++-
source4/heimdal/lib/krb5/config_file.c | 2 +-
source4/heimdal/lib/krb5/keytab_any.c | 2 +-
source4/heimdal/lib/roken/resolve.c | 2 +-
5 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/source4/heimdal/lib/asn1/gen.c b/source4/heimdal/lib/asn1/gen.c
index fd833dbd76f..919a7076ac1 100644
--- a/source4/heimdal/lib/asn1/gen.c
+++ b/source4/heimdal/lib/asn1/gen.c
@@ -502,7 +502,7 @@ is_primitive_type(int type)
}
static void
-space(int level)
+space(size_t level)
{
while(level-- > 0)
fprintf(headerfile, " ");
@@ -531,7 +531,7 @@ have_ellipsis(Type *t)
}
static void
-define_asn1 (int level, Type *t)
+define_asn1 (size_t level, Type *t)
{
switch (t->type) {
case TType:
diff --git a/source4/heimdal/lib/hx509/cert.c b/source4/heimdal/lib/hx509/cert.c
index 329fc179cb5..190bdb48a4f 100644
--- a/source4/heimdal/lib/hx509/cert.c
+++ b/source4/heimdal/lib/hx509/cert.c
@@ -1977,7 +1977,8 @@ hx509_verify_path(hx509_context context,
{
hx509_name_constraints nc;
hx509_path path;
- int ret, proxy_cert_depth, selfsigned_depth, diff;
+ int ret, diff;
+ size_t proxy_cert_depth, selfsigned_depth;
size_t i, k;
enum certtype type;
Name proxy_issuer;
diff --git a/source4/heimdal/lib/krb5/config_file.c b/source4/heimdal/lib/krb5/config_file.c
index 4ac25ae2870..2748f481d66 100644
--- a/source4/heimdal/lib/krb5/config_file.c
+++ b/source4/heimdal/lib/krb5/config_file.c
@@ -925,7 +925,7 @@ krb5_config_vget_strings(krb5_context context,
va_list args)
{
char **strings = NULL;
- int nstr = 0;
+ size_t nstr = 0;
const krb5_config_binding *b = NULL;
const char *p;
diff --git a/source4/heimdal/lib/krb5/keytab_any.c b/source4/heimdal/lib/krb5/keytab_any.c
index d5ac4883db1..568af0ac69e 100644
--- a/source4/heimdal/lib/krb5/keytab_any.c
+++ b/source4/heimdal/lib/krb5/keytab_any.c
@@ -225,7 +225,7 @@ any_remove_entry(krb5_context context,
{
struct any_data *a = id->data;
krb5_error_code ret;
- int found = 0;
+ size_t found = 0;
while(a != NULL) {
ret = krb5_kt_remove_entry(context, a->kt, entry);
if(ret == 0)
diff --git a/source4/heimdal/lib/roken/resolve.c b/source4/heimdal/lib/roken/resolve.c
index 0cfe0b0472a..b719aebaf0d 100644
--- a/source4/heimdal/lib/roken/resolve.c
+++ b/source4/heimdal/lib/roken/resolve.c
@@ -626,7 +626,7 @@ rk_dns_srv_order(struct rk_dns_reply *r)
{
struct rk_resource_record **srvs, **ss, **headp;
struct rk_resource_record *rr;
- int num_srv = 0;
+ size_t num_srv = 0;
#if defined(HAVE_INITSTATE) && defined(HAVE_SETSTATE)
int state[256 / sizeof(int)];
--
2.15.1
>From 1acfcbfdc2c93f5b7754a403a4f1a770c6ba76b2 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 17:35:11 +0100
Subject: [PATCH 02/42] s4:ntvfs: Fix size type in pvfs functions
This fixes compilation with -Wstrict-overflow=2.
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source4/ntvfs/posix/pvfs_resolve.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/source4/ntvfs/posix/pvfs_resolve.c b/source4/ntvfs/posix/pvfs_resolve.c
index 12fc0c1110b..cc3d72c2ed6 100644
--- a/source4/ntvfs/posix/pvfs_resolve.c
+++ b/source4/ntvfs/posix/pvfs_resolve.c
@@ -62,10 +62,10 @@ static NTSTATUS pvfs_case_search(struct pvfs_state *pvfs,
unsigned int flags)
{
/* break into a series of components */
- int num_components;
+ size_t num_components;
char **components;
char *p, *partial_name;
- int i;
+ size_t i;
/* break up the full name info pathname components */
num_components=2;
@@ -389,7 +389,7 @@ static NTSTATUS pvfs_reduce_name(TALLOC_CTX *mem_ctx,
{
codepoint_t c;
size_t c_size, len;
- int i, num_components, err_count;
+ size_t i, num_components, err_count;
char **components;
char *p, *s, *ret;
@@ -432,7 +432,7 @@ static NTSTATUS pvfs_reduce_name(TALLOC_CTX *mem_ctx,
err_count++;
}
}
- if (err_count) {
+ if (err_count > 0) {
if (flags & PVFS_RESOLVE_WILDCARD) err_count--;
if (err_count==1) {
--
2.15.1
>From 9dccfd1c0c99584bd1665cc897b8a05d1f1f27ce Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 17:38:21 +0100
Subject: [PATCH 03/42] s3:libads: Fix size types in kerberos functions
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source3/libads/kerberos.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/source3/libads/kerberos.c b/source3/libads/kerberos.c
index cfb09a704cb..82f118a021e 100644
--- a/source3/libads/kerberos.c
+++ b/source3/libads/kerberos.c
@@ -336,10 +336,10 @@ int kerberos_kinit_password(const char *principal,
************************************************************************/
-static void add_sockaddr_unique(struct sockaddr_storage *addrs, int *num_addrs,
+static void add_sockaddr_unique(struct sockaddr_storage *addrs, size_t *num_addrs,
const struct sockaddr_storage *addr)
{
- int i;
+ size_t i;
for (i=0; i<*num_addrs; i++) {
if (sockaddr_equal((const struct sockaddr *)&addrs[i],
@@ -382,12 +382,12 @@ static char *get_kdc_ip_string(char *mem_ctx,
const struct sockaddr_storage *pss)
{
TALLOC_CTX *frame = talloc_stackframe();
- int i;
+ size_t i;
struct ip_service *ip_srv_site = NULL;
struct ip_service *ip_srv_nonsite = NULL;
int count_site = 0;
int count_nonsite;
- int num_dcs;
+ size_t num_dcs;
struct sockaddr_storage *dc_addrs;
struct tsocket_address **dc_addrs2 = NULL;
const struct tsocket_address * const *dc_addrs3 = NULL;
@@ -448,7 +448,7 @@ static char *get_kdc_ip_string(char *mem_ctx,
struct tsocket_address *,
num_dcs);
- DEBUG(10, ("%d additional KDCs to test\n", num_dcs));
+ DBG_DEBUG("%zu additional KDCs to test\n", num_dcs);
if (num_dcs == 0) {
goto out;
}
--
2.15.1
>From b09a6576d001c7723ace7bcf512cb7e933d032c1 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 17:40:00 +0100
Subject: [PATCH 04/42] s4:dns_server: Fix size types
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source4/dns_server/dns_server.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/source4/dns_server/dns_server.c b/source4/dns_server/dns_server.c
index cd293b82522..b7f41b5c42f 100644
--- a/source4/dns_server/dns_server.c
+++ b/source4/dns_server/dns_server.c
@@ -687,7 +687,7 @@ static NTSTATUS dns_startup_interfaces(struct dns_server *dns,
struct interface *ifaces,
const struct model_ops *model_ops)
{
- int num_interfaces;
+ size_t num_interfaces;
TALLOC_CTX *tmp_ctx = talloc_new(dns);
NTSTATUS status;
int i;
@@ -704,7 +704,7 @@ static NTSTATUS dns_startup_interfaces(struct dns_server *dns,
NT_STATUS_NOT_OK_RETURN(status);
}
} else {
- int num_binds = 0;
+ size_t num_binds = 0;
char **wcard;
wcard = iface_list_wildcard(tmp_ctx);
if (wcard == NULL) {
--
2.15.1
>From c6aaafde85fe2c7c74b744d00da3d9dbdb37bbd0 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 17:42:02 +0100
Subject: [PATCH 05/42] s4:rpc_server: Fix size types in dcerpc dnsserver
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source4/rpc_server/dnsserver/dcerpc_dnsserver.c | 4 ++--
source4/rpc_server/dnsserver/dnsdata.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/source4/rpc_server/dnsserver/dcerpc_dnsserver.c b/source4/rpc_server/dnsserver/dcerpc_dnsserver.c
index 120d4b9a3d7..5d3cb9e2a8e 100644
--- a/source4/rpc_server/dnsserver/dcerpc_dnsserver.c
+++ b/source4/rpc_server/dnsserver/dcerpc_dnsserver.c
@@ -1223,9 +1223,9 @@ static WERROR dnsserver_complex_operate_server(struct dnsserver_state *dsstate,
{
int valid_operation = 0;
struct dnsserver_zone *z, **zlist;
- int zcount;
+ size_t zcount;
bool found1, found2, found3, found4;
- int i;
+ size_t i;
if (strcasecmp(operation, "QueryDwordProperty") == 0) {
if (typeid_in == DNSSRV_TYPEID_LPSTR) {
diff --git a/source4/rpc_server/dnsserver/dnsdata.c b/source4/rpc_server/dnsserver/dnsdata.c
index c3006433515..8080fa480b2 100644
--- a/source4/rpc_server/dnsserver/dnsdata.c
+++ b/source4/rpc_server/dnsserver/dnsdata.c
@@ -96,7 +96,7 @@ struct IP4_ARRAY *dns_addr_array_to_ip4_array(TALLOC_CTX *mem_ctx,
struct DNS_ADDR_ARRAY *ip)
{
struct IP4_ARRAY *ret;
- int i, count, curr;
+ size_t i, count, curr;
if (ip == NULL) {
return NULL;
--
2.15.1
>From 61811d99f21d81e06503672b048299f0e3930f09 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 17:43:08 +0100
Subject: [PATCH 06/42] s4:ldap_server: Fix size types
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source4/ldap_server/ldap_server.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/source4/ldap_server/ldap_server.c b/source4/ldap_server/ldap_server.c
index 5f7efe90bba..91e5d05b7fe 100644
--- a/source4/ldap_server/ldap_server.c
+++ b/source4/ldap_server/ldap_server.c
@@ -1178,8 +1178,8 @@ static void ldapsrv_task_init(struct task_server *task)
}
} else {
char **wcard;
- int i;
- int num_binds = 0;
+ size_t i;
+ size_t num_binds = 0;
wcard = iface_list_wildcard(task);
if (wcard == NULL) {
DEBUG(0,("No wildcard addresses available\n"));
--
2.15.1
>From 7f6fc1ab20db54a469b5254ef2164849534f40b4 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 17:43:58 +0100
Subject: [PATCH 07/42] s4:cldap_server: Fix size types
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source4/cldap_server/cldap_server.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source4/cldap_server/cldap_server.c b/source4/cldap_server/cldap_server.c
index 3f845c7e240..a0cde776550 100644
--- a/source4/cldap_server/cldap_server.c
+++ b/source4/cldap_server/cldap_server.c
@@ -154,7 +154,7 @@ static NTSTATUS cldapd_startup_interfaces(struct cldapd_server *cldapd, struct l
/* if we are allowing incoming packets from any address, then
we need to bind to the wildcard address */
if (!lpcfg_bind_interfaces_only(lp_ctx)) {
- int num_binds = 0;
+ size_t num_binds = 0;
char **wcard = iface_list_wildcard(cldapd);
NT_STATUS_HAVE_NO_MEMORY(wcard);
for (i=0; wcard[i]; i++) {
--
2.15.1
>From 02030d9cb99b3b902d52d2ffb7cd204dc9eb2fea Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 17:01:39 +0100
Subject: [PATCH 08/42] libcli:smb: Fix size types
This fixes compilation with -Wstrict-overflow=2.
Signed-off-by: Andreas Schneider <asn at samba.org>
---
libcli/smb/smbXcli_base.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c
index 6335ce0c121..4df39c5d6da 100644
--- a/libcli/smb/smbXcli_base.c
+++ b/libcli/smb/smbXcli_base.c
@@ -1901,7 +1901,7 @@ static NTSTATUS smb1cli_inbuf_parse_chain(uint8_t *buf, TALLOC_CTX *mem_ctx,
struct iovec **piov, int *pnum_iov)
{
struct iovec *iov;
- int num_iov;
+ size_t num_iov;
size_t buflen;
size_t taken;
size_t remaining;
@@ -3457,7 +3457,8 @@ static NTSTATUS smb2cli_inbuf_parse_compound(struct smbXcli_conn *conn,
uint8_t *buf,
size_t buflen,
TALLOC_CTX *mem_ctx,
- struct iovec **piov, int *pnum_iov)
+ struct iovec **piov,
+ size_t *pnum_iov)
{
struct iovec *iov;
int num_iov = 0;
@@ -3643,7 +3644,7 @@ static NTSTATUS smb2cli_conn_dispatch_incoming(struct smbXcli_conn *conn,
struct tevent_req *req;
struct smbXcli_req_state *state = NULL;
struct iovec *iov = NULL;
- int i, num_iov = 0;
+ size_t i, num_iov = 0;
NTSTATUS status;
bool defer = true;
struct smbXcli_session *last_session = NULL;
--
2.15.1
>From 6070aa6ac209ace16253e6a6072c02ca7ab486e5 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 17:03:37 +0100
Subject: [PATCH 09/42] s3:param: Fix size types
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source3/param/loadparm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 01c022e2889..7213ffb24ac 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -1833,8 +1833,8 @@ static bool is_synonym_of(int parm1, int parm2, bool *inverse)
static void show_parameter(int parmIndex)
{
- int enumIndex, flagIndex;
- int parmIndex2;
+ size_t enumIndex, flagIndex;
+ size_t parmIndex2;
bool hadFlag;
bool hadSyn;
bool inverse;
--
2.15.1
>From 9292a69dfde2be0a2cf15768d86f626e4a1b2c2e Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 17:45:45 +0100
Subject: [PATCH 10/42] s4:utils: Fix size types
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source4/utils/oLschema2ldif.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source4/utils/oLschema2ldif.c b/source4/utils/oLschema2ldif.c
index 108c2c8ab20..c46799d737a 100644
--- a/source4/utils/oLschema2ldif.c
+++ b/source4/utils/oLschema2ldif.c
@@ -68,7 +68,7 @@ struct ldb_dn *basedn;
static int check_braces(const char *string)
{
- int b;
+ size_t b;
char *c;
b = 0;
--
2.15.1
>From d8e2204c0d5f1c5b5ecbd77fb0714059bda65a37 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 17:48:00 +0100
Subject: [PATCH 11/42] s4:rpc_server: Fix size types
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source4/rpc_server/dcerpc_server.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/source4/rpc_server/dcerpc_server.c b/source4/rpc_server/dcerpc_server.c
index 24eaa65459e..a35560d6be8 100644
--- a/source4/rpc_server/dcerpc_server.c
+++ b/source4/rpc_server/dcerpc_server.c
@@ -3088,8 +3088,8 @@ static NTSTATUS dcesrv_add_ep_tcp(struct dcesrv_context *dce_ctx,
}
} else {
char **wcard;
- int i;
- int num_binds = 0;
+ size_t i;
+ size_t num_binds = 0;
wcard = iface_list_wildcard(dce_ctx);
NT_STATUS_HAVE_NO_MEMORY(wcard);
for (i=0; wcard[i]; i++) {
--
2.15.1
>From e77ffcdc85bc719a513525536c55c35ff37d582f Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 17:47:15 +0100
Subject: [PATCH 12/42] s4:torture: Fix size types in qsinfo test
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source4/torture/raw/qfsinfo.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/source4/torture/raw/qfsinfo.c b/source4/torture/raw/qfsinfo.c
index 0f1717b9cb2..b9ce2465c20 100644
--- a/source4/torture/raw/qfsinfo.c
+++ b/source4/torture/raw/qfsinfo.c
@@ -124,9 +124,9 @@ static union smb_fsinfo *find(const char *name)
bool torture_raw_qfsinfo(struct torture_context *torture,
struct smbcli_state *cli)
{
- int i;
+ size_t i;
bool ret = true;
- int count;
+ size_t count;
union smb_fsinfo *s1, *s2;
/* scan all the levels, pulling the results */
@@ -152,7 +152,7 @@ bool torture_raw_qfsinfo(struct torture_context *torture,
}
if (count != 0) {
- torture_comment(torture, "%d levels failed\n", count);
+ torture_comment(torture, "%zu levels failed\n", count);
torture_assert(torture, count > 13, "too many level failures - giving up");
}
--
2.15.1
>From b2c8388d7aab7f5db4fcaaaafb2bc81738c7ecfe Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 17:49:00 +0100
Subject: [PATCH 13/42] s4:torture: Fix size types in qfileinfo test
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source4/torture/raw/qfileinfo.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/source4/torture/raw/qfileinfo.c b/source4/torture/raw/qfileinfo.c
index 0c5daa3ccc3..dd529250969 100644
--- a/source4/torture/raw/qfileinfo.c
+++ b/source4/torture/raw/qfileinfo.c
@@ -229,9 +229,9 @@ static bool torture_raw_qfileinfo_internals(struct torture_context *torture,
int fnum, const char *fname,
bool is_ipc)
{
- int i;
+ size_t i;
bool ret = true;
- int count;
+ size_t count;
union smb_fileinfo *s1, *s2;
NTTIME correct_time;
uint64_t correct_size;
@@ -333,7 +333,7 @@ static bool torture_raw_qfileinfo_internals(struct torture_context *torture,
if (count != 0) {
ret = false;
- printf("%d levels failed\n", count);
+ printf("%zu levels failed\n", count);
if (count > 35) {
torture_fail(torture, "too many level failures - giving up");
}
--
2.15.1
>From 0d7a60d74a2484ce8b8b429e6778984b6576bf99 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 17:50:33 +0100
Subject: [PATCH 14/42] s3:torture: Fix size types in spoolss test
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source4/torture/rpc/spoolss.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index 31b9525ee62..380137b3dd3 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -5628,7 +5628,7 @@ static bool test_SetPrinterDataEx_matrix(struct torture_context *tctx,
REG_BINARY
};
const char *str = "abcdefghi";
- int t, s;
+ size_t t, s;
for (t=0; t < ARRAY_SIZE(types); t++) {
for (s=0; s < strlen(str); s++) {
--
2.15.1
>From 38cb9eb497b4a780892b21d9b40ba3d8879209ea Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 17:52:39 +0100
Subject: [PATCH 15/42] s3:libsmb: Fix size types in nmblib
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source3/libsmb/nmblib.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/source3/libsmb/nmblib.c b/source3/libsmb/nmblib.c
index 8feb029b05e..a2d561d6c7d 100644
--- a/source3/libsmb/nmblib.c
+++ b/source3/libsmb/nmblib.c
@@ -176,11 +176,11 @@ static bool handle_name_ptrs(unsigned char *ubuf,int *offset,int length,
static int parse_nmb_name(char *inbuf,int ofs,int length, struct nmb_name *name)
{
- int m,n=0;
+ size_t m,n=0;
unsigned char *ubuf = (unsigned char *)inbuf;
int ret = 0;
bool got_pointer=False;
- int loop_count=0;
+ size_t loop_count=0;
int offset = ofs;
if (length - offset < 2)
@@ -483,7 +483,7 @@ static int put_compressed_name_ptr(unsigned char *buf,
static bool parse_dgram(char *inbuf,int length,struct dgram_packet *dgram)
{
- int offset;
+ size_t offset;
int flags;
memset((char *)dgram,'\0',sizeof(*dgram));
--
2.15.1
>From 193d051cb9fe1e6b3cf585b8875a89447c7ea20b Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 17:54:12 +0100
Subject: [PATCH 16/42] s4:torture: Fix size types in nss tests
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source4/torture/local/nss_tests.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/source4/torture/local/nss_tests.c b/source4/torture/local/nss_tests.c
index 2cd61225ab8..cc02047d565 100644
--- a/source4/torture/local/nss_tests.c
+++ b/source4/torture/local/nss_tests.c
@@ -899,7 +899,7 @@ static bool test_reentrant_enumeration_crosschecks(struct torture_context *tctx)
static bool test_passwd_duplicates(struct torture_context *tctx)
{
- int i, d;
+ size_t i, d;
struct passwd *pwd;
size_t num_pwd;
int duplicates = 0;
@@ -934,7 +934,7 @@ static bool test_passwd_duplicates(struct torture_context *tctx)
static bool test_group_duplicates(struct torture_context *tctx)
{
- int i, d;
+ size_t i, d;
struct group *grp;
size_t num_grp;
int duplicates = 0;
--
2.15.1
>From 2ced1dfcc0efb7ee5b8feeaace7eca725e0075af Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 17:55:34 +0100
Subject: [PATCH 17/42] s4:client: Fix size types
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source4/client/client.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/source4/client/client.c b/source4/client/client.c
index e04aa25d69b..f73d9f99d20 100644
--- a/source4/client/client.c
+++ b/source4/client/client.c
@@ -2849,10 +2849,10 @@ static struct
******************************************************************/
static int process_tok(const char *tok)
{
- int i = 0, matches = 0;
- int cmd=0;
- int tok_len = strlen(tok);
-
+ size_t i = 0, matches = 0;
+ size_t cmd=0;
+ size_t tok_len = strlen(tok);
+
while (commands[i].fn != NULL) {
if (strequal(commands[i].name,tok)) {
matches = 1;
--
2.15.1
>From 01a22c27469a07996f8758540c5fd48c8fba24ed Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 18:47:18 +0100
Subject: [PATCH 18/42] s3:client: Fix size types
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source3/client/client.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/source3/client/client.c b/source3/client/client.c
index ad10a5381dd..49d027ad4ac 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -5607,9 +5607,9 @@ static struct {
static int process_tok(char *tok)
{
- int i = 0, matches = 0;
- int cmd=0;
- int tok_len = strlen(tok);
+ size_t i = 0, matches = 0;
+ size_t cmd=0;
+ size_t tok_len = strlen(tok);
while (commands[i].fn != NULL) {
if (strequal(commands[i].name,tok)) {
--
2.15.1
>From 9fd666321b71ac72f46904651324144e84426e9e Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 17:57:05 +0100
Subject: [PATCH 19/42] s3:avahi: Fix size types
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source3/smbd/avahi_register.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/source3/smbd/avahi_register.c b/source3/smbd/avahi_register.c
index 91e8a439b84..e80f68d764a 100644
--- a/source3/smbd/avahi_register.c
+++ b/source3/smbd/avahi_register.c
@@ -108,7 +108,7 @@ static void avahi_client_callback(AvahiClient *c, AvahiClientState status,
case AVAHI_CLIENT_S_RUNNING: {
int snum;
int num_services = lp_numservices();
- int dk = 0;
+ size_t dk = 0;
AvahiStringList *adisk = NULL;
AvahiStringList *adisk2 = NULL;
@@ -140,7 +140,7 @@ static void avahi_client_callback(AvahiClient *c, AvahiClientState status,
lp_parm_bool(snum, "fruit", "time machine", false))
{
adisk2 = avahi_string_list_add_printf(
- adisk, "dk%d=adVN=%s,adVF=0x82",
+ adisk, "dk%zu=adVN=%s,adVF=0x82",
dk++, lp_const_servicename(snum));
if (adisk2 == NULL) {
DBG_DEBUG("avahi_string_list_add_printf"
--
2.15.1
>From 171ddf0cd3d3a56b3d409294e1e70d3acafaae6f Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 17:58:38 +0100
Subject: [PATCH 20/42] s3:printing: Fix size type in printing_db
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source3/printing/printing_db.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/printing/printing_db.c b/source3/printing/printing_db.c
index 1a129eaad3b..7465195b771 100644
--- a/source3/printing/printing_db.c
+++ b/source3/printing/printing_db.c
@@ -35,7 +35,7 @@ static struct tdb_print_db *print_db_head;
struct tdb_print_db *get_print_db_byname(const char *printername)
{
struct tdb_print_db *p = NULL, *last_entry = NULL;
- int num_open = 0;
+ size_t num_open = 0;
char *printdb_path = NULL;
bool done_become_root = False;
char *print_cache_path;
--
2.15.1
>From f8e60b1a266a1400c663f70e0f5d6cbe1fb4f964 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 18:27:41 +0100
Subject: [PATCH 21/42] s3:winbindd: Fix size types in idmap_tdb_common
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source3/winbindd/idmap_tdb_common.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/source3/winbindd/idmap_tdb_common.c b/source3/winbindd/idmap_tdb_common.c
index e873b60bd8f..48d87bb16cf 100644
--- a/source3/winbindd/idmap_tdb_common.c
+++ b/source3/winbindd/idmap_tdb_common.c
@@ -307,7 +307,7 @@ NTSTATUS idmap_tdb_common_unixids_to_sids(struct idmap_domain * dom,
struct id_map ** ids)
{
NTSTATUS ret;
- int i, num_mapped = 0;
+ size_t i, num_mapped = 0;
struct idmap_tdb_common_context *ctx;
NTSTATUS(*unixid_to_sid_fn) (struct idmap_domain * dom,
@@ -543,7 +543,7 @@ static NTSTATUS idmap_tdb_common_sids_to_unixids_action(struct db_context *db,
void *private_data)
{
struct idmap_tdb_common_sids_to_unixids_context *state = private_data;
- int i, num_mapped = 0;
+ size_t i, num_mapped = 0;
NTSTATUS ret = NT_STATUS_OK;
DEBUG(10, ("idmap_tdb_common_sids_to_unixids: "
--
2.15.1
>From d0e10bcca00e2d0607143b91859bdf65eea4cb16 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 18:39:07 +0100
Subject: [PATCH 22/42] s3:vfs_nettalk: Fix size types
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source3/modules/vfs_netatalk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/modules/vfs_netatalk.c b/source3/modules/vfs_netatalk.c
index 16c129de995..4ebb945cd1b 100644
--- a/source3/modules/vfs_netatalk.c
+++ b/source3/modules/vfs_netatalk.c
@@ -118,7 +118,7 @@ static int atalk_unlink_file(const char *path)
static void atalk_add_to_list(name_compare_entry **list)
{
- int i, count = 0;
+ size_t i, count = 0;
name_compare_entry *new_list = 0;
name_compare_entry *cur_list = 0;
--
2.15.1
>From 9bb1b260ea30c678cbebbfb839251f7051cf12f7 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 18:42:44 +0100
Subject: [PATCH 23/42] s3:rpc_server: Fix size types in srvsvc
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source3/rpc_server/srvsvc/srv_srvsvc_nt.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
index 2ff8e64fccc..85a2fc35a5b 100644
--- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
+++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
@@ -547,13 +547,13 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
uint32_t *total_entries,
bool all_shares)
{
- int num_entries = 0;
- int alloc_entries = 0;
+ uint32_t num_entries = 0;
+ uint32_t alloc_entries = 0;
int num_services = 0;
int snum;
TALLOC_CTX *ctx = p->mem_ctx;
- int i = 0;
- int valid_share_count = 0;
+ uint32_t i = 0;
+ uint32_t valid_share_count = 0;
bool *allowed = 0;
union srvsvc_NetShareCtr ctr;
uint32_t resume_handle = resume_handle_p ? *resume_handle_p : 0;
--
2.15.1
>From 53ee37f88a91972da0e0579ebc5013be83f48443 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 19:47:04 +0100
Subject: [PATCH 24/42] s3:utils: Fix size type in log2pcaphex
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source3/utils/log2pcaphex.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/utils/log2pcaphex.c b/source3/utils/log2pcaphex.c
index f31efa10df8..5310982bed3 100644
--- a/source3/utils/log2pcaphex.c
+++ b/source3/utils/log2pcaphex.c
@@ -305,7 +305,7 @@ int main(int argc, const char **argv)
long data_offset = 0;
long data_length;
long data_bytes_read = 0;
- int in_packet = 0;
+ size_t in_packet = 0;
struct poptOption long_options[] = {
POPT_AUTOHELP
{ "quiet", 'q', POPT_ARG_NONE, &quiet, 0, "Be quiet, don't output warnings" },
--
2.15.1
>From 9483e641190d1054a956316f5d9387891e6cbee1 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 19:47:50 +0100
Subject: [PATCH 25/42] s3:nmbd: Fix size type in nmbd_browsesync.c
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source3/nmbd/nmbd_browsesync.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/nmbd/nmbd_browsesync.c b/source3/nmbd/nmbd_browsesync.c
index b1517f89c9f..6f90e613478 100644
--- a/source3/nmbd/nmbd_browsesync.c
+++ b/source3/nmbd/nmbd_browsesync.c
@@ -629,7 +629,7 @@ void sync_all_dmbs(time_t t)
{
static time_t lastrun = 0;
struct work_record *work;
- int count=0;
+ size_t count=0;
/* Only do this if we are using a WINS server. */
if(we_are_a_wins_client() == False)
--
2.15.1
>From a36ae5c7b776d648885c5924ebf458bb64ae68cf Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 20:07:08 +0100
Subject: [PATCH 26/42] s3:modules: Fix size type in getdate
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source3/modules/getdate.c | 2 +-
source3/modules/getdate.y | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/source3/modules/getdate.c b/source3/modules/getdate.c
index 6ed994649c4..8840d85cb7a 100644
--- a/source3/modules/getdate.c
+++ b/source3/modules/getdate.c
@@ -2491,7 +2491,7 @@ static int
yylex (YYSTYPE *lvalp, parser_control *pc)
{
unsigned char c;
- int count;
+ size_t count;
for (;;)
{
diff --git a/source3/modules/getdate.y b/source3/modules/getdate.y
index 1ddcda4fca7..2e49f15b87f 100644
--- a/source3/modules/getdate.y
+++ b/source3/modules/getdate.y
@@ -790,7 +790,7 @@ static int
yylex (YYSTYPE *lvalp, parser_control *pc)
{
unsigned char c;
- int count;
+ size_t count;
for (;;)
{
--
2.15.1
>From 609dc92057dbf653692383640defced42d137803 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 18:48:45 +0100
Subject: [PATCH 27/42] s3:passdb: Fix size types
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source3/passdb/pdb_ldap.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index c495448dcc5..bf9377c88d3 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -4103,7 +4103,8 @@ static NTSTATUS ldapsam_lookup_rids(struct pdb_methods *methods,
LDAPMessage *msg = NULL;
LDAPMessage *entry;
char *allsids = NULL;
- int i, rc, num_mapped;
+ size_t i, num_mapped;
+ int rc;
NTSTATUS result = NT_STATUS_NO_MEMORY;
TALLOC_CTX *mem_ctx;
LDAP *ld;
--
2.15.1
>From 8814662dcf5d8f01817afaf77e78c4be869252eb Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 18:50:20 +0100
Subject: [PATCH 28/42] s3:rpc_server: Fix size types in spoolss
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source3/rpc_server/spoolss/srv_spoolss_nt.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c
index f0226ba9441..fceb08fba38 100644
--- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
+++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
@@ -1085,13 +1085,13 @@ static int build_notify2_messages(TALLOC_CTX *mem_ctx,
SPOOLSS_NOTIFY_MSG *messages,
uint32_t num_msgs,
struct spoolss_Notify **_notifies,
- int *_count)
+ size_t *_count)
{
struct spoolss_Notify *notifies;
SPOOLSS_NOTIFY_MSG *msg;
- int count = 0;
+ size_t count = 0;
uint32_t id;
- int i;
+ uint32_t i;
notifies = talloc_zero_array(mem_ctx,
struct spoolss_Notify, num_msgs);
@@ -1184,7 +1184,7 @@ static int send_notify2_printer(TALLOC_CTX *mem_ctx,
SPOOLSS_NOTIFY_MSG_GROUP *msg_group)
{
struct spoolss_Notify *notifies;
- int count = 0;
+ size_t count = 0;
union spoolss_ReplyPrinterInfo info;
struct spoolss_NotifyInfo info0;
uint32_t reply_result;
--
2.15.1
>From 7319cdc2bcc4b777402df954a54de865ca8a92f1 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 19:21:38 +0100
Subject: [PATCH 29/42] s3:rpcclient: Fix size types
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source3/rpcclient/rpcclient.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index c1039ed84c5..c364d504045 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -73,7 +73,7 @@ static char **completion_fn(const char *text, int start, int end)
{
#define MAX_COMPLETIONS 1000
char **matches;
- int i, count=0;
+ size_t i, count=0;
struct cmd_list *commands = cmd_list;
#if 0 /* JERRY */
--
2.15.1
>From 139cb1d5ed01d702647b99f641dfff83ad16e684 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 15:54:13 +0100
Subject: [PATCH 30/42] lib:socket: Return early if we have only one interface
Signed-off-by: Andreas Schneider <asn at samba.org>
---
lib/socket/interfaces.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/socket/interfaces.c b/lib/socket/interfaces.c
index 6409275d7bc..168bff501c2 100644
--- a/lib/socket/interfaces.c
+++ b/lib/socket/interfaces.c
@@ -367,7 +367,10 @@ int get_interfaces(TALLOC_CTX *mem_ctx, struct iface_struct **pifaces)
int total, i, j;
total = _get_interfaces(mem_ctx, &ifaces);
- if (total <= 0) return total;
+ /* If we have an error, no interface or just one we can leave */
+ if (total <= 1) {
+ return total;
+ }
/* now we need to remove duplicates */
TYPESAFE_QSORT(ifaces, total, iface_comp);
--
2.15.1
>From f2b36c57898187c89b3624119c22a089c2f97169 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 16:20:18 +0100
Subject: [PATCH 31/42] ldb: Fix return checks in ldif functions
This fixes compilation with -Wstrict-overflow=2<Paste>
Signed-off-by: Andreas Schneider <asn at samba.org>
---
lib/ldb/common/ldb_ldif.c | 46 ++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 42 insertions(+), 4 deletions(-)
diff --git a/lib/ldb/common/ldb_ldif.c b/lib/ldb/common/ldb_ldif.c
index b90d27eea59..8408da6aca0 100644
--- a/lib/ldb/common/ldb_ldif.c
+++ b/lib/ldb/common/ldb_ldif.c
@@ -207,7 +207,18 @@ int ldb_should_b64_encode(struct ldb_context *ldb, const struct ldb_val *val)
}
/* this macro is used to handle the return checking on fprintf_fn() */
-#define CHECK_RET do { if (ret < 0) return ret; total += ret; } while (0)
+#define CHECK_RET \
+ do { \
+ if (ret < 0) { \
+ return ret; \
+ } \
+ if (ret > 0) { \
+ if ((total + ret) < total) { \
+ return -1; \
+ } \
+ total += ret; \
+ } \
+ } while (0)
/*
write a line folded string onto a file
@@ -267,7 +278,19 @@ static const struct {
};
/* this macro is used to handle the return checking on fprintf_fn() */
-#define CHECK_RET do { if (ret < 0) { talloc_free(mem_ctx); return ret; } total += ret; } while (0)
+#define CHECK_RET \
+ do { \
+ if (ret < 0) { \
+ talloc_free(mem_ctx); \
+ return ret; \
+ } \
+ if (ret > 0) { \
+ if ((total + ret) < total) { \
+ return -1; \
+ } \
+ total += ret; \
+ } \
+ } while (0)
/*
write to ldif, using a caller supplied write method, and only printing secrets if we are not in a trace
@@ -370,7 +393,14 @@ static int ldb_ldif_write_trace(struct ldb_context *ldb,
ret = base64_encode_f(ldb, fprintf_fn, private_data,
(char *)v.data, v.length,
strlen(msg->elements[i].name)+3);
- CHECK_RET;
+ if (ret < 0) {
+ talloc_free(mem_ctx);
+ return ret;
+ }
+ if (total + ret < total) {
+ return -1;
+ }
+ total += ret;
ret = fprintf_fn(private_data, "\n");
CHECK_RET;
} else {
@@ -379,12 +409,20 @@ static int ldb_ldif_write_trace(struct ldb_context *ldb,
if (ldb->flags & LDB_FLG_SHOW_BINARY) {
ret = fprintf_fn(private_data, "%*.*s",
v.length, v.length, (char *)v.data);
+ CHECK_RET;
} else {
ret = fold_string(fprintf_fn, private_data,
(char *)v.data, v.length,
strlen(msg->elements[i].name)+2);
+ if (ret < 0) {
+ talloc_free(mem_ctx);
+ return ret;
+ }
+ if (total + ret < total) {
+ return -1;
+ }
+ total += ret;
}
- CHECK_RET;
ret = fprintf_fn(private_data, "\n");
CHECK_RET;
}
--
2.15.1
>From d814103188715e02d7a00ace957c95106a63abf1 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 16:40:51 +0100
Subject: [PATCH 32/42] lib:param: Fix P_LIST case in set_variable_helper()
This is to pass -Wstrict-overflow=2 but also improves readablity.
Signed-off-by: Andreas Schneider <asn at samba.org>
---
lib/param/loadparm.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c
index d788ffbe36f..0ef6e715766 100644
--- a/lib/param/loadparm.c
+++ b/lib/param/loadparm.c
@@ -1670,20 +1670,21 @@ static bool set_variable_helper(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr
break;
}
+ if (*(const char ***)parm_ptr == NULL) {
+ *(char ***)parm_ptr = new_list;
+ break;
+ }
+
for (i=0; new_list[i]; i++) {
- if (*(const char ***)parm_ptr != NULL &&
- new_list[i][0] == '+' &&
- new_list[i][1])
- {
+ if (new_list[i][0] == '+' &&
+ new_list[i][1] != '\0') {
if (!str_list_check(*(const char ***)parm_ptr,
&new_list[i][1])) {
*(const char ***)parm_ptr = str_list_add(*(const char ***)parm_ptr,
&new_list[i][1]);
}
- } else if (*(const char ***)parm_ptr != NULL &&
- new_list[i][0] == '-' &&
- new_list[i][1])
- {
+ } else if (new_list[i][0] == '-' &&
+ new_list[i][1] != '\0') {
str_list_remove(*(const char ***)parm_ptr,
&new_list[i][1]);
} else {
@@ -1692,8 +1693,6 @@ static bool set_variable_helper(TALLOC_CTX *mem_ctx, int parmnum, void *parm_ptr
pszParmName, pszParmValue));
return false;
}
- *(char ***)parm_ptr = new_list;
- break;
}
}
break;
--
2.15.1
>From 5cdf50831b5461e78abe9a37a254f91f49c00232 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 26 Oct 2017 09:47:57 +0200
Subject: [PATCH 33/42] util: Add sanity check for count in
ms_fnmatch_protocol()
This fixes -Wstrict-overflow=2.
Signed-off-by: Andreas Schneider <asn at samba.org>
---
lib/util/ms_fnmatch.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/util/ms_fnmatch.c b/lib/util/ms_fnmatch.c
index c0f61ab04e7..4068b3cf1be 100644
--- a/lib/util/ms_fnmatch.c
+++ b/lib/util/ms_fnmatch.c
@@ -164,7 +164,8 @@ static int ms_fnmatch_core(const char *p, const char *n,
int ms_fnmatch_protocol(const char *pattern, const char *string, int protocol,
bool is_case_sensitive)
{
- int ret, count, i;
+ int ret = -1;
+ size_t count, i;
if (strcmp(string, "..") == 0) {
string = ".";
@@ -209,7 +210,7 @@ int ms_fnmatch_protocol(const char *pattern, const char *string, int protocol,
if (pattern[i] == '*' || pattern[i] == '<') count++;
}
- {
+ if (count > 0) {
struct max_n max_n[count];
memset(max_n, 0, sizeof(struct max_n) * count);
--
2.15.1
>From 071d7ccd449a4d501b1727a9aeb1122dd41c01a0 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 16:58:25 +0100
Subject: [PATCH 34/42] s3:lib: Fix sanity checks in ms_fnmatch()
This fixes -Wstrict-overflow=2.
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source3/lib/ms_fnmatch.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/source3/lib/ms_fnmatch.c b/source3/lib/ms_fnmatch.c
index 9763afefe76..fb58ec26fd2 100644
--- a/source3/lib/ms_fnmatch.c
+++ b/source3/lib/ms_fnmatch.c
@@ -150,7 +150,8 @@ int ms_fnmatch(const char *pattern, const char *string, bool translate_pattern,
{
smb_ucs2_t *p = NULL;
smb_ucs2_t *s = NULL;
- int ret, count, i;
+ int ret;
+ size_t count, i;
struct max_n *max_n = NULL;
struct max_n *max_n_free = NULL;
struct max_n one_max_n;
@@ -203,7 +204,7 @@ int ms_fnmatch(const char *pattern, const char *string, bool translate_pattern,
if (p[i] == UCS2_CHAR('*') || p[i] == UCS2_CHAR('<')) count++;
}
- if (count != 0) {
+ if (count > 0) {
if (count == 1) {
/*
* We're doing this a LOT, so save the effort to allocate
--
2.15.1
>From cc14deb1a82243c27dc287a78d459651f3da051e Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 17:32:36 +0100
Subject: [PATCH 35/42] s4:dsdb: Fix integer operations
This fixes compilation with -Wstrict-overflow=2.
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source4/dsdb/samdb/ldb_modules/operational.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/source4/dsdb/samdb/ldb_modules/operational.c b/source4/dsdb/samdb/ldb_modules/operational.c
index 08a8454eca6..576cf861574 100644
--- a/source4/dsdb/samdb/ldb_modules/operational.c
+++ b/source4/dsdb/samdb/ldb_modules/operational.c
@@ -699,7 +699,7 @@ static NTTIME get_msds_user_password_expiry_time_computed(struct ldb_module *mod
return 0x7FFFFFFFFFFFFFFFULL;
}
- if (pwdLastSet >= 0x7FFFFFFFFFFFFFFFULL) {
+ if (pwdLastSet >= 0x7FFFFFFFFFFFFFFFLL) {
/*
* Somethings wrong with the clock...
*/
@@ -725,7 +725,7 @@ static NTTIME get_msds_user_password_expiry_time_computed(struct ldb_module *mod
return 0x7FFFFFFFFFFFFFFFULL;
}
- if (maxPwdAge == -0x8000000000000000ULL) {
+ if (maxPwdAge == -0x8000000000000000LL) {
return 0x7FFFFFFFFFFFFFFFULL;
}
@@ -740,7 +740,7 @@ static NTTIME get_msds_user_password_expiry_time_computed(struct ldb_module *mod
* =
* 0xFFFFFFFFFFFFFFFFULL
*/
- ret = pwdLastSet - maxPwdAge;
+ ret = (NTTIME)pwdLastSet - (NTTIME)maxPwdAge;
if (ret >= 0x7FFFFFFFFFFFFFFFULL) {
return 0x7FFFFFFFFFFFFFFFULL;
}
--
2.15.1
>From d9de4213c85cb634c1b903f36da3227d5d581b37 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 15:24:59 +0100
Subject: [PATCH 36/42] s3:nmbd: Fix possible integer overflow
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source3/nmbd/nmbd_sendannounce.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/source3/nmbd/nmbd_sendannounce.c b/source3/nmbd/nmbd_sendannounce.c
index 1d557c45bbd..44d67e7ca84 100644
--- a/source3/nmbd/nmbd_sendannounce.c
+++ b/source3/nmbd/nmbd_sendannounce.c
@@ -288,8 +288,10 @@ void announce_my_server_names(time_t t)
}
/* Announce every minute at first then progress to every 12 mins */
- if ((t - work->lastannounce_time) < work->announce_interval)
+ if (t > work->lastannounce_time &&
+ (t - work->lastannounce_time) < work->announce_interval) {
continue;
+ }
if (work->announce_interval < (CHECK_TIME_MAX_HOST_ANNCE * 60))
work->announce_interval += 60;
--
2.15.1
>From 20e285c6e6798dbafba99ac58b4638efe156c7fe Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 18:24:18 +0100
Subject: [PATCH 37/42] s3:locking: Fix integer overflow check in
posix_lock_in_range()
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source3/locking/posix.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/source3/locking/posix.c b/source3/locking/posix.c
index ff794282114..0b627aaa3e5 100644
--- a/source3/locking/posix.c
+++ b/source3/locking/posix.c
@@ -145,7 +145,8 @@ static bool posix_lock_in_range(off_t *offset_out, off_t *count_out,
* Truncate count to end at max lock offset.
*/
- if (offset + count < 0 || offset + count > max_positive_lock_offset) {
+ if (offset > INT64_MAX - count ||
+ offset + count > max_positive_lock_offset) {
count = max_positive_lock_offset - offset;
}
--
2.15.1
>From f51f970705241aae8d63195ada8c3e26753dbd01 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 18:01:45 +0100
Subject: [PATCH 38/42] s3:printing: Fix size check in get_file_version()
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source3/printing/nt_printing.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 2e500f18c7d..00c737d2fd4 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -485,7 +485,7 @@ static int get_file_version(files_struct *fsp, char *fname,uint32_t *major, uint
/* Potential match data crosses buf boundry, move it to beginning
* of buf, and fill the buf with as much as it will hold. */
if (i>byte_count-VS_VERSION_INFO_SIZE) {
- int bc;
+ ssize_t bc;
memcpy(buf, &buf[i], byte_count-i);
if ((bc = vfs_read_data(fsp, &buf[byte_count-i], VS_NE_BUF_SIZE-
@@ -496,8 +496,10 @@ static int get_file_version(files_struct *fsp, char *fname,uint32_t *major, uint
goto error_exit;
}
+ if (byte_count - i < VS_VERSION_INFO_SIZE) {
+ break;
+ }
byte_count = bc + (byte_count - i);
- if (byte_count<VS_VERSION_INFO_SIZE) break;
i = 0;
}
--
2.15.1
>From ce0587d1e50c3ca88cb69509b104df463126eaf1 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 18:44:59 +0100
Subject: [PATCH 39/42] s3:vfs_preopen: Fix while loop check
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source3/modules/vfs_preopen.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/modules/vfs_preopen.c b/source3/modules/vfs_preopen.c
index 18b01e6c05e..4ef0a2e34ab 100644
--- a/source3/modules/vfs_preopen.c
+++ b/source3/modules/vfs_preopen.c
@@ -156,7 +156,7 @@ static bool preopen_helper_open_one(int sock_fd, char **pnamebuf,
nread = 0;
- while ((nread == 0) || (namebuf[nread-1] != '\0')) {
+ while (namebuf[nread-1] != '\0') {
ssize_t thistime;
thistime = read(sock_fd, namebuf + nread,
--
2.15.1
>From 36007b44385d6006a49f545652cf6f95229dba29 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 19:46:21 +0100
Subject: [PATCH 40/42] s3:registry: Fix size types and length calculations
This fixes compilation with -Wstrict-overflow=2
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source3/registry/reg_format.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/source3/registry/reg_format.c b/source3/registry/reg_format.c
index 15f63c7c06a..36ccb626194 100644
--- a/source3/registry/reg_format.c
+++ b/source3/registry/reg_format.c
@@ -54,16 +54,17 @@ static void cstr_unescape(char* val)
* @see srprs_val_name
*/
static int cbuf_print_value_assign(cbuf* ost, const char* name) {
- int ret, n;
+ size_t ret = 0;
+ int n;
if (*name == '\0') {
- ret = cbuf_putc(ost, '@');
+ n = cbuf_putc(ost, '@');
} else {
- ret = cbuf_print_quoted_string(ost, name);
+ n = cbuf_print_quoted_string(ost, name);
}
-
- if (ret<0) {
- return ret;
+ if (n < 0) {
+ return n;
}
+ ret += n;
n = cbuf_putc(ost, '=');
if (n < 0) {
@@ -120,7 +121,8 @@ cbuf_print_hive(cbuf* ost, const char* hive, int len, const struct fmt_key* fmt)
static int
cbuf_print_keyname(cbuf* ost, const char* key[], int n, const struct fmt_key* fmt)
{
- int r, ret=0;
+ int r;
+ size_t ret = 0;
size_t pos = cbuf_getpos(ost);
bool hive = true;
--
2.15.1
>From feacdfab2e30da8b81d0dcc1b67135441d1d6a29 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 7 Dec 2017 15:27:44 +0100
Subject: [PATCH 41/42] wafsamba: Add -Wstrict-overflow
Signed-off-by: Andreas Schneider <asn at samba.org>
---
buildtools/wafsamba/samba_autoconf.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py
index 7940a7d4fe8..f91329e0612 100644
--- a/buildtools/wafsamba/samba_autoconf.py
+++ b/buildtools/wafsamba/samba_autoconf.py
@@ -709,6 +709,8 @@ def SAMBA_CONFIG_H(conf, path=None):
testflags=True)
conf.ADD_CFLAGS('-Werror=uninitialized -Wuninitialized',
testflags=True)
+ conf.ADD_CFLAGS('-Werror=strict-overflow -Wstrict-overflow=2',
+ testflags=True)
conf.ADD_CFLAGS('-Wformat=2 -Wno-format-y2k', testflags=True)
conf.ADD_CFLAGS('-Wno-format-zero-length', testflags=True)
--
2.15.1
>From 9b5684f9acac4c4ff0136c0ef9663d8f9f4c28bf Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 26 Oct 2017 09:43:56 +0200
Subject: [PATCH 42/42] s3:glock: Add sanity check in g_lock_parse()
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source3/lib/g_lock.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/source3/lib/g_lock.c b/source3/lib/g_lock.c
index c5d66e3855e..ea2d7717ce5 100644
--- a/source3/lib/g_lock.c
+++ b/source3/lib/g_lock.c
@@ -81,6 +81,9 @@ static bool g_lock_parse(uint8_t *buf, size_t buflen, struct g_lock *lck)
buf += sizeof(uint32_t);
buflen -= sizeof(uint32_t);
data_ofs = found_recs * G_LOCK_REC_LENGTH;
+ if (data_ofs >= buflen) {
+ return false;
+ }
*lck = (struct g_lock) {
.recsbuf = buf, .num_recs = found_recs,
--
2.15.1
More information about the samba-technical
mailing list