Skip to content

Commit 4eb7983

Browse files
tejrSven Panne
authored andcommitted
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.
1 parent fec5053 commit 4eb7983

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

livestatus/src/TableContacts.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ void TableContacts::addColumns(Table *table, const std::string &prefix,
7171
"The time period in which the contact will be notified about service problems",
7272
indirect_offset, -1, -1,
7373
DANGEROUS_OFFSETOF(contact, service_notification_period)));
74-
for (int i = 1; i <= MAX_CONTACT_ADDRESSES; ++i) {
75-
std::string b = "address" + std::to_string(i);
74+
for (int i = 0; i < MAX_CONTACT_ADDRESSES; ++i) {
75+
std::string b = "address" + std::to_string(i + 1);
7676
table->addColumn(std::make_unique<OffsetStringColumn>(
7777
prefix + b, "The additional field " + b, indirect_offset, -1, -1,
7878
DANGEROUS_OFFSETOF(contact, address[i])));

0 commit comments

Comments
 (0)