DrKLO/Telegram · error
%s: can't open %s\n
Error message
%s: can't open %s\n
What it means
djpeg could not open the specified input file for binary reading. The program calls fopen(argv[file_index], READ_BINARY) and receives NULL, indicating the path is inaccessible. This is a hard failure: the process calls exit(EXIT_FAILURE) immediately after printing the message.
Source
Thrown at TMessagesProj/jni/mozjpeg/djpeg.c:587
} else {
if (file_index != argc - 1) {
fprintf(stderr, "%s: must name one input and one output file\n",
progname);
usage();
}
}
#else
/* Unix style: expect zero or one file name */
if (file_index < argc - 1) {
fprintf(stderr, "%s: only one input file\n", progname);
usage();
}
#endif /* TWO_FILE_COMMANDLINE */
/* Open the input file. */
if (file_index < argc) {
if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) {
fprintf(stderr, "%s: can't open %s\n", progname, argv[file_index]);
exit(EXIT_FAILURE);
}
} else {
/* default input file is stdin */
input_file = read_stdin();
}
/* Open the output file. */
if (outfilename != NULL) {
if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) {
fprintf(stderr, "%s: can't open %s\n", progname, outfilename);
exit(EXIT_FAILURE);
}
} else {
/* default output file is stdout */
output_file = write_stdout();
}
View on GitHub (pinned to 45ab8f4308)
Solutions
- Verify the path exists and is readable: ls -l <path> and test -r <path> before invoking djpeg.
- Use an absolute path or resolve relative to the known base directory instead of relying on the process cwd.
- Confirm the file is a regular file, not a directory: [ -f <path> ].
- Check filesystem mount and permissions (chmod/chown or Android sandbox grants).
Example fix
// before
./djpeg missing.jpg > out.ppm
// after - validate then run
test -f "$IN" || { echo "missing $IN"; exit 1; }
./djpeg "$IN" > out.ppm Defensive patterns
Strategy: validation
Validate before calling
#include <sys/stat.h>
int can_read_input(const char *p) {
struct stat st;
if (stat(p, &st) != 0) return 0; /* missing */
if (!S_ISREG(st.st_mode)) return 0; /* not a file */
return access(p, R_OK) == 0;
}
/* call before exec djpeg with argv[file_index] */ Prevention
- Resolve input paths to absolute form before invoking djpeg.
- In shell wrappers, gate on test -f && test -r before running.
- On Android, confirm the storage permission grant and content URI resolution.
When it happens
Trigger: Invoking djpeg with a path that does not exist, points to a directory instead of a file, lacks read permission, or is on an unmounted/unavailable filesystem. Triggered only when an explicit filename argument is given (file_index < argc); stdin is not involved here.
Common situations: Typo in the JPEG path, relative path evaluated from the wrong working directory, Android NDK build running with restrictive SELinux/AppArmor policies, file deleted between argument parsing and open, or a glob/variable expanding to a directory name.
Related errors
- %s: can't read from %s\n
- %s: can't read from stdin\n
- %s: can't read ICC profile from %s\n
- %s: can't open %s
- %s: can't open %s\n
AI-assisted analysis of DrKLO/Telegram@45ab8f4308 (2026-08-14).
Data as JSON: /api/errors/a3ad9a329ab38dfc.
Report an issue: GitHub.