Skip to content

Commit c3037ea

Browse files
committed
Fix parsing bug in cgiCheckVariables.
1 parent 928a86b commit c3037ea

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Changes in CUPS v2.4.17 (YYYY-MM-DD)
3434
- Fixed a bug in the IPP backend when SNMP was disabled.
3535
- Fixed a crash bug in the rastertoepson filter.
3636
- Fixed the range check for job password strings.
37+
- Fixed a bug in cgiCheckVariables.
3738

3839

3940
Changes in CUPS v2.4.16 (2025-12-04)

cgi-bin/var.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* CGI form variable and array functions for CUPS.
33
*
4-
* Copyright © 2020-2024 by OpenPrinting.
4+
* Copyright © 2020-2026 by OpenPrinting.
55
* Copyright © 2007-2019 by Apple Inc.
66
* Copyright © 1997-2005 by Easy Software Products.
77
*
@@ -95,8 +95,11 @@ cgiCheckVariables(const char *names) /* I - Variables to look for */
9595
while (*names == ' ' || *names == ',')
9696
names ++;
9797

98-
for (s = name; *names != '\0' && *names != ' ' && *names != ','; s ++, names ++)
99-
*s = *names;
98+
for (s = name; *names != '\0' && *names != ' ' && *names != ','; names ++)
99+
{
100+
if (s < (name + sizeof(name) - 1))
101+
*s++ = *names;
102+
}
100103

101104
*s = 0;
102105
if (name[0] == '\0')
@@ -633,7 +636,7 @@ cgi_add_variable(const char *name, /* I - Variable name */
633636

634637
if ((var->values = calloc((size_t)element + 1, sizeof(char *))) == NULL)
635638
{
636-
/*
639+
/*
637640
* Rollback changes
638641
*/
639642

0 commit comments

Comments
 (0)