mirror of
https://github.com/samba-team/samba.git
synced 2025-01-03 01:18:10 +03:00
ldb:dn_compare_base: avoid unlikely int overflow
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
This commit is contained in:
parent
4fa67dee9a
commit
d8b7712c53
@ -1062,13 +1062,15 @@ int ldb_dn_compare_base(struct ldb_dn *base, struct ldb_dn *dn)
|
|||||||
if (base->linearized && dn->linearized && dn->special == base->special) {
|
if (base->linearized && dn->linearized && dn->special == base->special) {
|
||||||
/* try with a normal compare first, if we are lucky
|
/* try with a normal compare first, if we are lucky
|
||||||
* we will avoid exploding and casefolding */
|
* we will avoid exploding and casefolding */
|
||||||
int dif;
|
size_t len_dn = strlen(dn->linearized);
|
||||||
dif = strlen(dn->linearized) - strlen(base->linearized);
|
size_t len_base = strlen(base->linearized);
|
||||||
if (dif < 0) {
|
|
||||||
return dif;
|
if (len_dn < len_base) {
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(base->linearized,
|
if (strcmp(base->linearized,
|
||||||
&dn->linearized[dif]) == 0) {
|
&dn->linearized[len_dn - len_base]) == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user