{"record":{"id":"46d89dd2eb33ac1b","repo":"DrKLO/Telegram","slug":"s-can-t-open-s-46d89d","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/wrjpgcom.c","lineNumber":437,"sourceCode":"  argc = ccommand(&argv);\n#endif\n\n  progname = argv[0];\n  if (progname == NULL || progname[0] == 0)\n    progname = \"wrjpgcom\";      /* in case C library doesn't provide it */\n\n  /* Parse switches, if any */\n  for (argn = 1; argn < argc; argn++) {\n    arg = argv[argn];\n    if (arg[0] != '-')\n      break;                    /* not switch, must be file name */\n    arg++;                      /* advance over '-' */\n    if (keymatch(arg, \"replace\", 1)) {\n      keep_COM = 0;\n    } else if (keymatch(arg, \"cfile\", 2)) {\n      if (++argn >= argc) usage();\n      if ((comment_file = fopen(argv[argn], \"r\")) == NULL) {\n        fprintf(stderr, \"%s: can't open %s\\n\", progname, argv[argn]);\n        exit(EXIT_FAILURE);\n      }\n    } else if (keymatch(arg, \"comment\", 1)) {\n      if (++argn >= argc) usage();\n      comment_arg = argv[argn];\n      /* If the comment text starts with '\"', then we are probably running\n       * under MS-DOG and must parse out the quoted string ourselves.  Sigh.\n       */\n      if (comment_arg[0] == '\"') {\n        comment_arg = (char *)malloc((size_t)MAX_COM_LENGTH);\n        if (comment_arg == NULL)\n          ERREXIT(\"Insufficient memory\");\n        if (strlen(argv[argn]) + 2 >= (size_t)MAX_COM_LENGTH) {\n          fprintf(stderr, \"Comment text may not exceed %u bytes\\n\",\n                  (unsigned int)MAX_COM_LENGTH);\n          exit(EXIT_FAILURE);\n        }\n        strcpy(comment_arg, argv[argn] + 1);","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/mozjpeg/wrjpgcom.c#L419-L455","documentation":"wrjpgcom is a mozjpeg CLI tool that inserts/replaces JPEG comment (COM) markers. The -cfile switch tells it to read the new comment text from an external file. This message is printed to stderr and the process exits with EXIT_FAILURE when fopen(argv[argn], \"r\") on that comment file returns NULL, i.e. the file cannot be opened for reading. The first %s is progname (argv[0]), the second is the offending path.","triggerScenarios":"Invoking `wrjpgcom -cfile <path> [input.jpg]` where <path> does not exist, is not a regular file, or lacks read permission. The check runs during argv parsing, before any JPEG input is touched.","commonSituations":"Typo or wrong relative path (cwd differs from expectation), file on a read-only/unmounted volume, SELinux/Android permission denial in the TMessagesProj JNI context, or passing a directory name instead of a file.","solutions":["Verify the -cfile path is readable before running: run `test -r <path>` or stat() it from the caller.","Pass an absolute path instead of a relative one to remove cwd ambiguity.","Check permissions/ownership of the target file and the directory leading to it.","Confirm the path points to a regular file, not a directory or device node."],"exampleFix":"// before\nwrjpgcom -cfile notes.txt photo.jpg   # notes.txt not in cwd\n// after\nwrjpgcom -cfile /sdcard/comments/notes.txt photo.jpg","handlingStrategy":"validation","validationCode":"/* C caller: verify -cfile target is readable before exec'ing wrjpgcom */\n#include <unistd.h>\nif (access(cfile_path, R_OK) != 0) {\n    /* report missing/unreadable comment file; do not invoke */\n    return -1;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve -cfile to an absolute path before invoking wrjpgcom.","In shell, guard with: [ -r \"$cfile\" ] || { echo \"missing cfile\"; exit 1; }.","Never pass a directory or device path as -cfile."],"tags":["cli","jpeg","mozjpeg","wrjpgcom","file-io","input-validation"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}