{"record":{"id":"4fb43586ed6bd5c6","repo":"DrKLO/Telegram","slug":"s-only-one-input-file-n-4fb435","errorCode":null,"errorMessage":"%s: only one input file\\n","messagePattern":"(.+?): only one input file\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"TMessagesProj/jni/mozjpeg/wrjpgcom.c","lineNumber":527,"sourceCode":"    infile = stdin;\n#endif\n  }\n\n  /* Open the output file. */\n#ifdef TWO_FILE_COMMANDLINE\n  /* Must have explicit output file name */\n  if (argn != argc - 2) {\n    fprintf(stderr, \"%s: must name one input and one output file\\n\", progname);\n    usage();\n  }\n  if ((outfile = fopen(argv[argn + 1], WRITE_BINARY)) == NULL) {\n    fprintf(stderr, \"%s: can't open %s\\n\", progname, argv[argn + 1]);\n    exit(EXIT_FAILURE);\n  }\n#else\n  /* Unix style: expect zero or one file name */\n  if (argn < argc - 1) {\n    fprintf(stderr, \"%s: only one input file\\n\", progname);\n    usage();\n  }\n  /* default output file is stdout */\n#ifdef USE_SETMODE              /* need to hack file mode? */\n  setmode(fileno(stdout), O_BINARY);\n#endif\n#ifdef USE_FDOPEN               /* need to re-open in binary mode? */\n  if ((outfile = fdopen(fileno(stdout), WRITE_BINARY)) == NULL) {\n    fprintf(stderr, \"%s: can't open stdout\\n\", progname);\n    exit(EXIT_FAILURE);\n  }\n#else\n  outfile = stdout;\n#endif\n#endif /* TWO_FILE_COMMANDLINE */\n\n  /* Collect comment text from comment_file or stdin, if necessary */\n  if (comment_arg == NULL) {","sourceCodeStart":509,"sourceCodeEnd":545,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/jni/mozjpeg/wrjpgcom.c#L509-L545","documentation":"In the Unix-style (non-TWO_FILE_COMMANDLINE) build, wrjpgcom accepts zero or one positional input file. If more than one positional arg remains (argn < argc - 1), it prints `%s: only one input file`, calls usage(), and exits. This guards against multiple input files being passed.","triggerScenarios":"Running a Unix-style build with two or more positional file arguments, e.g. `wrjpgcom in1.jpg in2.jpg`.","commonSituations":"Glob expanding to multiple JPEGs, or scripting a loop that accidentally passes several files in one invocation.","solutions":["Pass at most one positional input file per invocation.","Loop over inputs in the shell rather than listing them on one command line.","Quote/validate the argument list length before invoking wrjpgcom."],"exampleFix":"// before\nwrjpgcom -comment hi *.jpg\n// after\nfor f in *.jpg; do wrjpgcom -comment hi \"$f\" > \"$f.cmt\"; done","handlingStrategy":"validation","validationCode":"/* Unix-style build: at most one positional input */\nif (argc_after_switches > 1) { /* loop per-file instead of batching */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Invoke wrjpgcom once per input file.","Avoid passing unquoted globs that expand to many files.","Count positional args in the wrapper before exec."],"tags":["cli","jpeg","mozjpeg","wrjpgcom","arguments","input-validation"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}