Skip to content

Commit

Permalink
Merge pull request #3450 from BOINC/dpa_rss_feed
Browse files Browse the repository at this point in the history
Client: fix crashing bug in RSS feed fetch.
  • Loading branch information
TheAspens committed Feb 6, 2020
2 parents d591598 + 9e13857 commit c5695e4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 30 deletions.
50 changes: 26 additions & 24 deletions client/acct_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,10 @@ void ACCT_MGR_OP::handle_reply(int http_op_retval) {
} else {
// here we don't already have the project.
//
if (acct.detach || (acct.detach_when_done.present && acct.detach_when_done.value)) {
continue;
}

retval = check_string_signature2(
acct.url.c_str(), acct.url_signature, ami.signing_key, verified
);
Expand All @@ -756,32 +760,30 @@ void ACCT_MGR_OP::handle_reply(int http_op_retval) {
continue;
}

// Attach to it, unless the acct mgr is telling us to detach
// Attach to it
//
if (!acct.detach && !(acct.detach_when_done.present && acct.detach_when_done.value)) {
msg_printf(NULL, MSG_INFO,
"Attaching to %s", acct.url.c_str()
);
gstate.add_project(
acct.url.c_str(), acct.authenticator.c_str(), "", true
);
pp = gstate.lookup_project(acct.url.c_str());
if (pp) {
for (int j=0; j<MAX_RSC; j++) {
pp->no_rsc_ams[j] = acct.no_rsc[j];
}
if (acct.dont_request_more_work.present) {
pp->dont_request_more_work = acct.dont_request_more_work.value;
}
if (acct.suspend.present && acct.suspend.value) {
pp->suspend();
}
} else {
msg_printf(NULL, MSG_INTERNAL_ERROR,
"Failed to add project: %s",
acct.url.c_str()
);
msg_printf(NULL, MSG_INFO,
"Attaching to %s", acct.url.c_str()
);
gstate.add_project(
acct.url.c_str(), acct.authenticator.c_str(), "", true
);
pp = gstate.lookup_project(acct.url.c_str());
if (pp) {
for (int j=0; j<MAX_RSC; j++) {
pp->no_rsc_ams[j] = acct.no_rsc[j];
}
if (acct.dont_request_more_work.present) {
pp->dont_request_more_work = acct.dont_request_more_work.value;
}
if (acct.suspend.present && acct.suspend.value) {
pp->suspend();
}
} else {
msg_printf(NULL, MSG_INTERNAL_ERROR,
"Failed to add project: %s",
acct.url.c_str()
);
}
}
}
Expand Down
19 changes: 14 additions & 5 deletions client/cs_notice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,6 @@ void RSS_FEED::delete_files() {

RSS_FEED_OP::RSS_FEED_OP() {
error_num = BOINC_SUCCESS;
rfp = NULL;
gui_http = &gstate.gui_http;
}

Expand All @@ -785,7 +784,7 @@ bool RSS_FEED_OP::poll() {
if (gstate.now > rf.next_poll_time) {
rf.next_poll_time = gstate.now + rf.poll_interval;
rf.feed_file_name(file_name, sizeof(file_name));
rfp = &rf;
canceled = false;
if (log_flags.notice_debug) {
msg_printf(0, MSG_INFO,
"[notice] start fetch from %s", rf.url
Expand All @@ -806,7 +805,17 @@ void RSS_FEED_OP::handle_reply(int http_op_retval) {
char file_name[256];
int nitems;

if (!rfp) return; // op was canceled
if (canceled) return; // op was canceled

RSS_FEED* rfp = rss_feeds.lookup_url(gui_http->http_op.m_url);
if (!rfp) {
if (log_flags.notice_debug) {
msg_printf(0, MSG_INFO,
"[notice] RSS feed %s not found", rfp->url
);
}
return;
}

if (http_op_retval) {
if (log_flags.notice_debug) {
Expand Down Expand Up @@ -965,11 +974,11 @@ void RSS_FEEDS::update_feed_list() {
} else {
// cancel op if active
//
if (rss_feed_op.rfp == &(*iter)) {
if (!strcmp(rss_feed_op.gui_http->http_op.m_url, rf.url)) {
if (rss_feed_op.gui_http->is_busy()) {
gstate.http_ops->remove(&rss_feed_op.gui_http->http_op);
}
rss_feed_op.rfp = NULL;
rss_feed_op.canceled = true;
}
if (log_flags.notice_debug) {
msg_printf(0, MSG_INFO,
Expand Down
2 changes: 1 addition & 1 deletion client/cs_notice.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ struct RSS_FEED {

struct RSS_FEED_OP: public GUI_HTTP_OP {
int error_num;
RSS_FEED* rfp;
bool canceled;

RSS_FEED_OP();
virtual ~RSS_FEED_OP(){}
Expand Down

0 comments on commit c5695e4

Please sign in to comment.