Commit bc8fc5ad authored by Joachim Wiedorn's avatar Joachim Wiedorn

Fix: save errno for second command

parent 707454d4
......@@ -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
......
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,
......@@ -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
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment