{"record":{"id":"a3ad9a329ab38dfc","repo":"DrKLO/Telegram","slug":"s-can-t-open-s-n","errorCode":null,"errorMessage":"%s: can't open %s\\n","messagePattern":"(.+?): can't open (.+?)\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"TMessagesProj/jni/mozjpeg/djpeg.c","lineNumber":587,"sourceCode":"  } else {\n    if (file_index != argc - 1) {\n      fprintf(stderr, \"%s: must name one input and one output file\\n\",\n              progname);\n      usage();\n    }\n  }\n#else\n  /* Unix style: expect zero or one file name */\n  if (file_index < argc - 1) {\n    fprintf(stderr, \"%s: only one input file\\n\", progname);\n    usage();\n  }\n#endif /* TWO_FILE_COMMANDLINE */\n\n  /* Open the input file. */\n  if (file_index < argc) {\n    if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) {\n      fprintf(stderr, \"%s: can't open %s\\n\", progname, argv[file_index]);\n      exit(EXIT_FAILURE);\n    }\n  } else {\n    /* default input file is stdin */\n    input_file = read_stdin();\n  }\n\n  /* Open the output file. */\n  if (outfilename != NULL) {\n    if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) {\n      fprintf(stderr, \"%s: can't open %s\\n\", progname, outfilename);\n      exit(EXIT_FAILURE);\n    }\n  } else {\n    /* default output file is stdout */\n    output_file = write_stdout();\n  }\n","sourceCodeStart":569,"sourceCodeEnd":605,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/mozjpeg/djpeg.c#L569-L605","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// before\n./djpeg missing.jpg > out.ppm\n// after - validate then run\ntest -f \"$IN\" || { echo \"missing $IN\"; exit 1; }\n./djpeg \"$IN\" > out.ppm","handlingStrategy":"validation","validationCode":"#include <sys/stat.h>\nint can_read_input(const char *p) {\n  struct stat st;\n  if (stat(p, &st) != 0) return 0;          /* missing */\n  if (!S_ISREG(st.st_mode)) return 0;        /* not a file */\n  return access(p, R_OK) == 0;\n}\n/* call before exec djpeg with argv[file_index] */","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["file-io","djpeg","input","mozjpeg","cli"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}