diff options
| author | Nalin Dahyabhai <nalin@redhat.com> | 2012-01-24 13:45:50 -0500 |
|---|---|---|
| committer | Nalin Dahyabhai <nalin@redhat.com> | 2012-01-24 13:45:50 -0500 |
| commit | fc31cb50a21a7cf851f367e75ae3282b01b9d16c (patch) | |
| tree | 040eb86af4d3db159d9ff897f784ec06df446b1f /src | |
| parent | 0c70b2c9fda067d4fa3ddc160e77c4275b647a62 (diff) | |
- take steps to avoid making yp_first/yp_next clients loop indefinitely when a single LDAP entry produces multiple copies of the same NIS key for a given map
Diffstat (limited to 'src')
| -rw-r--r-- | src/map.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -557,7 +557,7 @@ map_next(struct plugin_state *state, { struct map *map; struct map_entry *entry; - unsigned int key_index; + unsigned int key_index, last_instance; *next_key_len = 0; *next_key = NULL; *next_value_len = 0; @@ -571,6 +571,18 @@ map_next(struct plugin_state *state, if (entry == NULL) { return FALSE; } + last_instance = entry->n_keys - 1; + while (last_instance > key_index) { + if ((prev_len != entry->key_len[last_instance]) || + (memcmp(prev, entry->keys[last_instance], prev_len) != 0)) { + last_instance--; + } else { + break; + } + } + if (last_instance > key_index) { + key_index = last_instance; + } if (key_index + 1 < entry->n_keys) { *next_key_len = entry->key_len[key_index + 1]; *next_key = entry->keys[key_index + 1]; |
