[gvfs] Correctly detect the missing arguments
- From: Andreas Henriksson <ah src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] Correctly detect the missing arguments
- Date: Wed, 23 Jun 2010 08:19:22 +0000 (UTC)
commit e9418fc74b1323ae56c85e0c16364c24b2c2cf68
Author: Ã?ric Piel <eric piel tremplin-utc net>
Date: Wed May 26 20:30:47 2010 +0200
Correctly detect the missing arguments
argc contains the number of arguments, including the name of the program, so it
is one more than expected.
In addition, value must also be checked, otherwise segfault ensues.
programs/gvfs-set-attribute.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/programs/gvfs-set-attribute.c b/programs/gvfs-set-attribute.c
index f51fc9e..e88739c 100644
--- a/programs/gvfs-set-attribute.c
+++ b/programs/gvfs-set-attribute.c
@@ -132,7 +132,7 @@ main (int argc, char *argv[])
return 1;
}
- if (argc < 1)
+ if (argc < 2)
{
g_printerr (_("Location not specified\n"));
return 1;
@@ -140,7 +140,7 @@ main (int argc, char *argv[])
file = g_file_new_for_commandline_arg (argv[1]);
- if (argc < 2)
+ if (argc < 3)
{
g_printerr (_("Attribute not specified\n"));
return 1;
@@ -149,6 +149,12 @@ main (int argc, char *argv[])
attribute = argv[2];
type = attribute_type_from_string (attr_type);
+ if ((argc < 4) && (type != G_FILE_ATTRIBUTE_TYPE_INVALID))
+ {
+ g_printerr (_("Value not specified\n"));
+ return 1;
+ }
+
switch (type)
{
case G_FILE_ATTRIBUTE_TYPE_STRING:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]