summaryrefslogtreecommitdiff
path: root/programs
diff options
context:
space:
mode:
authorÉric Piel <eric.piel@tremplin-utc.net>2010-05-26 20:30:47 +0200
committerAndreas Henriksson <andreas@fatal.se>2010-06-23 10:17:00 +0200
commite9418fc74b1323ae56c85e0c16364c24b2c2cf68 (patch)
tree4f1343df7554b2cdbb11de11db2e2284a04bfa07 /programs
parente6b6ecf80e5db77a6cfb087cacde4cb1a277def0 (diff)
downloadgvfs-e9418fc74b1323ae56c85e0c16364c24b2c2cf68.tar.gz
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.
Diffstat (limited to 'programs')
-rw-r--r--programs/gvfs-set-attribute.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/programs/gvfs-set-attribute.c b/programs/gvfs-set-attribute.c
index f51fc9e5..e88739c2 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: