Fix: save errno for second command
authorJoachim Wiedorn <ad_debian@joonet.de>
Fri, 11 Mar 2011 19:36:54 +0000 (20:36 +0100)
committerJoachim Wiedorn <ad_debian@joonet.de>
Fri, 11 Mar 2011 19:36:54 +0000 (20:36 +0100)
debian/changelog
debian/patches/12_save-errno-for-second-command.patch [new file with mode: 0644]
debian/patches/series
debian/patches/ubuntu.series

index c764729648eb33d557ca277ea80b6665fc92d613..d726381519b5587d2ae294e5667c7714c798d644 100644 (file)
@@ -2,6 +2,7 @@ lilo (1:23.1-2) unstable; urgency=low
 
   * debian/control:
     - Remove dependency to lilo in package lilo-doc. (Closes: #613753)
+  * Fix: save errno for second command (device.c).
 
  -- Joachim Wiedorn <ad_debian@joonet.de>  Thu, 17 Feb 2011 21:39:38 +0100
 
diff --git a/debian/patches/12_save-errno-for-second-command.patch b/debian/patches/12_save-errno-for-second-command.patch
new file mode 100644 (file)
index 0000000..f21597d
--- /dev/null
@@ -0,0 +1,51 @@
+Package:     lilo
+Subject:     save errno for second command
+Author:      Joachim Wiedorn <ad_debian at joonet.de>
+Forwarded:   yes
+Last-Update: 2011-02-17
+
+The problem is that fprintf can alter the value of errno 
+(see man perror). In a weired case the user get a bogus error 
+because the real error was hidden by fprintf. 
+---
+
+diff -urN s11/src/device.c s12/src/device.c
+--- s11/src/device.c   2011-02-17 22:07:17.167142581 +0100
++++ s12/src/device.c   2011-02-17 22:20:03.047152869 +0100
+@@ -197,6 +197,7 @@
+     char name[PATH_MAX];
+     ST_BUF st;
+     int count;
++    int err;
+     if (lookup_dev(name,dev,number)) dev->delete = 0;
+     else {
+@@ -235,11 +236,12 @@
+ #endif
+     if (flags == O_BYPASS) dev->fd = -1;
+     else if ((dev->fd = open(name,flags)) < 0) {
+-            fprintf (errstd, "Cannot proceed. Maybe you need to add "
++        err = errno;
++        fprintf (errstd, "Cannot proceed. Maybe you need to add "
+                         "this to your lilo.conf:\n"
+                          "\tdisk=%s inaccessible\n"
+                         "(real error shown below)\n", name);
+-          die("open %s: %s",name,strerror(errno));
++          die("open %s: %s",name,strerror(err));
+     }
+     dev->name = stralloc(name);
+     return dev->fd;
+@@ -714,11 +716,11 @@
+       
+     fd = dev_open(&dev, device, option ? O_RDWR : O_RDONLY);
+     if (read(fd, &buf, sizeof(buf)) != sizeof(buf)) {
+-      fprintf (errstd, "Cannot proceed. Maybe you need to add "
++      fprintf (errstd, "Cannot proceed. Maybe you need to add "
+                         "this to your lilo.conf:\n"
+                          "\tdisk=%s inaccessible\n"
+                         "(real error shown below)\n", dev.name);
+-      die("VolumeID read error: sector 0 of %s not readable", dev.name);
++      die("VolumeID read error: sector 0 of %s not readable", dev.name);
+     }
+     if (option==ID_SET) {
+       make_backup(NULL, 0, &buf, device,
index fa3c5e2b45fab6cd3ca25559ca79c8c0b6a18005..e9ca37844f86d07d1e4ae38b28c1e9b1b0160c44 100644 (file)
@@ -9,3 +9,4 @@
 09_use-of-newer-debhelper.patch
 10_add-info-about-h-option.patch
 11_remove-obsolete-bios-workaround.patch
+12_save-errno-for-second-command.patch
index fcf413958586b20f986839177a719b0607824c2b..de8414a77263df3598d7522bacbc4d6146c24b41 100644 (file)
@@ -9,3 +9,4 @@
 09_use-of-newer-debhelper.patch
 10_add-info-about-h-option.patch
 11_remove-obsolete-bios-workaround.patch
+12_save-errno-for-second-command.patch