{"record":{"id":"60d2438df05036c2","repo":"DrKLO/Telegram","slug":"s-can-t-open-s-60d243","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/jpegtran.c","lineNumber":506,"sourceCode":"    usage();\n  }\n#endif /* TWO_FILE_COMMANDLINE */\n\n  /* Open the input file. */\n  if (file_index < argc) {\n    if ((fp = fopen(argv[file_index], READ_BINARY)) == NULL) {\n      fprintf(stderr, \"%s: can't open %s for reading\\n\", progname,\n              argv[file_index]);\n      exit(EXIT_FAILURE);\n    }\n  } else {\n    /* default input file is stdin */\n    fp = read_stdin();\n  }\n\n  if (icc_filename != NULL) {\n    if ((icc_file = fopen(icc_filename, READ_BINARY)) == NULL) {\n      fprintf(stderr, \"%s: can't open %s\\n\", progname, icc_filename);\n      exit(EXIT_FAILURE);\n    }\n    if (fseek(icc_file, 0, SEEK_END) < 0 ||\n        (icc_len = ftell(icc_file)) < 1 ||\n        fseek(icc_file, 0, SEEK_SET) < 0) {\n      fprintf(stderr, \"%s: can't determine size of %s\\n\", progname,\n              icc_filename);\n      exit(EXIT_FAILURE);\n    }\n    if ((icc_profile = (JOCTET *)malloc(icc_len)) == NULL) {\n      fprintf(stderr, \"%s: can't allocate memory for ICC profile\\n\", progname);\n      fclose(icc_file);\n      exit(EXIT_FAILURE);\n    }\n    if (fread(icc_profile, icc_len, 1, icc_file) < 1) {\n      fprintf(stderr, \"%s: can't read ICC profile from %s\\n\", progname,\n              icc_filename);\n      free(icc_profile);","sourceCodeStart":488,"sourceCodeEnd":524,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/mozjpeg/jpegtran.c#L488-L524","documentation":"When the user specifies an ICC profile via the `-icc` option, jpegtran opens it with fopen(icc_filename, READ_BINARY) at jpegtran.c:505. A NULL return means the ICC file path is invalid or inaccessible. Unlike the input JPEG, this error message omits 'for reading' to distinguish it.","triggerScenarios":"Passing `-icc profile.icc` where profile.icc does not exist, is a directory, or has restrictive permissions. Also triggered by a typo in the ICC filename or an expired/cleaned-up temp file path.","commonSituations":"ICC profile file was downloaded to a cache that was cleared. Path is relative and resolves wrong in JNI context. Profile is bundled as an Android asset but the native code receives a path that doesn't resolve on the filesystem.","solutions":["Verify the ICC file exists and is readable with `access(icc_path, R_OK)` before invoking jpegtran","Use an absolute path for the ICC profile file","Extract the ICC profile from the APK assets to internal storage first, then pass that path"],"exampleFix":"// before\njpegtran -icc srgb.icc input.jpg -outfile out.jpg\n\n// after\nconst char *icc = \"/data/user/0/app/files/srgb.icc\";\nif (access(icc, R_OK) != 0) { return -1; }\njpegtran -icc /data/user/0/app/files/srgb.icc input.jpg -outfile out.jpg","handlingStrategy":"validation","validationCode":"// Validate ICC profile file before invoking jpegtran -icc\nint validate_icc_file(const char *path) {\n    if (access(path, R_OK) != 0) return -1;\n    struct stat st;\n    if (stat(path, &st) != 0) return -1;\n    if (!S_ISREG(st.st_mode)) return -1;\n    if (st.st_size < 128 || st.st_size > 5*1024*1024) return -1; // ICC profiles are 128B-5MB\n    return 0;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify the ICC file exists and is readable before passing -icc","Bundle ICC profiles in app internal storage, not external removable storage","Use absolute paths for ICC profile files"],"tags":["jpeg","jpegtran","icc-profile","file-io"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}