DrKLO/Telegram · error
Comment text may not exceed %u bytes
Error message
Comment text may not exceed %u bytes
What it means
When -comment is given a value whose first character is a double-quote, wrjpgcom assumes an MS-DOS-style quoted string and allocates a MAX_COM_LENGTH (65000) byte buffer to reassemble it. This error fires when even the very first token is too long: strlen(argv[argn]) + 2 >= MAX_COM_LENGTH. The +2 accounts for the appended space and terminator used while concatenating further tokens. The process exits EXIT_FAILURE.
Source
Thrown at TMessagesProj/jni/mozjpeg/wrjpgcom.c:451
keep_COM = 0;
} else if (keymatch(arg, "cfile", 2)) {
if (++argn >= argc) usage();
if ((comment_file = fopen(argv[argn], "r")) == NULL) {
fprintf(stderr, "%s: can't open %s\n", progname, argv[argn]);
exit(EXIT_FAILURE);
}
} else if (keymatch(arg, "comment", 1)) {
if (++argn >= argc) usage();
comment_arg = argv[argn];
/* If the comment text starts with '"', then we are probably running
* under MS-DOG and must parse out the quoted string ourselves. Sigh.
*/
if (comment_arg[0] == '"') {
comment_arg = (char *)malloc((size_t)MAX_COM_LENGTH);
if (comment_arg == NULL)
ERREXIT("Insufficient memory");
if (strlen(argv[argn]) + 2 >= (size_t)MAX_COM_LENGTH) {
fprintf(stderr, "Comment text may not exceed %u bytes\n",
(unsigned int)MAX_COM_LENGTH);
exit(EXIT_FAILURE);
}
strcpy(comment_arg, argv[argn] + 1);
for (;;) {
comment_length = (unsigned int)strlen(comment_arg);
if (comment_length > 0 && comment_arg[comment_length - 1] == '"') {
comment_arg[comment_length - 1] = '\0'; /* zap terminating quote */
break;
}
if (++argn >= argc)
ERREXIT("Missing ending quote mark");
if (strlen(comment_arg) + strlen(argv[argn]) + 2 >=
(size_t)MAX_COM_LENGTH) {
fprintf(stderr, "Comment text may not exceed %u bytes\n",
(unsigned int)MAX_COM_LENGTH);
exit(EXIT_FAILURE);
}View on GitHub (pinned to 45ab8f4308)
Solutions
- Keep comment text under 65000 bytes; for larger payloads use -cfile with a file instead.
- If the text legitimately exceeds the limit, store it in a file and pass -cfile <file>.
- Trim or chunk the comment source before constructing the argv.
Example fix
// before wrjpgcom -comment "$(cat huge.txt)" photo.jpg // after wrjpgcom -cfile huge.txt photo.jpg
Defensive patterns
Strategy: validation
Validate before calling
#define MAX_COM_LENGTH 65000L
/* before building argv, check the quoted comment's first token length */
if (comment[0] == '"' && strlen(comment) + 2 >= (size_t)MAX_COM_LENGTH) {
/* route long comments through -cfile instead */
} Prevention
- Treat any comment >= ~64KB as a file payload, not an argv string.
- Bound user-supplied comment length at the input boundary.
- Prefer -cfile for programmatically generated comments.
When it happens
Trigger: Running `wrjpgcom -comment "<very long string>"` where the single quoted token (minus trailing quote considerations) already reaches/exceeds 64998 bytes, so no further tokens could ever fit.
Common situations: Piping a huge blob into a shell-quoted -comment argument, accidentally passing a file's full contents as an argument, or a script concatenating unbounded user input into the comment.
Related errors
- Comment text may not exceed %u bytes\n
- %s: can't open %s
- %s: can't open %s\n
- %s: must name one input and one output file\n
- %s: only one input file\n
AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14).
Data as JSON: /api/errors/6be5f6232a02e7f7.
Report an issue: GitHub.