{"record":{"id":"61a30ed71afef9b3","repo":"DrKLO/Telegram","slug":"s-can-t-set-quality-ratings","errorCode":null,"errorMessage":"%s: can't set quality ratings\n","messagePattern":"(.+?): can't set quality ratings\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"TMessagesProj/jni/mozjpeg/cjpeg.c","lineNumber":618,"sourceCode":"      jpeg_c_set_bool_param(cinfo, JBOOLEAN_OVERSHOOT_DERINGING, FALSE);\n\n\t} else if (keymatch(arg, \"nojfif\", 6)) {\n      cinfo->write_JFIF_header = 0;\n    } else {\n      fprintf(stderr, \"%s: unknown option '%s'\\n\", progname, arg);\n      usage();                  /* bogus switch */\n    }\n  }\n\n  /* Post-switch-scanning cleanup */\n\n  if (for_real) {\n\n    /* Set quantization tables for selected quality. */\n    /* Some or all may be overridden if -qtables is present. */\n    if (qualityarg != NULL)     /* process -quality if it was present */\n      if (! set_quality_ratings(cinfo, qualityarg, force_baseline)) {\n        fprintf(stderr, \"%s: can't set quality ratings\\n\", progname);\n        usage();\n      }\n\n    if (qtablefile != NULL)     /* process -qtables if it was present */\n      if (! read_quant_tables(cinfo, qtablefile, force_baseline)) {\n        fprintf(stderr, \"%s: can't read qtable file\\n\", progname);\n        usage();\n      }\n\n    if (qslotsarg != NULL)      /* process -qslots if it was present */\n      if (!set_quant_slots(cinfo, qslotsarg))\n        usage();\n\n    /* set_quality_ratings sets default subsampling, so the explicit\n       subsampling must be set after it */\n    if (samplearg != NULL)      /* process -sample if it was present */\n      if (! set_sample_factors(cinfo, samplearg)) {\n        fprintf(stderr, \"%s: can't set sample factors\\n\", progname);","sourceCodeStart":600,"sourceCodeEnd":636,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/mozjpeg/cjpeg.c#L600-L636","documentation":"cjpeg calls set_quality_ratings() to parse the -quality argument (format N[,N,...], one value per quant table slot, last replicated). The function returns FALSE if sscanf fails to read a float, or if the separator after a value is not a comma. The wrapper then prints this message and calls usage().","triggerScenarios":"Passing -quality with a malformed value: empty string, non-numeric token, a separator other than comma (e.g. -quality 75;90 or -quality 75/90), or a trailing comma with no following number that breaks the per-slot sscanf/separator loop.","commonSituations":"Quoting bugs that pass an empty -quality; config files that emit the wrong delimiter; localized environments where a comma is interpreted differently; copying a quality spec from documentation that used a different separator.","solutions":["Use the documented format: a single number or a comma-separated list with no trailing comma, e.g. -quality 90 or -quality 80,90,85.","If the value comes from a variable, validate it matches ^[0-9.]+(,[0-9.]+)*$ before passing it.","Avoid trailing separators and non-comma delimiters (semicolons, slashes, spaces)."],"exampleFix":"# before\ncjpeg -quality 75;90 input.ppm > out.jpg\n# after\ncjpeg -quality 75,90 input.ppm > out.jpg","handlingStrategy":"validation","validationCode":"#!/bin/sh\n# Validate -quality value format: N[,N,...] floats\nQUALITY=\"$1\"\nprintf '%s' \"$QUALITY\" | grep -Eq '^[0-9]+(\\.[0-9]+)?(,[0-9]+(\\.[0-9]+)?)*$' || { echo 'bad -quality format' >&2; exit 1; }\ncjpeg -quality \"$QUALITY\" in.ppm > out.jpg","typeGuard":"// n/a: string-format validation in the caller.","tryCatchPattern":"if ! cjpeg -quality \"$QUALITY\" in.ppm > out.jpg 2>/tmp/e; then\n  grep -q \"can't set quality ratings\" /tmp/e && { echo 'fix -quality format (N[,N,...])'; exit 1; }\nfi","preventionTips":["Restrict the -quality input with a regex before invoking cjpeg.","Normalize separators (spaces/semicolons/slashes) to commas in your wrapper.","Unit-test the wrapper against malformed quality strings."],"tags":["mozjpeg","cjpeg","cli-argument","quality","parse-error"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}