{"record":{"id":"5b4f0ef0bb6d2a91","repo":"DrKLO/Telegram","slug":"s-must-name-one-input-and-one-output-file-5b4f0e","errorCode":null,"errorMessage":"%s: must name one input and one output file\n","messagePattern":"(.+?): must name one input and one output file\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"TMessagesProj/jni/mozjpeg/jpegtran.c","lineNumber":472,"sourceCode":"  jpeg_create_compress(&dstinfo);\n\n  /* Scan command line to find file names.\n   * It is convenient to use just one switch-parsing routine, but the switch\n   * values read here are mostly ignored; we will rescan the switches after\n   * opening the input file.  Also note that most of the switches affect the\n   * destination JPEG object, so we parse into that and then copy over what\n   * needs to affects the source too.\n   */\n\n  file_index = parse_switches(&dstinfo, argc, argv, 0, FALSE);\n  jsrcerr.trace_level = jdsterr.trace_level;\n  srcinfo.mem->max_memory_to_use = dstinfo.mem->max_memory_to_use;\n\n#ifdef TWO_FILE_COMMANDLINE\n  /* Must have either -outfile switch or explicit output file name */\n  if (outfilename == NULL) {\n    if (file_index != argc - 2) {\n      fprintf(stderr, \"%s: must name one input and one output file\\n\",\n              progname);\n      usage();\n    }\n    outfilename = argv[file_index + 1];\n  } else {\n    if (file_index != argc - 1) {\n      fprintf(stderr, \"%s: must name one input and one output file\\n\",\n              progname);\n      usage();\n    }\n  }\n#else\n  /* Unix style: expect zero or one file name */\n  if (file_index < argc - 1) {\n    fprintf(stderr, \"%s: only one input file\\n\", progname);\n    usage();\n  }\n#endif /* TWO_FILE_COMMANDLINE */","sourceCodeStart":454,"sourceCodeEnd":490,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/mozjpeg/jpegtran.c#L454-L490","documentation":"Under TWO_FILE_COMMANDLINE, when no -outfile was given, jpegtran expects exactly one input and one output positional argument (file_index == argc - 2). If that invariant fails, jpegtran prints this message and calls usage() (which exits). The input is implicitly argv[file_index] and the output argv[file_index+1].","triggerScenarios":"Invoking jpegtran with zero, one, or three+ positional file arguments and no -outfile. Examples: jpegtran in.jpg (missing output), jpegtran in.jpg out.jpg extra.jpg, or jpegtran (no files).","commonSituations":"Forgetting the output argument, a shell glob expanding to multiple files in the input position, a quoting bug dropping an argument, or assuming stdout output is allowed (it is not under TWO_FILE_COMMANDLINE).","solutions":["Provide exactly two positional arguments: jpegtran in.jpg out.jpg.","Use -outfile to name the output explicitly if positional parsing is ambiguous.","Quote/guard against glob expansion: pass literal filenames, not unquoted patterns.","Check argc in your wrapper before invoking jpegtran."],"exampleFix":"// before\n./jpegtran in.jpg\n// after\n./jpegtran in.jpg out.jpg","handlingStrategy":"validation","validationCode":"/* wrapper: ensure exactly two positional args when no -outfile */\nint positional = 0, has_outfile = 0;\nfor (int i=1;i<argc;i++) {\n  if (strncmp(argv[i],\"-outfile\",8)==0||strncmp(argv[i],\"-o\",2)==0) has_outfile=1;\n  else if (argv[i][0]!='-') positional++;\n}\nif (!has_outfile && positional!=2) { fprintf(stderr,\"need exactly INPUT OUTPUT\\n\"); exit(2); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always supply exactly two positional files, or use -outfile.","Quote globs to prevent unexpected multi-file expansion.","Validate argument count in the wrapper."],"tags":["jpegtran","cli-args","validation","command-line","mozjpeg"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}