Skip to content

Commit

Permalink
ldb_tdb: Use memcmp rather than strncmp() in ltdb_key_is_record(), re…
Browse files Browse the repository at this point in the history
…_key() and re_index()

Signed-off-by: Andrew Bartlett <[email protected]>
Reviewed-by: Douglas Bagnall <[email protected]>
  • Loading branch information
abartlet committed Sep 7, 2017
1 parent fec666b commit 3ce80cf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/ldb/ldb_tdb/ldb_index.c
Original file line number Diff line number Diff line change
Expand Up @@ -1578,7 +1578,7 @@ static int re_key(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *st
ldb = ldb_module_get_ctx(module);

if (key.dsize > 4 &&
strncmp((char *)key.dptr, "DN=@", 4) == 0) {
memcmp(key.dptr, "DN=@", 4) == 0) {
return 0;
}

Expand Down Expand Up @@ -1647,7 +1647,7 @@ static int re_index(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *
ldb = ldb_module_get_ctx(module);

if (key.dsize > 4 &&
strncmp((char *)key.dptr, "DN=@", 4) == 0) {
memcmp(key.dptr, "DN=@", 4) == 0) {
return 0;
}

Expand Down
6 changes: 3 additions & 3 deletions lib/ldb/ldb_tdb/ldb_tdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,19 @@ bool ltdb_key_is_record(TDB_DATA key)
return false;
}

if (strncmp((char *)key.dptr, "DN=", 3) == 0) {
if (memcmp(key.dptr, "DN=", 3) == 0) {
return true;
}

if (strncmp((char *)key.dptr, "ID=", 3) == 0) {
if (memcmp(key.dptr, "ID=", 3) == 0) {
return true;
}

if (key.dsize < 6) {
return false;
}

if (strncmp((char *)key.dptr, "GUID=", 5) == 0) {
if (memcmp(key.dptr, "GUID=", 5) == 0) {
return true;
}

Expand Down

0 comments on commit 3ce80cf

Please sign in to comment.