[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
dd duplicated option bug (or is it a feature?)
From: |
Fabrício Barros Cabral |
Subject: |
dd duplicated option bug (or is it a feature?) |
Date: |
Sun, 07 Aug 2005 18:02:00 -0300 |
Hello people!
I don't know if I found a bug or if it is a feature. The problema is
related to duplicated name of options. See:
address@hidden:~$ dd of=me of=you
dd stay in a infinite loop, until I press ctrl + d. The result is a only
file named "you" with nothing inside it.
So, if is it a bug, please consider my patch.
Thanks in advance,
--fx
--- dd.c.orig 2005-08-07 17:20:29.284867560 -0300
+++ dd.c 2005-08-07 17:45:31.050564472 -0300
@@ -552,9 +552,11 @@
scanargs (int argc, char **argv)
{
int i;
+ char *dup_name;
--argc;
++argv;
+ dup_name = NULL;
for (i = optind; i < argc; i++)
{
@@ -562,19 +564,36 @@
name = argv[i];
val = strchr (name, '=');
+
+ if (dup_name)
+ {
+ error (0, 0, _("duplicated option %s"), quote (dup_name));
+ usage (EXIT_FAILURE);
+ }
+
if (val == NULL)
{
error (0, 0, _("unrecognized option %s"), quote (name));
usage (EXIT_FAILURE);
}
+
*val++ = '\0';
if (STREQ (name, "if"))
- input_file = val;
+ {
+ input_file = val;
+ dup_name = name;
+ }
else if (STREQ (name, "of"))
- output_file = val;
+ {
+ output_file = val;
+ dup_name = name;
+ }
else if (STREQ (name, "conv"))
- parse_conversion (val);
+ {
+ parse_conversion (val);
+ dup_name = name;
+ }
else
{
int invalid = 0;
@@ -587,6 +606,7 @@
input_blocksize = n;
invalid |= input_blocksize != n || input_blocksize == 0;
conversions_mask |= C_TWOBUFS;
+ dup_name = name;
}
else if (STREQ (name, "obs"))
{
@@ -595,6 +615,7 @@
output_blocksize = n;
invalid |= output_blocksize != n || output_blocksize == 0;
conversions_mask |= C_TWOBUFS;
+ dup_name = name;
}
else if (STREQ (name, "bs"))
{
@@ -602,19 +623,30 @@
invalid |= SSIZE_MAX < n;
output_blocksize = input_blocksize = n;
invalid |= output_blocksize != n || output_blocksize == 0;
+ dup_name = name;
}
else if (STREQ (name, "cbs"))
{
conversion_blocksize = n;
invalid |= (conversion_blocksize != n
|| conversion_blocksize == 0);
+ dup_name = name;
}
else if (STREQ (name, "skip"))
- skip_records = n;
+ {
+ skip_records = n;
+ dup_name = name;
+ }
else if (STREQ (name, "seek"))
- seek_records = n;
+ {
+ seek_records = n;
+ dup_name = name;
+ }
else if (STREQ (name, "count"))
- max_records = n;
+ {
+ max_records = n;
+ dup_name = name;
+ }
else
{
error (0, 0, _("unrecognized option %s=%s"),
_______________________________________________________
Yahoo! Acesso Grátis - Internet rápida e grátis.
Instale o discador agora! http://br.acesso.yahoo.com/
- dd duplicated option bug (or is it a feature?),
Fabrício Barros Cabral <=