overflow protection

main
rhetorica 2026-01-05 14:25:17 -08:00
parent 897cb674d9
commit 133e9ec8d2
1 changed files with 8 additions and 2 deletions

View File

@ -38,7 +38,7 @@
*/
#include <ARES/a>
#define CLIENT_VERSION "0.2.3"
#define CLIENT_VERSION "0.2.4"
#define CLIENT_VERSION_TAGS "alpha"
list feeds;
@ -171,7 +171,10 @@ main(integer src, integer n, string m, key outs, key ins, key user) {
string headline;
pipe_read(ins, headline);
if(~strpos(headline, "<rss") || ~strpos(headline, "<feed")) {
if(substr(headline, 0, 2) == "<!") {
headline = "(server returned HTML)";
print(avatar, avatar, PROGRAM_NAME + ": Failed to fetch headline from " + url);
} else if(~strpos(headline, "<rss") || ~strpos(headline, "<feed")) {
string item;
integer item_start = strpos(headline, "<item");
@ -229,6 +232,9 @@ main(integer src, integer n, string m, key outs, key ins, key user) {
}
}
if(strlen(headline) > 200) // beyond the pale of what the UI can display
headline = substr(headline, 0, 199);
if(headline != gets(headlines, offset)) {
headlines = alter(headlines, [headline], offset, offset);
setdbl("news", ["headline"], jsarray(headlines));