projects
/
profile
/
ivi
/
syslinux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
d8f1d5b
)
loadfile: make sure we don't trash errno
author
H. Peter Anvin
<hpa@zytor.com>
Mon, 16 Jun 2008 00:03:18 +0000
(17:03 -0700)
committer
H. Peter Anvin
<hpa@zytor.com>
Mon, 16 Jun 2008 00:03:18 +0000
(17:03 -0700)
Make sure we don't trash a useful value in errno.
com32/lib/syslinux/loadfile.c
patch
|
blob
|
history
diff --git
a/com32/lib/syslinux/loadfile.c
b/com32/lib/syslinux/loadfile.c
index
42a1fd6
..
7ad8e81
100644
(file)
--- a/
com32/lib/syslinux/loadfile.c
+++ b/
com32/lib/syslinux/loadfile.c
@@
-31,6
+31,7
@@
* Read the contents of a data file into a malloc'd buffer
*/
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@
-45,14
+46,18
@@
int loadfile(const char *filename, void **ptr, size_t *len)
{
FILE *f;
- int rv;
+ int rv
, e
;
f = fopen(filename, "r");
if ( !f )
return -1;
rv = floadfile(f, ptr, len, NULL, 0);
+ e = errno;
+
fclose(f);
+ if (rv)
+ errno = e;
return rv;
}