Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions cups/ipp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,8 @@ ippAddStringfv(ipp_t *ipp, // I - IPP message
bufptr --;
}

bufptr --;
if (bufptr > buffer)
bufptr --;
}

*bufptr = '\0';
Expand Down Expand Up @@ -3434,7 +3435,8 @@ ippSetStringfv(ipp_t *ipp, // I - IPP message
bufptr --;
}

bufptr --;
if (bufptr > buffer)
bufptr --;
}

*bufptr = '\0';
Expand Down
28 changes: 28 additions & 0 deletions cups/testipp.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,34 @@ main(int argc, // I - Number of command-line arguments
testEnd(true);
}

// Oversized values consisting only of UTF-8 continuation bytes must be
// truncated to a boundary without stepping below the format buffer...
testBegin("ippAddStringf(oversized continuation bytes)");
{
char overlong[2 * IPP_MAX_NAME];
const char *str; // Resulting value

memset(overlong, 0x80, sizeof(overlong) - 1);
overlong[sizeof(overlong) - 1] = '\0';

attr = ippAddStringf(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "overlong-attr", /*lang*/NULL, "%s", overlong);

if (!attr)
{
testEndMessage(false, "Unable to create name attribute");
status = 1;
}
else if ((str = ippGetString(attr, 0, NULL)) == NULL || strlen(str) >= IPP_MAX_NAME)
{
testEndMessage(false, "value not truncated (%d bytes)", str ? (int)strlen(str) : -1);
status = 1;
}
else
{
testEnd(true);
}
}

ippDelete(request);

#ifdef DEBUG
Expand Down
Loading