Skip to content

Commit af366b1

Browse files
committed
Fix RSS notifier.
1 parent 88516bf commit af366b1

2 files changed

Lines changed: 27 additions & 7 deletions

File tree

notifier/rss.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/*
22
* RSS notifier for CUPS.
33
*
4-
* Copyright © 2020-2024 by OpenPrinting.
5-
* Copyright 2007-2015 by Apple Inc.
6-
* Copyright 2007 by Easy Software Products.
4+
* Copyright © 2020-2026 by OpenPrinting.
5+
* Copyright © 2007-2015 by Apple Inc.
6+
* Copyright © 2007 by Easy Software Products.
77
*
8-
* Licensed under Apache License v2.0. See the file "LICENSE" for more information.
8+
* Licensed under Apache License v2.0. See the file "LICENSE" for more
9+
* information.
910
*/
1011

1112
/*
@@ -80,6 +81,7 @@ main(int argc, /* I - Number of command-line arguments */
8081
http_status_t status; /* HTTP GET/PUT status code */
8182
char filename[1024], /* Local filename */
8283
newname[1024]; /* filename.N */
84+
struct stat fileinfo; /* Local file information */
8385
cups_lang_t *language; /* Language information */
8486
ipp_attribute_t *printer_up_time, /* Timestamp on event */
8587
*notify_sequence_number,/* Sequence number */
@@ -111,9 +113,9 @@ main(int argc, /* I - Number of command-line arguments */
111113

112114
if (httpSeparateURI(HTTP_URI_CODING_ALL, argv[1], scheme, sizeof(scheme),
113115
username, sizeof(username), host, sizeof(host), &port,
114-
resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
116+
resource, sizeof(resource)) < HTTP_URI_STATUS_OK || strstr(resource, "../") != NULL)
115117
{
116-
fprintf(stderr, "ERROR: Bad RSS URI \"%s\"!\n", argv[1]);
118+
fprintf(stderr, "ERROR: Bad RSS URI \"%s\".\n", argv[1]);
117119
return (1);
118120
}
119121

@@ -209,6 +211,12 @@ main(int argc, /* I - Number of command-line arguments */
209211
snprintf(filename, sizeof(filename), "%s/rss%s", cachedir, resource);
210212
snprintf(newname, sizeof(newname), "%s.N", filename);
211213

214+
if (!lstat(filename, &fileinfo) && !S_ISREG(fileinfo.st_mode))
215+
{
216+
fprintf(stderr, "ERROR: Local RSS path \"%s\" is not a file.\n", filename);
217+
return (1);
218+
}
219+
212220
httpAssembleURIf(HTTP_URI_CODING_ALL, baseurl, sizeof(baseurl), "http",
213221
NULL, server_name, atoi(server_port), "/rss%s", resource);
214222
}

scheduler/ipp.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* IPP routines for the CUPS scheduler.
33
*
4-
* Copyright © 2020-2025 by OpenPrinting
4+
* Copyright © 2020-2026 by OpenPrinting
55
* Copyright © 2007-2021 by Apple Inc.
66
* Copyright © 1997-2007 by Easy Software Products, all rights reserved.
77
*
@@ -1931,6 +1931,12 @@ add_job_subscriptions(
19311931
"notify-status-code", IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES);
19321932
return;
19331933
}
1934+
else if (!strcmp(scheme, "rss") && strstr(resource, "../") != NULL)
1935+
{
1936+
send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE, _("Bad notify-recipient-uri URI \"%s\"."), recipient);
1937+
ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_ENUM, "notify-status-code", IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES);
1938+
return;
1939+
}
19341940
}
19351941
else if (!strcmp(attr->name, "notify-pull-method") &&
19361942
attr->value_tag == IPP_TAG_KEYWORD)
@@ -5906,6 +5912,12 @@ create_subscriptions(
59065912
"notify-status-code", IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES);
59075913
return;
59085914
}
5915+
else if (!strcmp(scheme, "rss") && strstr(resource, "../") != NULL)
5916+
{
5917+
send_ipp_status(con, IPP_STATUS_ERROR_NOT_POSSIBLE, _("Bad notify-recipient-uri URI \"%s\"."), recipient);
5918+
ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_ENUM, "notify-status-code", IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES);
5919+
return;
5920+
}
59095921
}
59105922
else if (!strcmp(attr->name, "notify-pull-method") &&
59115923
attr->value_tag == IPP_TAG_KEYWORD)

0 commit comments

Comments
 (0)