diff options
author | Andrew Tridgell <tridge@samba.org> | 2006-08-22 23:12:22 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:16:32 -0500 |
commit | 5b9633e40d3230ff6e0e64879eefddfe7e9e8516 (patch) | |
tree | 916fc13148104e93b18fc298210a840b88fa8ed7 /source4/lib/ldb | |
parent | 2fe39a82bf3fcd7d9c214151bfaa570f617630f0 (diff) | |
download | samba-5b9633e40d3230ff6e0e64879eefddfe7e9e8516.tar.gz samba-5b9633e40d3230ff6e0e64879eefddfe7e9e8516.tar.bz2 samba-5b9633e40d3230ff6e0e64879eefddfe7e9e8516.zip |
r17724: don't rely on strnlen() as MacOSX 10.4 doesn't have it. Someday apple
will realise that buffer overflows are bad ....
(This used to be commit 0a6968b71b3cc492edfc3d46bd7e0c66c7ed8557)
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r-- | source4/lib/ldb/ldb_tdb/ldb_pack.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_pack.c b/source4/lib/ldb/ldb_tdb/ldb_pack.c index c6edf663ae..b2a004b99f 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_pack.c +++ b/source4/lib/ldb/ldb_tdb/ldb_pack.c @@ -155,6 +155,16 @@ int ltdb_pack_data(struct ldb_module *module, return 0; } +/* using this means we can compile standalone on broken systems like + MacOSX 10.4 */ +static size_t ldb_strnlen(const char *s, size_t n) +{ + int i; + for (i=0; s[i] && i<n; i++) + /* noop */ ; + return i; +} + /* unpack a ldb message from a linear buffer in TDB_DATA @@ -191,7 +201,7 @@ int ltdb_unpack_data(struct ldb_module *module, break; case LTDB_PACKING_FORMAT: - len = strnlen((char *)p, remaining); + len = ldb_strnlen((char *)p, remaining); if (len == remaining) { errno = EIO; goto failed; @@ -234,7 +244,7 @@ int ltdb_unpack_data(struct ldb_module *module, errno = EIO; goto failed; } - len = strnlen((char *)p, remaining-6); + len = ldb_strnlen((char *)p, remaining-6); if (len == remaining-6) { errno = EIO; goto failed; |