[syslinux:master] isohybrid: unbreak hex/octal arguments in C version

syslinux-bot for P J P pj.pandit at yahoo.co.in
Tue Jun 28 16:33:12 PDT 2011


Commit-ID:  79363f76918fb783ca67a5a7146569db82c81818
Gitweb:     http://syslinux.zytor.com/commit/79363f76918fb783ca67a5a7146569db82c81818
Author:     P J P <pj.pandit at yahoo.co.in>
AuthorDate: Tue, 28 Jun 2011 16:31:38 -0700
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Tue, 28 Jun 2011 16:31:38 -0700

isohybrid: unbreak hex/octal arguments in C version

Allow hex/octal arguments in the C version of isohybrid, since they
were accepted by the Perl version.


---
 utils/isohybrid.c |   19 +++++++++++++------
 utils/isohybrid.h |    2 +-
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/utils/isohybrid.c b/utils/isohybrid.c
index 7ee9a7f..8a60531 100644
--- a/utils/isohybrid.c
+++ b/utils/isohybrid.c
@@ -108,6 +108,7 @@ printh(void)
 int
 check_option(int argc, char *argv[])
 {
+    char *err = NULL;
     int n = 0, ind = 0;
 
     const char optstr[] = ":h:s:e:o:t:i:fcp?vV";
@@ -135,32 +136,38 @@ check_option(int argc, char *argv[])
         switch (n)
         {
         case 'h':
-            if (!sscanf(optarg, "%hu", &head) || head < 1 || head > 256)
+            head = strtoul(optarg, &err, 0);
+            if (head < 1 || head > 256)
                 errx(1, "invalid head: `%s', 1 <= head <= 256", optarg);
             break;
 
         case 's':
-            if (!sscanf(optarg, "%hhu", &sector) || sector < 1 || sector > 63)
+            sector = strtoul(optarg, &err, 0);
+            if (sector < 1 || sector > 63)
                 errx(1, "invalid sector: `%s', 1 <= sector <= 63", optarg);
             break;
 
         case 'e':
-            if (!sscanf(optarg, "%hhu", &entry) || entry < 1 || entry > 4)
+            entry = strtoul(optarg, &err, 0);
+            if (entry < 1 || entry > 4)
                 errx(1, "invalid entry: `%s', 1 <= entry <= 4", optarg);
             break;
 
         case 'o':
-            if (!sscanf(optarg, "%hhu", &offset) || offset > 64)
+            offset = strtoul(optarg, &err, 0);
+            if (*err || offset > 64)
                 errx(1, "invalid offset: `%s', 0 <= offset <= 64", optarg);
             break;
 
         case 't':
-            if (!sscanf(optarg, "%hu", &type) || type > 255)
+            type = strtoul(optarg, &err, 0);
+            if (*err || type > 255)
                 errx(1, "invalid type: `%s', 0 <= type <= 255", optarg);
             break;
 
         case 'i':
-            if (!sscanf(optarg, "%u", &id))
+            id = strtoul(optarg, &err, 0);
+            if (*err)
                 errx(1, "invalid id: `%s'", optarg);
             break;
 
diff --git a/utils/isohybrid.h b/utils/isohybrid.h
index 826e90c..eecf1ca 100644
--- a/utils/isohybrid.h
+++ b/utils/isohybrid.h
@@ -20,7 +20,7 @@
  *
  */
 
-#define VERSION     "0.11"
+#define VERSION     "0.12"
 #define BUFSIZE     2048
 #define MBRSIZE      432
 



More information about the Syslinux-commits mailing list