summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2008-04-23 14:55:51 +0200
committerKarolin Seeger <kseeger@samba.org>2008-05-05 13:56:16 +0200
commitb3161ef66b4ba939353e53b9b79a0bc01e53d369 (patch)
treed80bc4f40239077dc9306425ddf269c5f2dc14a7
parent937f7a2873573c1547b1e610c86b467b5f842e1d (diff)
downloadsamba-b3161ef66b4ba939353e53b9b79a0bc01e53d369.tar.gz
samba-b3161ef66b4ba939353e53b9b79a0bc01e53d369.tar.xz
samba-b3161ef66b4ba939353e53b9b79a0bc01e53d369.zip
winbindd_cache: simplify logic in new key length check for UA keys.
This reduces indentation by combining common code paths, and wraps long lines. Holger: sorry, I could not resist. I think it is much easier to understand what is going on when we only have one check and determine the max allowed key length in advance. Michael (cherry picked from commit e489f3d988feafe35b486b31a9e60c2399e6a6e7)
-rw-r--r--source/winbindd/winbindd_cache.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/source/winbindd/winbindd_cache.c b/source/winbindd/winbindd_cache.c
index 5abd207e793..020338165ba 100644
--- a/source/winbindd/winbindd_cache.c
+++ b/source/winbindd/winbindd_cache.c
@@ -3348,23 +3348,18 @@ struct key_val_struct {
static int cache_traverse_validate_fn(TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, void *state)
{
int i;
+ unsigned int max_key_len = 1024;
struct tdb_validation_status *v_state = (struct tdb_validation_status *)state;
/* Paranoia check. */
- if (kbuf.dsize > 1024) {
- if (strncmp("UA/", (const char *)kbuf.dptr, 3) == 0) {
- unsigned int max_key_len = 1024*1024;
- if (kbuf.dsize > max_key_len) {
- DEBUG(0,("cache_traverse_validate_fn: UA key to large (%u) > (%u)\n\n",
- (unsigned int)kbuf.dsize, (unsigned int)max_key_len ));
- return 1;
- }
- } else {
-
- DEBUG(0,("cache_traverse_validate_fn: key length too large (%u) > 1024\n\n",
- (unsigned int)kbuf.dsize ));
- return 1;
- }
+ if (strncmp("UA/", (const char *)kbuf.dptr, 3) == 0) {
+ max_key_len = 1024 * 1024;
+ }
+ if (kbuf.dsize > max_key_len) {
+ DEBUG(0, ("cache_traverse_validate_fn: key length too large: "
+ "(%u) > (%u)\n\n",
+ (unsigned int)kbuf.dsize, (unsigned int)max_key_len));
+ return 1;
}
for (i = 0; key_val[i].keyname; i++) {