Skip to content

Commit ed0e4ec

Browse files
committed
rpm2archive: - is only supported as lone argument
Give an error message otherwise. Resolves: rpm-software-management#3923
1 parent d3ed13a commit ed0e4ec

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

tests/rpmgeneral.at

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,13 @@ runroot rpm2archive "${RPMTEST}"/data/SRPMS/hello-1.0-1.src.rpm | tar tzf -
457457
[./hello-1.0.tar.gz
458458
./hello.spec
459459
])
460+
RPMTEST_CHECK([
461+
runroot rpm2archive "${RPMTEST}"/data/SRPMS/hello-1.0-1.src.rpm -
462+
],
463+
[1],
464+
[],
465+
[No other arguments allowed beside of -
466+
])
460467

461468
RPMTEST_CLEANUP
462469

tools/rpm2archive.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ int main(int argc, char *argv[])
287287
int rc = 0;
288288
poptContext optCon;
289289
const char *fn;
290+
int arg_stdin = 0;
291+
int args = 0;
290292

291293
xsetprogname(argv[0]); /* Portability call -- see system.h */
292294
rpmReadConfigFiles(NULL, NULL);
@@ -324,6 +326,18 @@ int main(int argc, char *argv[])
324326
goto exit;
325327
}
326328

329+
/* Make sure - is given as a lone argument */
330+
for (const char ** arg = poptGetArgs(optCon); *arg; arg++){
331+
if (!strcmp(*arg, "-"))
332+
arg_stdin = 1;
333+
args++;
334+
}
335+
if (arg_stdin && args > 1) {
336+
fprintf(stderr, "No other arguments allowed beside of -\n");
337+
rc = 1;
338+
goto exit;
339+
}
340+
327341
while ((fn = poptGetArg(optCon)) != NULL) {
328342
rc = process_package(ts, fn);
329343
if (rc != 0)

0 commit comments

Comments
 (0)