Jim Meyering <[email protected]> wrote:

> Jim Meyering <[email protected]> wrote:
>> Otavio Salvador <[email protected]> wrote:
>>> diff --git a/po/POTFILES.in b/po/POTFILES.in
>>> index 8b2a9e2..96b43f2 100644
>>> --- a/po/POTFILES.in
>>> +++ b/po/POTFILES.in
>>> @@ -13,7 +13,6 @@ lib/regcomp.c
>>>  lib/rpmatch.c
>>>  lib/version-etc.c
>>>  lib/xalloc-die.c
>>> -lib/xstrtol-error.c
>>
>> ACK, assuming "make syntax-check" still passes.
>
> Did you run "make syntax-check"?
>
> This change broke "make syntax-check", so I'm about to revert it.
>
> If you're not running ./bootstrap regularly (when building from git),
> you should start doing so.

Ahh... I see what happened.
I'd built on "next", that had created lib/xstrtol-error.c,
and it hung around even after I switched back to "master",
where syntax-check failed.

Since the gnulib xstrtol module (of which that is a part)
will eventually come in with changes from "next", I've gone
ahead and found a use for it by fixing a small infelicity
in clearfat.  It would fail to diagnose a bogus device number.

I've just pushed this:


>From 29e1a79630c51321f851d762c45b2bd99afeaec7 Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email protected]>
Date: Sat, 7 Feb 2009 17:17:54 +0100
Subject: [PATCH] clearfat: diagnose an invalid device number

* debug/clearfat/clearfat.c: Include <limits.h> and "xstrtol.h".
(main): Diagnose an invalid minor device number argument.
* bootstrap.conf (gnulib_modules): Add xstrtol.
---
 bootstrap.conf            |    1 +
 debug/clearfat/clearfat.c |   16 +++++++++++++---
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/bootstrap.conf b/bootstrap.conf
index 91bbe6e..99432ad 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -55,6 +55,7 @@ gnulib_modules="
        stdbool
        useless-if-before-free
        version-etc-fsf
+       xstrtol
 "

 # Additional xgettext options to use.  Use "\\\newline" to break lines.
diff --git a/debug/clearfat/clearfat.c b/debug/clearfat/clearfat.c
index 7a4c61f..69bc357 100644
--- a/debug/clearfat/clearfat.c
+++ b/debug/clearfat/clearfat.c
@@ -1,6 +1,6 @@
 /*
     clear_fat - a tool to clear unused space (for testing purposes)
-    Copyright (C) 2000, 2007-2008 Free Software Foundation, Inc.
+    Copyright (C) 2000, 2007-2009 Free Software Foundation, Inc.

     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -21,12 +21,14 @@
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <limits.h>
 #include <getopt.h>
 #include "closeout.h"
 #include "configmake.h"
 #include "error.h"
 #include "long-options.h"
 #include "progname.h"
+#include "xstrtol.h"

 #include "../../libparted/fs/fat/fat.h"

@@ -288,6 +290,14 @@ main (int argc, char* argv[])
             usage (EXIT_FAILURE);
           }

+       unsigned long minor_dev_number;
+       if (xstrtoul (argv[2], NULL, 10, &minor_dev_number, NULL)
+           || INT_MAX < minor_dev_number)
+         {
+           error (0, 0, _("invalid minor device number: %s"), argv[2]);
+            usage (EXIT_FAILURE);
+         }
+
        dev = ped_device_get (argv [1]);
        if (!dev)
                goto error;
@@ -297,8 +307,8 @@ main (int argc, char* argv[])
        disk = ped_disk_new (dev);
        if (!disk)
                goto error_close_dev;
- 
-       part = ped_disk_get_partition (disk, atoi (argv[2]));
+
+       part = ped_disk_get_partition (disk, minor_dev_number);
        if (!part) {
                printf ("Couldn't find partition `%s'\n", argv[2]);
                goto error_destroy_disk;
-- 
1.6.1.2.549.g547ef


_______________________________________________
parted-devel mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/parted-devel

Reply via email to