{"record":{"id":"001dbd1ad71e4c5c","repo":"DrKLO/Telegram","slug":"s-bogus-crop-argument-s","errorCode":null,"errorMessage":"%s: bogus -crop argument '%s'\n","messagePattern":"(.+?): bogus -crop argument '(.+?)'\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"TMessagesProj/jni/mozjpeg/jpegtran.c","lineNumber":212,"sourceCode":"      /* Select which extra markers to copy. */\n      if (++argn >= argc)       /* advance to next argument */\n        usage();\n      if (keymatch(argv[argn], \"none\", 1)) {\n        copyoption = JCOPYOPT_NONE;\n      } else if (keymatch(argv[argn], \"comments\", 1)) {\n        copyoption = JCOPYOPT_COMMENTS;\n      } else if (keymatch(argv[argn], \"all\", 1)) {\n        copyoption = JCOPYOPT_ALL;\n      } else\n        usage();\n\n    } else if (keymatch(arg, \"crop\", 2)) {\n      /* Perform lossless cropping. */\n#if TRANSFORMS_SUPPORTED\n      if (++argn >= argc)       /* advance to next argument */\n        usage();\n      if (!jtransform_parse_crop_spec(&transformoption, argv[argn])) {\n        fprintf(stderr, \"%s: bogus -crop argument '%s'\\n\",\n                progname, argv[argn]);\n        exit(EXIT_FAILURE);\n      }\n      prefer_smallest = FALSE;\n#else\n      select_transform(JXFORM_NONE);    /* force an error */\n#endif\n\n    } else if (keymatch(arg, \"debug\", 1) || keymatch(arg, \"verbose\", 1)) {\n      /* Enable debug printouts. */\n      /* On first -d, print version identification */\n      static boolean printed_version = FALSE;\n\n      if (!printed_version) {\n        fprintf(stderr, \"%s version %s (build %s)\\n\",\n                PACKAGE_NAME, VERSION, BUILD);\n        fprintf(stderr, \"%s\\n\\n\", JCOPYRIGHT);\n        fprintf(stderr, \"Emulating The Independent JPEG Group's software, version %s\\n\\n\",","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/mozjpeg/jpegtran.c#L194-L230","documentation":"jpegtran's -crop argument failed to parse via jtransform_parse_crop_spec(). The expected format is WxH+X+Y (or WxH+X+Y with optional alignment/offset syntax); an unparseable string triggers this fatal error.","triggerScenarios":"Passing a malformed crop spec such as -crop 100, -crop 100x, -crop x100+0+0, -crop 100x100-0-0, or any string jtransform_parse_crop_spec rejects. Also triggered by missing width/height or invalid delimiters.","commonSituations":"Constructing the crop string programmatically with a format bug, locale issues affecting 'x' parsing, or copy-pasting a spec from a tool that uses a different syntax.","solutions":["Use the exact format WxH+X+Y, e.g. -crop 100x100+0+0.","If calling the API, validate the parsed spec fields (width>0, height>0) after jtransform_parse_crop_spec returns nonzero.","Quote the argument to prevent shell globbing/expansion of the '+' or 'x'.","Test the crop string against the parser separately before bundling into a full jpegtran command."],"exampleFix":"// before\n./jpegtran -crop 100,100,0,0 in.jpg > out.jpg\n// after\n./jpegtran -crop 100x100+0+0 in.jpg > out.jpg","handlingStrategy":"validation","validationCode":"#include <ctype.h>\n/* minimal WxH+X+Y validator matching jtransform_parse_crop_spec expectations */\nint crop_spec_ok(const char *s) {\n  const char *p = s; char *end;\n  long w = strtol(p,&end,10); if (end==p||*end!='x'||w<=0) return 0; p=end+1;\n  long h = strtol(p,&end,10); if (end==p||h<=0) return 0; p=end;\n  if (*p!='+') return 0; p++;\n  long x = strtol(p,&end,10); if (end==p||x<0) return 0; p=end;\n  if (*p!='+') return 0; p++;\n  long y = strtol(p,&end,10); if (end==p||y<0) return 0; p=end;\n  return *p=='\\0';\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build crop strings in the exact WxH+X+Y form.","Validate the spec before passing to jpegtran.","Quote the argument to shield '+' and 'x' from the shell."],"tags":["jpegtran","crop","cli-args","parsing","mozjpeg"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}