[PATCH] Some fixes detected by Undefined Sanitizer

Andreas Schneider asn at samba.org
Thu Nov 22 20:51:55 UTC 2018


On Thursday, 22 November 2018 21:32:34 CET Gary Lockyer via samba-technical 
wrote:
> Happy with them all except:
> s4:bind_dlz: Only copy the dn once
>   dn gets modified in each loop iteration, so it needs to be copied for
>   each iteration.

Updated patchset attached.

> Otherwise RB+

Thanks!

> Gary.
> 
> On 23/11/18 05:07, Andreas Schneider via samba-technical wrote:
> > On Thursday, 22 November 2018 16:26:45 CET Andreas Schneider via samba-
> > 
> > technical wrote:
> >> On Wednesday, 21 November 2018 11:20:44 CET Andreas Schneider via samba-
> >> 
> >> technical wrote:
> >>> Hi,
> >>> 
> >>> see attached. Review and comments are welcome. Please push if OK.
> >> 
> >> Here is an updated patchset with more patches. I have more in the queue,
> >> but I can tell you, there be dragons!
> >> 
> >> https://gitlab.com/samba-team/devel/samba/pipelines/37563706
> > 
> > I've removed one patch which fixed some tdb stuff. This needs more fixing
> > by the callers first.
> > 
> > New pipeline:
> > https://gitlab.com/samba-team/devel/samba/pipelines/37566650
> > 
> > 	Andreas


-- 
Andreas Schneider                      asn at samba.org
Samba Team                             www.samba.org
GPG-ID:     8DFF53E18F2ABC8D8F3C92237EE0FC4DCC014E3D
-------------- next part --------------
>From 47449afe48696daf4136dada68e52dd1bcf78689 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Fri, 16 Nov 2018 16:07:42 +0100
Subject: [PATCH 01/12] s4:bind_dlz: Only copy the dn once

../source4/dns_server/dlz_bind9.c:1132:4: error: 'dn' may be used uninitialized in this function [-Werror=maybe-uninitialized]
    state->log(ISC_LOG_INFO, "failed to find dnsRecord for %s",
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        ldb_dn_get_linearized(dn));
        ~~~~~~~~~~~~~~~~~~~~~~~~~~

Found by Undefined Sanitizer.

Signed-off-by: Andreas Schneider <asn at samba.org>
---
 source4/dns_server/dlz_bind9.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/source4/dns_server/dlz_bind9.c b/source4/dns_server/dlz_bind9.c
index 43f3e57c789..82c72111a00 100644
--- a/source4/dns_server/dlz_bind9.c
+++ b/source4/dns_server/dlz_bind9.c
@@ -1059,8 +1059,9 @@ _PUBLIC_ isc_result_t dlz_allnodes(const char *zone, void *dbdata,
 {
 	struct dlz_bind9_data *state = talloc_get_type_abort(dbdata, struct dlz_bind9_data);
 	const char *attrs[] = { "dnsRecord", NULL };
-	int ret = LDB_SUCCESS, i, j;
-	struct ldb_dn *dn;
+	int ret = LDB_ERR_NO_SUCH_OBJECT;
+	size_t i, j;
+	struct ldb_dn *dn = NULL;
 	struct ldb_result *res;
 	TALLOC_CTX *tmp_ctx = talloc_new(state);
 	struct ldb_val zone_name_val = data_blob_string_const(zone);
@@ -1113,7 +1114,7 @@ _PUBLIC_ isc_result_t dlz_allnodes(const char *zone, void *dbdata,
 			break;
 		}
 	}
-	if (ret != LDB_SUCCESS) {
+	if (ret != LDB_SUCCESS || dn == NULL) {
 		talloc_free(tmp_ctx);
 		return ISC_R_NOTFOUND;
 	}
-- 
2.19.1


>From d23f9db92af0358b51cd11577bccf32b3f3c5f35 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Fri, 16 Nov 2018 18:25:58 +0100
Subject: [PATCH 02/12] s4:torture: Initialize pointers in libnetapi user test

Found by Undefined Sanitizer.

Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>
---
 source4/torture/libnetapi/libnetapi_user.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/source4/torture/libnetapi/libnetapi_user.c b/source4/torture/libnetapi/libnetapi_user.c
index e925725e5f0..134b4e8b9c0 100644
--- a/source4/torture/libnetapi/libnetapi_user.c
+++ b/source4/torture/libnetapi/libnetapi_user.c
@@ -271,8 +271,8 @@ static NET_API_STATUS test_netusergetgroups(struct torture_context *tctx,
 	uint8_t *buffer = NULL;
 	int i;
 
-	struct GROUP_USERS_INFO_0 *i0;
-	struct GROUP_USERS_INFO_1 *i1;
+	struct GROUP_USERS_INFO_0 *i0 = NULL;
+	struct GROUP_USERS_INFO_1 *i1 = NULL;
 
 	torture_comment(tctx, "Testing NetUserGetGroups level %d\n", level);
 
-- 
2.19.1


>From 5b503fb8582d22481de71f178af497934fa13061 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Fri, 16 Nov 2018 20:02:26 +0100
Subject: [PATCH 03/12] s3:tests: Initialize pointers with NULL in netdisplay
 test

Found by Undefined Sanitizer

Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>
---
 source3/lib/netapi/tests/netdisplay.c | 6 +++---
 source3/lib/netapi/tests/netuser.c    | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/source3/lib/netapi/tests/netdisplay.c b/source3/lib/netapi/tests/netdisplay.c
index 090792cec2f..d7967fa4150 100644
--- a/source3/lib/netapi/tests/netdisplay.c
+++ b/source3/lib/netapi/tests/netdisplay.c
@@ -39,9 +39,9 @@ static NET_API_STATUS test_netquerydisplayinformation(const char *hostname,
 	uint32_t idx = 0;
 	int i;
 
-	struct NET_DISPLAY_USER *user;
-	struct NET_DISPLAY_GROUP *group;
-	struct NET_DISPLAY_MACHINE *machine;
+	struct NET_DISPLAY_USER *user = NULL;
+	struct NET_DISPLAY_GROUP *group = NULL;
+	struct NET_DISPLAY_MACHINE *machine = NULL;
 
 	printf("testing NetQueryDisplayInformation level %d\n", level);
 
diff --git a/source3/lib/netapi/tests/netuser.c b/source3/lib/netapi/tests/netuser.c
index de5f0a102d9..ad2bb53f18c 100644
--- a/source3/lib/netapi/tests/netuser.c
+++ b/source3/lib/netapi/tests/netuser.c
@@ -265,8 +265,8 @@ static NET_API_STATUS test_netusergetgroups(const char *hostname,
 	uint8_t *buffer = NULL;
 	int i;
 
-	struct GROUP_USERS_INFO_0 *i0;
-	struct GROUP_USERS_INFO_1 *i1;
+	struct GROUP_USERS_INFO_0 *i0 = NULL;
+	struct GROUP_USERS_INFO_1 *i1 = NULL;
 
 	printf("testing NetUserGetGroups level %d\n", level);
 
-- 
2.19.1


>From 7fe0715c962aeba7f13de3eac6544756719cdf73 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Tue, 20 Nov 2018 10:37:01 +0100
Subject: [PATCH 04/12] lib:util: Always include unistd.h for setgroups

This is needed to pass configure checks

Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>
---
 lib/util/setid.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/util/setid.c b/lib/util/setid.c
index eb7511083f0..10014618def 100644
--- a/lib/util/setid.c
+++ b/lib/util/setid.c
@@ -34,6 +34,9 @@
 #include <sys/types.h>
 #include <errno.h>
 
+#if defined(HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
 #ifdef HAVE_SYS_PRIV_H
 #include <sys/priv.h>
 #endif
@@ -57,9 +60,6 @@ int samba_setgroups(size_t setlen, const gid_t *gidset);
 #endif
 
 #if defined(HAVE_LINUX_THREAD_CREDENTIALS)
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
 #if defined(HAVE_SYSCALL_H)
 #include <syscall.h>
 #endif
-- 
2.19.1


>From 1449d3e17749bd0ef63eed59e8c0ed165bad2b6d Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Tue, 20 Nov 2018 10:39:28 +0100
Subject: [PATCH 05/12] s3:lib: Do not redefine bool and use stdbool.h

Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>
---
 source3/lib/util_sec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source3/lib/util_sec.c b/source3/lib/util_sec.c
index 703c522d77b..94082697def 100644
--- a/source3/lib/util_sec.c
+++ b/source3/lib/util_sec.c
@@ -28,6 +28,7 @@
 #if defined(HAVE_UNISTD_H)
 #include <unistd.h>
 #endif
+#include <stdbool.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <sys/types.h>
@@ -42,7 +43,6 @@
 
 #define DEBUG(x, y) printf y
 #define smb_panic(x) exit(1)
-#define bool int
 #endif
 
 /* are we running as non-root? This is used by the regresison test code,
-- 
2.19.1


>From 6458924fcd17de71811f835c8ebe3007d2d01268 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 22 Nov 2018 09:22:38 +0100
Subject: [PATCH 06/12] lib:crypto: Fix undefined behavior in md4

runtime error: left shift of 145 by 24 places cannot be represented in type 'int'

Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>
---
 lib/crypto/md4.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/crypto/md4.c b/lib/crypto/md4.c
index 7eb6070cd44..831fe32ecb8 100644
--- a/lib/crypto/md4.c
+++ b/lib/crypto/md4.c
@@ -112,8 +112,10 @@ static void copy64(uint32_t *M, const uint8_t *in)
 	int i;
 
 	for (i=0;i<16;i++)
-		M[i] = (in[i*4+3]<<24) | (in[i*4+2]<<16) |
-			(in[i*4+1]<<8) | (in[i*4+0]<<0);
+		M[i] = ((uint32_t)in[i*4+3] << 24) |
+			((uint32_t)in[i*4+2] << 16) |
+			((uint32_t)in[i*4+1] << 8) |
+			((uint32_t)in[i*4+0] << 0);
 }
 
 static void copy4(uint8_t *out, uint32_t x)
-- 
2.19.1


>From 8e94df83bbb91f89090a7de8a4ba0bef63fa0120 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 22 Nov 2018 13:57:18 +0100
Subject: [PATCH 07/12] s3:lib: Fix undefined behavior in messages_dgm

source3/lib/messages_dgm.c:1290:7: runtime error: variable length array
bound evaluates to non-positive value 0

Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>
---
 source3/lib/messages_dgm.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/source3/lib/messages_dgm.c b/source3/lib/messages_dgm.c
index daaad9619e0..af12be8d82e 100644
--- a/source3/lib/messages_dgm.c
+++ b/source3/lib/messages_dgm.c
@@ -1249,6 +1249,7 @@ static void messaging_dgm_read_handler(struct tevent_context *ev,
 	size_t msgbufsize = msghdr_prep_recv_fds(NULL, NULL, 0, INT8_MAX);
 	uint8_t msgbuf[msgbufsize];
 	uint8_t buf[MESSAGING_DGM_FRAGMENT_LENGTH];
+	size_t num_fds;
 
 	messaging_dgm_validate(ctx);
 
@@ -1284,8 +1285,12 @@ static void messaging_dgm_read_handler(struct tevent_context *ev,
 		return;
 	}
 
-	{
-		size_t num_fds = msghdr_extract_fds(&msg, NULL, 0);
+	num_fds = msghdr_extract_fds(&msg, NULL, 0);
+	if (num_fds == 0) {
+		int fds[1];
+
+		messaging_dgm_recv(ctx, ev, buf, received, fds, 0);
+	} else {
 		size_t i;
 		int fds[num_fds];
 
@@ -1303,7 +1308,6 @@ static void messaging_dgm_read_handler(struct tevent_context *ev,
 
 		messaging_dgm_recv(ctx, ev, buf, received, fds, num_fds);
 	}
-
 }
 
 static int messaging_dgm_in_msg_destructor(struct messaging_dgm_in_msg *m)
-- 
2.19.1


>From cf9feaeef02e77d64404ef6e8505c1aeedfce7e4 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 22 Nov 2018 14:45:20 +0100
Subject: [PATCH 08/12] lib:util: Fix undefined behavior in asn1 parser

lib/util/asn1.c:969 runtime error: left shift of negative value -1

Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>
---
 lib/util/asn1.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/util/asn1.c b/lib/util/asn1.c
index d3b46aac857..60ddfa09bcf 100644
--- a/lib/util/asn1.c
+++ b/lib/util/asn1.c
@@ -953,21 +953,24 @@ bool asn1_read_ContextSimple(struct asn1_data *data, TALLOC_CTX *mem_ctx, uint8_
 bool asn1_read_implicit_Integer(struct asn1_data *data, int *i)
 {
 	uint8_t b;
+	uint32_t x = 0;
 	bool first_byte = true;
+
 	*i = 0;
 
 	while (!data->has_error && asn1_tag_remaining(data)>0) {
 		if (!asn1_read_uint8(data, &b)) return false;
 		if (first_byte) {
 			if (b & 0x80) {
-				/* Number is negative.
-				   Set i to -1 for sign extend. */
-				*i = -1;
+				/* Number is negative. */
+				x = (uint32_t)-1;
 			}
 			first_byte = false;
 		}
-		*i = (*i << 8) + b;
+		x = (x << 8) + b;
 	}
+	*i = (int)x;
+
 	return !data->has_error;
 }
 
-- 
2.19.1


>From 2d42ef69ee86489a4725a9385d60d471fab850be Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 22 Nov 2018 14:53:21 +0100
Subject: [PATCH 09/12] lib:util: Fix undefined behavior in idtree

lib/util/idtree.c:84 runtime error: left shift of 1 by 31 places cannot
be represented in type 'int'

Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>
---
 lib/util/idtree.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/util/idtree.c b/lib/util/idtree.c
index 72266a6a62c..d72ddfbc538 100644
--- a/lib/util/idtree.c
+++ b/lib/util/idtree.c
@@ -50,9 +50,9 @@
 #define MAX_LEVEL (MAX_ID_SHIFT + IDR_BITS - 1) / IDR_BITS
 #define IDR_FREE_MAX MAX_LEVEL + MAX_LEVEL
 
-#define set_bit(bit, v) (v) |= (1<<(bit))
-#define clear_bit(bit, v) (v) &= ~(1<<(bit))
-#define test_bit(bit, v) ((v) & (1<<(bit)))
+#define set_bit(bit, v) (v) |= (1U<<(bit))
+#define clear_bit(bit, v) (v) &= ~(1U<<(bit))
+#define test_bit(bit, v) ((v) & (1U<<(bit)))
 
 struct idr_layer {
 	uint32_t		 bitmap;
-- 
2.19.1


>From fa06a6d355d9d52dfff952388332c12a006a374e Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 22 Nov 2018 15:06:42 +0100
Subject: [PATCH 10/12] lib:util: Fix undefined behavior in bitmap.c

lib/util/bitmap.c:77: runtime error: left shift of 1 by 31 places cannot
be represented in type 'int'

Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>
---
 lib/util/bitmap.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/util/bitmap.c b/lib/util/bitmap.c
index 63963356f98..12cdfe4d16a 100644
--- a/lib/util/bitmap.c
+++ b/lib/util/bitmap.c
@@ -74,7 +74,7 @@ bool bitmap_set(struct bitmap *bm, unsigned i)
 		      i, bm->n));
 		return false;
 	}
-	bm->b[i/32] |= (1<<(i%32));
+	bm->b[i/32] |= (1U<<(i%32));
 	return true;
 }
 
@@ -88,7 +88,7 @@ bool bitmap_clear(struct bitmap *bm, unsigned i)
 		      i, bm->n));
 		return false;
 	}
-	bm->b[i/32] &= ~(1<<(i%32));
+	bm->b[i/32] &= ~(1U<<(i%32));
 	return true;
 }
 
@@ -98,7 +98,7 @@ query a bit in a bitmap
 bool bitmap_query(struct bitmap *bm, unsigned i)
 {
 	if (i >= bm->n) return false;
-	if (bm->b[i/32] & (1<<(i%32))) {
+	if (bm->b[i/32] & (1U<<(i%32))) {
 		return true;
 	}
 	return false;
-- 
2.19.1


>From d4c5376a95603adca2aab4939a9e10f3d87aaeed Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 22 Nov 2018 15:11:09 +0100
Subject: [PATCH 11/12] lib:compression: Fix undefined behavior in lzxpress

lib/compression/lzxpress.c:228 runtime error: store to misaligned
address 0x5631d53ca9fe for type 'uint32_t', which requires 4 byte
alignment

Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>
---
 lib/compression/lzxpress.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/compression/lzxpress.c b/lib/compression/lzxpress.c
index a4ded7e4555..024aba4c2ce 100644
--- a/lib/compression/lzxpress.c
+++ b/lib/compression/lzxpress.c
@@ -225,7 +225,7 @@ ssize_t lzxpress_compress(const uint8_t *uncompressed,
 		for (; (indic_bit % 32) != 0; indic_bit++)
 			indic |= 0 << (32 - ((indic_bit % 32) + 1));
 
-		*(uint32_t *)&compressed[compressed_pos] = 0;
+		SIVAL(compressed, compressed_pos, 0);
 		SIVAL(indic_pos, 0, indic);
 		compressed_pos += sizeof(uint32_t);
 	}
-- 
2.19.1


>From 9442563226f6b9c78db9d0c8306562b83641784a Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Thu, 22 Nov 2018 15:01:44 +0100
Subject: [PATCH 12/12] librpc:ndr: Fix undefined behavior in ndr.c

librpc/ndr/ndr.c:1430 runtime error: left shift of 1 by 31 places cannot
be represented in type 'int'

Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Gary Lockyer <gary at catalyst.net.nz>
---
 librpc/ndr/libndr.h | 66 ++++++++++++++++++++++-----------------------
 1 file changed, 33 insertions(+), 33 deletions(-)

diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h
index de93893be19..c31496fe1dc 100644
--- a/librpc/ndr/libndr.h
+++ b/librpc/ndr/libndr.h
@@ -118,21 +118,21 @@ struct ndr_print {
 	bool print_secrets;
 };
 
-#define LIBNDR_FLAG_BIGENDIAN  (1<<0)
-#define LIBNDR_FLAG_NOALIGN    (1<<1)
-
-#define LIBNDR_FLAG_STR_ASCII		(1<<2)
-#define LIBNDR_FLAG_STR_LEN4		(1<<3)
-#define LIBNDR_FLAG_STR_SIZE4		(1<<4)
-#define LIBNDR_FLAG_STR_NOTERM		(1<<5)
-#define LIBNDR_FLAG_STR_NULLTERM	(1<<6)
-#define LIBNDR_FLAG_STR_SIZE2		(1<<7)
-#define LIBNDR_FLAG_STR_BYTESIZE	(1<<8)
-#define LIBNDR_FLAG_STR_CONFORMANT	(1<<10)
-#define LIBNDR_FLAG_STR_CHARLEN		(1<<11)
-#define LIBNDR_FLAG_STR_UTF8		(1<<12)
-#define LIBNDR_FLAG_STR_RAW8		(1<<13)
-#define LIBNDR_STRING_FLAGS		(0 | \
+#define LIBNDR_FLAG_BIGENDIAN  (1U<<0)
+#define LIBNDR_FLAG_NOALIGN    (1U<<1)
+
+#define LIBNDR_FLAG_STR_ASCII		(1U<<2)
+#define LIBNDR_FLAG_STR_LEN4		(1U<<3)
+#define LIBNDR_FLAG_STR_SIZE4		(1U<<4)
+#define LIBNDR_FLAG_STR_NOTERM		(1U<<5)
+#define LIBNDR_FLAG_STR_NULLTERM	(1U<<6)
+#define LIBNDR_FLAG_STR_SIZE2		(1U<<7)
+#define LIBNDR_FLAG_STR_BYTESIZE	(1U<<8)
+#define LIBNDR_FLAG_STR_CONFORMANT	(1U<<10)
+#define LIBNDR_FLAG_STR_CHARLEN		(1U<<11)
+#define LIBNDR_FLAG_STR_UTF8		(1U<<12)
+#define LIBNDR_FLAG_STR_RAW8		(1U<<13)
+#define LIBNDR_STRING_FLAGS		(0U | \
 		LIBNDR_FLAG_STR_ASCII | \
 		LIBNDR_FLAG_STR_LEN4 | \
 		LIBNDR_FLAG_STR_SIZE4 | \
@@ -150,10 +150,10 @@ struct ndr_print {
  * Mark an element as SECRET, it won't be printed by
  * via ndr_print* unless NDR_PRINT_SECRETS is specified.
  */
-#define LIBNDR_FLAG_IS_SECRET		(1<<14)
+#define LIBNDR_FLAG_IS_SECRET		(1U<<14)
 
 /* Disable string token compression  */
-#define LIBNDR_FLAG_NO_COMPRESSION	(1<<15)
+#define LIBNDR_FLAG_NO_COMPRESSION	(1U<<15)
 
 /*
  * don't debug NDR_ERR_BUFSIZE failures,
@@ -161,25 +161,25 @@ struct ndr_print {
  *
  * return NDR_ERR_INCOMPLETE_BUFFER instead.
  */
-#define LIBNDR_FLAG_INCOMPLETE_BUFFER (1<<16)
+#define LIBNDR_FLAG_INCOMPLETE_BUFFER (1U<<16)
 
 /*
  * This lets ndr_pull_subcontext_end() return
  * NDR_ERR_UNREAD_BYTES.
  */
-#define LIBNDR_FLAG_SUBCONTEXT_NO_UNREAD_BYTES (1<<17)
+#define LIBNDR_FLAG_SUBCONTEXT_NO_UNREAD_BYTES (1U<<17)
 
 /* set if relative pointers should *not* be marshalled in reverse order */
-#define LIBNDR_FLAG_NO_RELATIVE_REVERSE	(1<<18)
+#define LIBNDR_FLAG_NO_RELATIVE_REVERSE	(1U<<18)
 
 /* set if relative pointers are marshalled in reverse order */
-#define LIBNDR_FLAG_RELATIVE_REVERSE	(1<<19)
+#define LIBNDR_FLAG_RELATIVE_REVERSE	(1U<<19)
 
-#define LIBNDR_FLAG_REF_ALLOC    (1<<20)
-#define LIBNDR_FLAG_REMAINING    (1<<21)
-#define LIBNDR_FLAG_ALIGN2       (1<<22)
-#define LIBNDR_FLAG_ALIGN4       (1<<23)
-#define LIBNDR_FLAG_ALIGN8       (1<<24)
+#define LIBNDR_FLAG_REF_ALLOC    (1U<<20)
+#define LIBNDR_FLAG_REMAINING    (1U<<21)
+#define LIBNDR_FLAG_ALIGN2       (1U<<22)
+#define LIBNDR_FLAG_ALIGN4       (1U<<23)
+#define LIBNDR_FLAG_ALIGN8       (1U<<24)
 
 #define LIBNDR_ALIGN_FLAGS ( 0        | \
 		LIBNDR_FLAG_NOALIGN   | \
@@ -189,22 +189,22 @@ struct ndr_print {
 		LIBNDR_FLAG_ALIGN8    | \
 		0)
 
-#define LIBNDR_PRINT_ARRAY_HEX   (1<<25)
-#define LIBNDR_PRINT_SET_VALUES  (1<<26)
+#define LIBNDR_PRINT_ARRAY_HEX   (1U<<25)
+#define LIBNDR_PRINT_SET_VALUES  (1U<<26)
 
 /* used to force a section of IDL to be little-endian */
-#define LIBNDR_FLAG_LITTLE_ENDIAN (1<<27)
+#define LIBNDR_FLAG_LITTLE_ENDIAN (1U<<27)
 
 /* used to check if alignment padding is zero */
-#define LIBNDR_FLAG_PAD_CHECK     (1<<28)
+#define LIBNDR_FLAG_PAD_CHECK     (1U<<28)
 
-#define LIBNDR_FLAG_NDR64         (1<<29)
+#define LIBNDR_FLAG_NDR64         (1U<<29)
 
 /* set if an object uuid will be present */
-#define LIBNDR_FLAG_OBJECT_PRESENT    (1<<30)
+#define LIBNDR_FLAG_OBJECT_PRESENT    (1U<<30)
 
 /* set to avoid recursion in ndr_size_*() calculation */
-#define LIBNDR_FLAG_NO_NDR_SIZE		(1<<31)
+#define LIBNDR_FLAG_NO_NDR_SIZE		(1U<<31)
 
 /* useful macro for debugging */
 #define NDR_PRINT_DEBUG(type, p) ndr_print_debug((ndr_print_fn_t)ndr_print_ ##type, #p, p)
-- 
2.19.1



More information about the samba-technical mailing list