Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

umockdev-run: Fix segfault if no program is specified.

  • Loading branch information...
commit 17db3bee3a145749bebe57479aaa7dc4d9b7163f 1 parent 8430f93
Martin Pitt authored
Showing with 28 additions and 0 deletions.
  1. +4 −0 NEWS
  2. +5 −0 src/umockdev-run.vala
  3. +19 −0 tests/test-integration.vala
View
4 NEWS
@@ -1,3 +1,7 @@
+0.2.2 (UNRELEASED)
+------------------
+- umockdev-run: Fix segfault if no program is specified. (issue #6)
+
0.2.1 (2013-02-21)
------------------
- umockdev-wrapper: Use exec to avoid keeping the shell process around and make
View
5 src/umockdev-run.vala
@@ -79,6 +79,11 @@ main (string[] args)
}
}
+ if (opt_program.length == 0) {
+ stderr.printf ("No program specified. See --help for how to use umockdev-run\n");
+ Process.exit (1);
+ }
+
Posix.execvp(opt_program[0], opt_program);
stderr.printf ("Cannot run program: %s\n", strerror (errno));
return 1;
View
19 tests/test-integration.vala
@@ -87,6 +87,22 @@ Canon PowerShot SX200 IS usb:001,011
}
static void
+t_run_invalid_args ()
+{
+ string sout;
+ string serr;
+ int exit;
+
+ // missing program to run
+ if (!get_program_out ("true", umockdev_run_command, out sout, out serr, out exit))
+ return;
+ assert (serr.contains ("--help"));
+ assert_cmpint (exit, Op.NE, 0);
+ assert (Process.if_exited (exit));
+ assert_cmpstr (sout, Op.EQ, "");
+}
+
+static void
t_gphoto_folderlist ()
{
check_program_out ("gphoto2",
@@ -192,6 +208,9 @@ main (string[] args)
else
rootdir = ".";
+ // boundary conditions
+ Test.add_func ("/umockdev-run/invalid-args", t_run_invalid_args);
+
// tests with gphoto2 program for PowerShot
Test.add_func ("/umockdev-integration/gphoto-detect", t_gphoto_detect);
Test.add_func ("/umockdev-integration/gphoto-folderlist", t_gphoto_folderlist);
Please sign in to comment.
Something went wrong with that request. Please try again.