[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
storeread segfault...
From: |
Alfred M. Szmidt |
Subject: |
storeread segfault... |
Date: |
Tue, 9 Mar 2004 06:08:36 +0100 (MET) |
storeread segfaults if you don't pass a argument to it.
hurd:/home/ams/hurd/hurd.obj/utils# storeread
Segmentation fault (core dumped)
The following patch fixes that, and it also updates the docstring a
bit. It also makes storeread barf if you pass it >3 arguments (there
is no point in passing more).
utils/ChangeLog
2004-03-09 Alfred M. Szmidt <ams@kemisten.nu>
* storeread.c (arg_doc): Don't pretend to take an infinite amount
of arguments.
(main): Check that we got the correct number of arguments.
--- utils/storeread.c.~1.7.~ 2003-10-26 12:01:19.000000000 -0800
+++ utils/storeread.c 2004-03-09 14:13:27.000000000 -0800
@@ -1,6 +1,6 @@
/* Write portions of a store to stdout
- Copyright (C) 1996,97,99,2001,02,03 Free Software Foundation, Inc.
+ Copyright (C) 1996,97,99,2001,02,03,04 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.org>
This file is part of the GNU Hurd.
@@ -35,7 +35,7 @@ struct argp_option options[] = {
{"block-size", 'b', "BYTES", 0, "Set the file block size"},
{0, 0}
};
-const char arg_doc[] = "FILE [ADDR [LENGTH]]...";
+const char arg_doc[] = "FILE [ADDR [LENGTH]]";
const char doc[] = "Write portions of the contents of a store to stdout"
"\vADDR is in blocks, and defaults to 0;"
" LENGTH is in bytes, and defaults to the remainder of FILE.";
@@ -73,6 +73,10 @@ main (int argc, char **argv)
case 'b': block_size = atoi (arg); break;
case ARGP_KEY_ARG:
+ if (state->arg_num > 2)
+ /* Too many arguments. */
+ argp_usage (state);
+
if (! store)
{
error_t err;
@@ -109,6 +113,10 @@ main (int argc, char **argv)
break;
case ARGP_KEY_END:
+ if (state->arg_num < 1)
+ /* Not enough arguments. */
+ argp_usage (state);
+
if (addr >= 0)
dump (addr, -1);
else if (! dumped)
- storeread segfault...,
Alfred M. Szmidt <=