[Date Prev][Date Next]
[Chronological]
[Thread]
[Top]
Re: core dumped on create new entries with UTF/base64 dn (ITS#2632)
Thanks for investigating this. It looks like the binary file
encoding/decoding code needs to be revamped significantly to
either be truly portable (use BER or some other well defined
rules for encoding) or use a platform specific format.
I note that switch the code to use ac_uint4 is not all that
portable as ac_unit4 is not defined on all platforms... and
the union/struct padding blows most of the portability out
the window.
Kurt
At 10:36 PM 7/7/2003, tiamat@komi.mts.ru wrote:
>>The back trace you provided shows a trashed stack but no
>>indication of how that occurred. You'll likely will need
>>to walk through the code in a debugger to determine how
>>that occurred.
>
>i386 and sparc64 has different size of type long:
>
>i386 has sizeof(long) = 4
>sparc64 has sizeof(long) = 8
>
>Many data types, (for example libraries/liblunicode/ucdata/ucdata.c) defined
>as unsigned long:
>
>static unsigned long *_ucdcmp_nodes;
>
>and used as unsigned int:
>
>#define endian_long(cc) ((((cc) & 0xff) << 24)|((((cc) >> 8) & 0xff) <<
>16)|\
> ((((cc) >> 16) & 0xff) << 8)|((cc) >> 24))
>
>_ucdcmp_nodes[i] = endian_long(_ucdcmp_nodes[i]);
>
>or
>
>typedef struct {
> ac_uint2 bom;
> ac_uint2 cnt;
> union {
> ac_uint4 bytes;
> ac_uint2 len[2];
> } size;
>} _ucheader_t;
>
>_ucheader_t hdr;
>
>hdr.size.bytes = endian_long(hdr.size.bytes);
>_ucdcmp_nodes = (unsigned long *) malloc(hdr.size.bytes);
>
>why you do not use ac_uint4 instead of unsigned long?
>
>---
>/var/tmp/mnt/devel/ncvs/ports/mts/openldap21/work/openldap-2.1.22/libraries/
>liblunicode/ucdata/ucdata.c Sun Feb 9 02:50:39 2003
>+++ ucdata.c Tue Jul 8 09:24:40 2003
>@@ -110,7 +110,7 @@
>
> static unsigned long _ucprop_size;
> static unsigned short *_ucprop_offsets;
>-static unsigned long *_ucprop_ranges;
>+static ac_uint4 *_ucprop_ranges;
>
> /*
> * Return -1 on error, 0 if okay
>@@ -171,7 +171,7 @@
> if ((size = ((hdr.cnt + 1) * sizeof(unsigned short))) & 3)
> size += 4 - (size & 3);
> size >>= 1;
>- _ucprop_ranges = (unsigned long *) (_ucprop_offsets + size);
>+ _ucprop_ranges = (ac_uint4 *) (_ucprop_offsets + size);
>
> /*
> * Load the offset array.
>@@ -191,7 +191,7 @@
> * Load the ranges. The number of elements is in the last array
>position
> * of the offsets.
> */
>- fread((char *) _ucprop_ranges, sizeof(unsigned long),
>+ fread((char *) _ucprop_ranges, sizeof(ac_uint4),
> _ucprop_offsets[_ucprop_size], in);
>
> fclose(in);
>@@ -291,7 +291,7 @@
>
> static unsigned long _uccase_size;
> static unsigned short _uccase_len[2];
>-static unsigned long *_uccase_map;
>+static ac_uint4 *_uccase_map;
>
> /*
> * Return -1 on error, 0 if okay
>@@ -336,13 +336,13 @@
> _uccase_len[0] = hdr.size.len[0] * 3;
> _uccase_len[1] = hdr.size.len[1] * 3;
>
>- _uccase_map = (unsigned long *)
>- malloc(_uccase_size * sizeof(unsigned long));
>+ _uccase_map = (ac_uint4 *)
>+ malloc(_uccase_size * sizeof(ac_uint4));
>
> /*
> * Load the case mapping table.
> */
>- fread((char *) _uccase_map, sizeof(unsigned long), _uccase_size, in);
>+ fread((char *) _uccase_map, sizeof(ac_uint4), _uccase_size, in);
>
> /*
> * Do an endian swap if necessary.
>@@ -482,7 +482,7 @@
>
>**************************************************************************/
>
> static unsigned long _uccomp_size;
>-static unsigned long *_uccomp_data;
>+static ac_uint4 *_uccomp_data;
>
> /*
> * Return -1 on error, 0 if okay
>@@ -519,13 +519,13 @@
> }
>
> _uccomp_size = hdr.cnt;
>- _uccomp_data = (unsigned long *) malloc(hdr.size.bytes);
>+ _uccomp_data = (ac_uint4 *) malloc(hdr.size.bytes);
>
> /*
> * Read the composition data in.
> */
>- size = hdr.size.bytes / sizeof(unsigned long);
>- fread((char *) _uccomp_data, sizeof(unsigned long), size, in);
>+ size = hdr.size.bytes / sizeof(ac_uint4);
>+ fread((char *) _uccomp_data, sizeof(ac_uint4), size, in);
>
> /*
> * Do an endian swap if necessary.
>@@ -672,12 +672,12 @@
>
>**************************************************************************/
>
> static unsigned long _ucdcmp_size;
>-static unsigned long *_ucdcmp_nodes;
>-static unsigned long *_ucdcmp_decomp;
>+static ac_uint4 *_ucdcmp_nodes;
>+static ac_uint4 *_ucdcmp_decomp;
>
> static unsigned long _uckdcmp_size;
>-static unsigned long *_uckdcmp_nodes;
>-static unsigned long *_uckdcmp_decomp;
>+static ac_uint4 *_uckdcmp_nodes;
>+static ac_uint4 *_uckdcmp_decomp;
>
> /*
> * Return -1 on error, 0 if okay
>@@ -714,14 +714,14 @@
> }
>
> _ucdcmp_size = hdr.cnt << 1;
>- _ucdcmp_nodes = (unsigned long *) malloc(hdr.size.bytes);
>+ _ucdcmp_nodes = (ac_uint4 *) malloc(hdr.size.bytes);
> _ucdcmp_decomp = _ucdcmp_nodes + (_ucdcmp_size + 1);
>
> /*
> * Read the decomposition data in.
> */
>- size = hdr.size.bytes / sizeof(unsigned long);
>- fread((char *) _ucdcmp_nodes, sizeof(unsigned long), size, in);
>+ size = hdr.size.bytes / sizeof(ac_uint4);
>+ fread((char *) _ucdcmp_nodes, sizeof(ac_uint4), size, in);
>
> /*
> * Do an endian swap if necessary.
>@@ -769,14 +769,14 @@
> }
>
> _uckdcmp_size = hdr.cnt << 1;
>- _uckdcmp_nodes = (unsigned long *) malloc(hdr.size.bytes);
>+ _uckdcmp_nodes = (ac_uint4 *) malloc(hdr.size.bytes);
> _uckdcmp_decomp = _uckdcmp_nodes + (_uckdcmp_size + 1);
>
> /*
> * Read the decomposition data in.
> */
>- size = hdr.size.bytes / sizeof(unsigned long);
>- fread((char *) _uckdcmp_nodes, sizeof(unsigned long), size, in);
>+ size = hdr.size.bytes / sizeof(ac_uint4);
>+ fread((char *) _uckdcmp_nodes, sizeof(ac_uint4), size, in);
>
> /*
> * Do an endian swap if necessary.
>@@ -987,7 +987,7 @@
>
>**************************************************************************/
>
> static unsigned long _uccmcl_size;
>-static unsigned long *_uccmcl_nodes;
>+static ac_uint4 *_uccmcl_nodes;
>
> /*
> * Return -1 on error, 0 if okay
>@@ -1024,12 +1024,12 @@
> }
>
> _uccmcl_size = hdr.cnt * 3;
>- _uccmcl_nodes = (unsigned long *) malloc(hdr.size.bytes);
>+ _uccmcl_nodes = (ac_uint4 *) malloc(hdr.size.bytes);
>
> /*
> * Read the combining classes in.
> */
>- fread((char *) _uccmcl_nodes, sizeof(unsigned long), _uccmcl_size, in);
>+ fread((char *) _uccmcl_nodes, sizeof(ac_uint4), _uccmcl_size, in);
>
> /*
> * Do an endian swap if necessary.
>@@ -1079,7 +1079,7 @@
> *
>
>**************************************************************************/
>
>-static unsigned long *_ucnum_nodes;
>+static ac_uint4 *_ucnum_nodes;
> static unsigned long _ucnum_size;
> static short *_ucnum_vals;
>
>@@ -1137,7 +1137,7 @@
> * Determine the number of values that have to be adjusted.
> */
> size = (hdr.size.bytes -
>- (_ucnum_size * (sizeof(unsigned long) << 1))) /
>+ (_ucnum_size * (sizeof(ac_uint4) << 1))) /
> sizeof(short);
>
> for (i = 0; i < size; i++)
>
>Thanks!