Skip to content

Commit 6487ece

Browse files
committedDec 28, 2024·
mysql_adaptor: let mbop_userlist skip over users with no PR_DISPLAY_TYPE_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
1 parent bc5fefb commit 6487ece

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed
 

‎exch/mysql_adaptor/sql2.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -731,14 +731,18 @@ int mysql_adaptor_mbop_userlist(std::vector<sql_user> &out) try
731731
if (result == nullptr)
732732
return ENOMEM;
733733
std::vector<sql_user> gv(result.num_rows());
734-
for (size_t i = 0; i < gv.size(); ++i) {
734+
for (size_t i = 0; i < gv.size(); ) {
735735
auto row = result.fetch_row();
736736
gv[i].id = strtoul(row[0], nullptr, 0);
737737
gv[i].username = row[1];
738738
gv[i].addr_status = strtoul(row[2], nullptr, 0);
739739
gv[i].maildir = znul(row[3]);
740-
gv[i].dtypx = static_cast<enum display_type>(strtoul(row[4], nullptr, 0));
741-
gv[i].homeserver = znul(row[5]);
740+
if (row[4] == nullptr) {
741+
gv.pop_back();
742+
continue;
743+
}
744+
gv[i].dtypx = static_cast<enum display_type>(strtoul(znul(row[4]), nullptr, 0));
745+
gv[i++].homeserver = znul(row[5]);
742746
}
743747
out = std::move(gv);
744748
return 0;

0 commit comments

Comments
 (0)
Please sign in to comment.