Skip to content


Browse files Browse the repository at this point in the history
Correct off-by-one error in address table indices
Commit c0fa444 changed the indices of this for loop from being
0-based to 1-based, but did not update the index into the contact
object's "address" member accordingly to be zero-based. This meant that
the value defined in the "address1" attribute of contact objects was
made available in the "address2" attribute in LiveStatus query results,
and "address2" in "address3" etc, per the definitions for the contact
object in in nagios/objects.h and nagios4/objects.h.

This change restores the zero base case for the loop index, but sets
both the 1-based directive name and the 0-based array index correctly,
restoring the expected behaviour.
  • Loading branch information
tejr authored and Sven Panne committed Jan 29, 2018
1 parent fec5053 commit 4eb7983
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions livestatus/src/
Expand Up @@ -71,8 +71,8 @@ void TableContacts::addColumns(Table *table, const std::string &prefix,
"The time period in which the contact will be notified about service problems",
indirect_offset, -1, -1,
DANGEROUS_OFFSETOF(contact, service_notification_period)));
for (int i = 1; i <= MAX_CONTACT_ADDRESSES; ++i) {
std::string b = "address" + std::to_string(i);
for (int i = 0; i < MAX_CONTACT_ADDRESSES; ++i) {
std::string b = "address" + std::to_string(i + 1);
prefix + b, "The additional field " + b, indirect_offset, -1, -1,
DANGEROUS_OFFSETOF(contact, address[i])));
Expand Down

0 comments on commit 4eb7983

Please sign in to comment.