[elbe-devel] [PATCH 09/13] commands/validate: check number of arguments

Torben Hohn torben.hohn at linutronix.de
Tue Dec 5 16:57:55 CET 2017


On Thu, Nov 30, 2017 at 03:15:11PM +0100, Manuel Traut wrote:
> to avoid outofindex exception if no filename is given
> 
> Signed-off-by: Manuel Traut <manut at linutronix.de>
> ---
>  elbepack/commands/validate.py | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/elbepack/commands/validate.py b/elbepack/commands/validate.py
> index f9ff4e86..99a6368b 100644
> --- a/elbepack/commands/validate.py
> +++ b/elbepack/commands/validate.py
> @@ -30,6 +30,10 @@ def run_command( argv ):
>  
>      (opt,args) = oparser.parse_args(sys.argv)
this is not good. ^^
the elbe commands are supposed to parse their argv parameter.
should be:  (opt,args) = oparser.parse_args(argv)

getting these straight, means, that the following gets:

s/3/1/
s/2/0/

>  
> +    if len(args) < 3:
> +        oparser.print_help()
> +        sys.exit(20)
> +
>      if not os.path.exists(args[2]):
>          print ("%s - file not found" % args[2])
>          oparser.print_help()

I see several sys.argv cargo culted:

elbepack/commands/control.py:    (opt,args) = oparser.parse_args (sys.argv)
elbepack/commands/initvm.py:    (opt,args) = oparser.parse_args (sys.argv)
elbepack/commands/pbuilder.py:    (opt,args) = oparser.parse_args (sys.argv)
elbepack/commands/prjrepo.py:    (opt, args) = oparser.parse_args(sys.argv)
elbepack/commands/validate.py:    (opt,args) = oparser.parse_args(sys.argv)

All of them need fixes.


-- 
Mit freundlichen Grüßen
Torben Hohn

Linutronix GmbH

Standort: Bremen

Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Firmensitz / Registered Office: D-88690 Uhldingen, Bahnhofstr. 3
Registergericht / Local District Court: Amtsgericht Freiburg i. Br.; HRB
Nr. / Trade register no.: 700 806

Geschäftsführer / Managing Directors: Heinz Egger, Thomas Gleixner

Eine Bitte von uns: Sollten Sie diese E-Mail irrtümlich erhalten haben,
benachrichtigen Sie uns in diesem Falle bitte sobald wie es Ihnen
möglich ist, durch Antwort-Mail. Vielen Dank!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.linutronix.de/pipermail/elbe-devel/attachments/20171205/63abc152/attachment.sig>


More information about the elbe-devel mailing list