{"record":{"id":"b4edad3cee5f2d05","repo":"DrKLO/Telegram","slug":"s-can-t-determine-size-of-s","errorCode":null,"errorMessage":"%s: can't determine size of %s\n","messagePattern":"(.+?): can't determine size of (.+?)\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"TMessagesProj/jni/mozjpeg/cjpeg.c","lineNumber":769,"sourceCode":"  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 if (!memdst) {\n    /* default output file is stdout */\n    output_file = write_stdout();\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);\n      fclose(icc_file);\n      exit(EXIT_FAILURE);\n    }\n    fclose(icc_file);\n  }\n","sourceCodeStart":751,"sourceCodeEnd":787,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/mozjpeg/cjpeg.c#L751-L787","documentation":"After opening the ICC file, cjpeg seeks to the end (fseek SEEK_END), calls ftell to get the size, and seeks back (fseek SEEK_SET). If any seek fails or ftell returns a value < 1 (empty file), it prints this message and exits EXIT_FAILURE. The %s is icc_filename.","triggerScenarios":"The ICC file is empty (zero bytes / size < 1), or the file descriptor is non-seekable (e.g. a pipe, FIFO, or special device passed as -icc), causing fseek/ftell to fail.","commonSituations":"Passing a pipe or /dev/stdin as the -icc source; a truncated/empty download of a profile; a symlink pointing at an empty target; a file on a filesystem that reports size incorrectly.","solutions":["Ensure the ICC file is a regular, non-empty file.","Do not pipe or use special devices for -icc; copy the profile to a real file first.","Re-download/restore a valid, complete ICC profile if the size is zero."],"exampleFix":"# before: empty or piped icc\ncat profile.icc | cjpeg -icc /dev/stdin in.ppm out.jpg\n# after: regular non-empty file\ncjpeg -icc profile.icc in.ppm out.jpg","handlingStrategy":"validation","validationCode":"#!/bin/sh\nICC=\"$1\"\n[ -f \"$ICC\" ] || { echo \"not a regular file: $ICC\" >&2; exit 1; }\n[ -c \"$ICC\" ] && { echo 'icc must be a regular (seekable) file, not a pipe/device' >&2; exit 1; }\nsize=$(stat -c%s \"$ICC\" 2>/dev/null || stat -f%z \"$ICC\")\n[ \"$size\" -ge 1 ] 2>/dev/null || { echo \"ICC file empty or size unknown: $ICC\" >&2; exit 1; }\ncjpeg -icc \"$ICC\" in.ppm out.jpg","typeGuard":"// n/a: filesystem precondition check in the caller.","tryCatchPattern":"if ! cjpeg -icc \"$ICC\" in.ppm out.jpg 2>/tmp/e; then\n  grep -q \"can't determine size\" /tmp/e && { echo \"ICC not seekable or empty: $ICC\" >&2; exit 1; }\nfi","preventionTips":["Never pipe or use /dev/stdin for -icc; copy to a real file first.","Assert the profile is a regular non-empty file before encoding.","Validate the downloaded profile size against a known expected length."],"tags":["mozjpeg","cjpeg","filesystem","icc-profile","seek"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}