Skip to content

Commit 2387fe6

Browse files
tiranencukou
authored andcommitted
Use correct types for BER en/decode
ber_scanf() and ber_printf() "i" format uses ber_int_t. lber_types.h defines the type as int but Python code assumes the type to be unsigned long: #define LBER_INT_T int typedef LBER_INT_T ber_int_t; The code was working fine on little endian machines but broke on big endian machines. ber_int_t is now correctly parsed as signed int. #162 Fixes: #161 Signed-off-by: Christian Heimes <cheimes@redhat.com>
1 parent ad46c11 commit 2387fe6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Modules/ldapcontrol.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ encode_rfc2696(PyObject *self, PyObject *args)
242242
BerElement *ber = 0;
243243
struct berval cookie, *ctrl_val;
244244
Py_ssize_t cookie_len;
245-
unsigned long size;
245+
int size = 0; /* ber_int_t is int */
246246
ber_tag_t tag;
247247

248248
if (!PyArg_ParseTuple(args, "is#:encode_page_control", &size,
@@ -300,7 +300,7 @@ decode_rfc2696(PyObject *self, PyObject *args)
300300
struct berval ldctl_value;
301301
ber_tag_t tag;
302302
struct berval *cookiep;
303-
unsigned long count = 0;
303+
int count = 0; /* ber_int_t is int */
304304
Py_ssize_t ldctl_value_len;
305305

306306
if (!PyArg_ParseTuple(args, "s#:decode_page_control",
@@ -320,7 +320,7 @@ decode_rfc2696(PyObject *self, PyObject *args)
320320
goto endlbl;
321321
}
322322

323-
res = Py_BuildValue("(kO&)", count, LDAPberval_to_object, cookiep);
323+
res = Py_BuildValue("(iO&)", count, LDAPberval_to_object, cookiep);
324324
ber_bvfree(cookiep);
325325

326326
endlbl:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy