Skip to content

Commit

Permalink
mysql_adaptor: let mbop_userlist skip over users with no PR_DISPLAY_T…
Browse files Browse the repository at this point in the history
…YPE_EX

==82291==ERROR: AddressSanitizer: SEGV on unknown address 0x0
==82291==The signal is caused by a READ memory access.
==82291==Hint: address points to the zero page.
    f0 __GI_____strtoul_l_internal ../stdlib/strtol_l.c:304
    f1 mysql_adaptor_mbop_userlist(std::vector<sql_user, std::allocator<sql_user> >&) exch/mysql_adaptor/sql2.cpp:740
    f2 main tools/mbop_main.cpp:735

References: GXH-119
  • Loading branch information
jengelh committed Dec 28, 2024
1 parent bc5fefb commit 6487ece
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions exch/mysql_adaptor/sql2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -731,14 +731,18 @@ int mysql_adaptor_mbop_userlist(std::vector<sql_user> &out) try
if (result == nullptr)
return ENOMEM;
std::vector<sql_user> gv(result.num_rows());
for (size_t i = 0; i < gv.size(); ++i) {
for (size_t i = 0; i < gv.size(); ) {
auto row = result.fetch_row();
gv[i].id = strtoul(row[0], nullptr, 0);
gv[i].username = row[1];
gv[i].addr_status = strtoul(row[2], nullptr, 0);
gv[i].maildir = znul(row[3]);
gv[i].dtypx = static_cast<enum display_type>(strtoul(row[4], nullptr, 0));
gv[i].homeserver = znul(row[5]);
if (row[4] == nullptr) {
gv.pop_back();
continue;
}
gv[i].dtypx = static_cast<enum display_type>(strtoul(znul(row[4]), nullptr, 0));
gv[i++].homeserver = znul(row[5]);
}
out = std::move(gv);
return 0;
Expand Down

0 comments on commit 6487ece

Please sign in to comment.