diff --git a/ChangeLog b/ChangeLog index 79108ad1..1906f923 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20347,3 +20347,7 @@ 'RD_SavePodcast()' calls to the rivwebcapi API. 2020-09-23 Fred Gleason * Added a 'RD_DeletePodcast()' call to the rivwebcapi API. +2020-09-23 Fred Gleason + * Fixed a regression in rdxport.cgi(1) that caused segfaults when + processing the 'PostRss' for feeds enclosed by one or more + superfeeds. diff --git a/web/rdxport/podcasts.cpp b/web/rdxport/podcasts.cpp index 6532fa6c..d31135d1 100644 --- a/web/rdxport/podcasts.cpp +++ b/web/rdxport/podcasts.cpp @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -354,41 +353,17 @@ void Xport::RemovePodcast() } -void Xport::PostRss() +bool Xport::PostRssElemental(RDFeed *feed,const QDateTime &now,QString *err_msg) { - int feed_id=0; - QString keyname; - QString destpath; - QString err_msg; - RDFeed *feed=NULL; - QString msg="OK"; - bool ret=false; - CURL *curl=NULL; CURLcode curl_err; char errstr[CURL_ERROR_SIZE]; - QDateTime now=QDateTime::currentDateTime(); + bool ret=false; - if(!xport_post->getValue("ID",&feed_id)) { - XmlExit("Missing ID",400,"podcasts.cpp",LINE_NUMBER); - } - feed=new RDFeed(feed_id,rda->config(),this); - if(!feed->exists()) { - XmlExit("No such feed",404,"podcasts.cpp",LINE_NUMBER); - } - keyname=feed->keyName(); - - if(((!rda->user()->editPodcast())|| - (!rda->user()->feedAuthorized(keyname)))&& - (!rda->user()->adminConfig())) { - delete feed; - XmlExit("No such feed",404,"podcasts.cpp",LINE_NUMBER); - } if((curl=curl_easy_init())==NULL) { XmlExit("unable to get CURL handle",500,"podcasts.cpp",LINE_NUMBER); } - - xport_curl_data=feed->rssXml(&err_msg,now).toUtf8(); + xport_curl_data=feed->rssXml(err_msg,now).toUtf8(); xport_curl_data_ptr=0; // @@ -435,12 +410,50 @@ void Xport::PostRss() break; default: - err_msg=errstr; + *err_msg+=errstr; ret=false; break; } curl_easy_cleanup(curl); + rda->syslog(LOG_DEBUG, + "posted RSS XML to \"%s\"",feed->feedUrl().toUtf8().constData()); + + return ret; +} + + +void Xport::PostRss() +{ + int feed_id=0; + QString keyname; + QString destpath; + QString err_msg; + RDFeed *feed=NULL; + QString msg="OK"; + bool ret=false; + + QDateTime now=QDateTime::currentDateTime(); + + if(!xport_post->getValue("ID",&feed_id)) { + XmlExit("Missing ID",400,"podcasts.cpp",LINE_NUMBER); + } + feed=new RDFeed(feed_id,rda->config(),this); + if(!feed->exists()) { + XmlExit("No such feed",404,"podcasts.cpp",LINE_NUMBER); + } + keyname=feed->keyName(); + + if(((!rda->user()->editPodcast())|| + (!rda->user()->feedAuthorized(keyname)))&& + (!rda->user()->adminConfig())) { + delete feed; + XmlExit("No such feed",404,"podcasts.cpp",LINE_NUMBER); + } + + ret=PostRssElemental(feed,now,&err_msg); + delete feed; + // // Update Enclosing Superfeeds // @@ -448,7 +461,7 @@ void Xport::PostRss() for(int i=0;iconfig(),this); - if(!feed->postXml()) { + if(!PostRssElemental(feed,now,&err_msg)) { err_msg+="\nRepost of XML failed"; } delete feed; @@ -462,9 +475,6 @@ void Xport::PostRss() printf("Status: 200\n\n"); printf("OK\n"); - rda->syslog(LOG_DEBUG, - "posted RSS XML to \"%s\"",feed->feedUrl().toUtf8().constData()); - Exit(0); } diff --git a/web/rdxport/rdxport.h b/web/rdxport/rdxport.h index c554632b..445b855d 100644 --- a/web/rdxport/rdxport.h +++ b/web/rdxport/rdxport.h @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -87,6 +88,7 @@ class Xport : public QObject void DeletePodcast(); void PostPodcast(); void RemovePodcast(); + bool PostRssElemental(RDFeed *feed,const QDateTime &now,QString *err_msg); void PostRss(); void RemoveRss(); void PostImage();