diff options
Diffstat (limited to 'lib/ldb/common/ldb_pack.c')
-rw-r--r-- | lib/ldb/common/ldb_pack.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/ldb/common/ldb_pack.c b/lib/ldb/common/ldb_pack.c index 5360a36cccc..e59c542fc5b 100644 --- a/lib/ldb/common/ldb_pack.c +++ b/lib/ldb/common/ldb_pack.c @@ -33,12 +33,6 @@ #include "ldb_private.h" -/* change this if the data format ever changes */ -#define LDB_PACKING_FORMAT 0x26011967 - -/* old packing formats */ -#define LDB_PACKING_FORMAT_NODN 0x26011966 - /* use a portable integer format */ static void put_uint32(uint8_t *p, int ofs, unsigned int val) { @@ -195,7 +189,7 @@ int ldb_unpack_data_flags(struct ldb_context *ldb, size_t remaining; size_t dn_len; unsigned int i, j; - unsigned format; + uint32_t format; unsigned int nelem = 0; size_t len; struct ldb_val *ldb_val_single_array = NULL; @@ -208,7 +202,10 @@ int ldb_unpack_data_flags(struct ldb_context *ldb, goto failed; } - format = pull_uint32(p, 0); + if (ldb_unpack_get_format(data, &format) != LDB_SUCCESS) { + errno = EIO; + goto failed; + } message->num_elements = pull_uint32(p, 4); p += 8; @@ -402,6 +399,16 @@ failed: return -1; } +int ldb_unpack_get_format(const struct ldb_val *data, + uint32_t *pack_format_version) +{ + if (data->length < 4) { + return LDB_ERR_OPERATIONS_ERROR; + } + *pack_format_version = pull_uint32(data->data, 0); + return LDB_SUCCESS; +} + /* * Unpack a ldb message from a linear buffer in ldb_val * |