summaryrefslogtreecommitdiffstats
path: root/src/unstrip.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/unstrip.c')
-rw-r--r--src/unstrip.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/unstrip.c b/src/unstrip.c
index 50749093..6b4598c8 100644
--- a/src/unstrip.c
+++ b/src/unstrip.c
@@ -291,12 +291,13 @@ make_directories (const char *path)
if (lastslash == path)
return;
- char *dir = strndupa (path, lastslash - path);
+ char *dir = strndup (path, lastslash - path);
while (mkdir (dir, 0777) < 0 && errno != EEXIST)
if (errno == ENOENT)
make_directories (dir);
else
error (EXIT_FAILURE, errno, _("cannot create directory '%s'"), dir);
+ free (dir);
}
/* Keep track of new section data we are creating, so we can free it
@@ -2017,7 +2018,7 @@ DWARF data in '%s' not adjusted for prelinking bias; consider prelink -u"),
make_directories (output_file);
/* Copy the unstripped file and then modify it. */
- int outfd = open (output_file, O_RDWR | O_CREAT,
+ int outfd = open (output_file, O_RDWR | O_BINARY | O_CREAT,
stripped_ehdr->e_type == ET_REL ? 0666 : 0777);
if (outfd < 0)
error (EXIT_FAILURE, errno, _("cannot open '%s'"), output_file);
@@ -2047,7 +2048,7 @@ DWARF data in '%s' not adjusted for prelinking bias; consider prelink -u"),
static int
open_file (const char *file, bool writable)
{
- int fd = open (file, writable ? O_RDWR : O_RDONLY);
+ int fd = open (file, writable ? (O_RDWR | O_BINARY) : (O_RDONLY | O_BINARY));
if (fd < 0)
error (EXIT_FAILURE, errno, _("cannot open '%s'"), file);
return fd;