* po/da.po: Updated Danish translation.
[deliverable/binutils-gdb.git] / binutils / resres.c
index 8b75bcf59422cfe317e39b6a2da2c4b138809217..2ad40b481a39fa9532299f9cab5e0cdc6b1dc9d7 100644 (file)
@@ -1,5 +1,5 @@
 /* resres.c: read_res_file and write_res_file implementation for windres.
-   Copyright 1998, 1999, 2001, 2002, 2007
+   Copyright 1998, 1999, 2001, 2002, 2007, 2008
    Free Software Foundation, Inc.
    Written by Anders Norlander <anorland@hem2.passagen.se>.
    Rewritten by Kai Tietz, Onevision.
@@ -8,7 +8,7 @@
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -128,13 +128,11 @@ write_res_file (const char *fn,const rc_res_directory *resdir)
   filename = fn;
 
   abfd = windres_open_as_binary (filename, 0);
-  sec = bfd_make_section (abfd, ".data");
+  sec = bfd_make_section_with_flags (abfd, ".data",
+                                    (SEC_HAS_CONTENTS | SEC_ALLOC
+                                     | SEC_LOAD | SEC_DATA));
   if (sec == NULL)
     bfd_fatal ("bfd_make_section");
-  if (! bfd_set_section_flags (abfd, sec,
-                              (SEC_HAS_CONTENTS | SEC_ALLOC
-                               | SEC_LOAD | SEC_DATA)))
-    bfd_fatal ("bfd_set_section_flags");
   /* Requiring this is probably a bug in BFD.  */
   sec->output_section = sec;
 
@@ -157,8 +155,8 @@ write_res_file (const char *fn,const rc_res_directory *resdir)
                                          (const rc_res_id *) NULL,
                                          &language, 1);
   if (sec_length != sec_length_wrote)
-    fatal ("res write failed with different sizes (%lu/%lu).", (long) sec_length,
-          (long) sec_length_wrote);
+    fatal ("res write failed with different sizes (%lu/%lu).",
+          (unsigned long) sec_length, (unsigned long) sec_length_wrote);
 
   bfd_close (abfd);
   return;
@@ -554,10 +552,12 @@ read_unistring (windres_bfd *wrbfd, rc_uint_type *off, rc_uint_type omax,
   rc_uint_type l;
   rc_uint_type soff = off[0];
 
-  do {
-    read_res_data (wrbfd, &soff, omax, d, sizeof (unichar));
-    c = windres_get_16 (wrbfd, d, 2);
-  } while (c != 0);
+  do
+    {
+      read_res_data (wrbfd, &soff, omax, d, sizeof (unichar));
+      c = windres_get_16 (wrbfd, d, 2);
+    }
+  while (c != 0);
   l = ((soff - off[0]) / sizeof (unichar));
 
   /* there are hardly any names longer than 256 characters, but anyway. */
@@ -592,8 +592,11 @@ probe_binary (windres_bfd *wrbfd, rc_uint_type omax)
   if ((off + BIN_RES_HDR_SIZE) >= omax)
     return 1;
   read_res_data_hdr (wrbfd, &off, omax, &reshdr);
-  if ((off + reshdr.data_size + reshdr.header_size) > omax)
-      return 0;
+  /* off is advanced by BIN_RES_HDR_SIZE in read_res_data_hdr()
+     which is part of reshdr.header_size. We shouldn't take it
+     into account twice.  */
+  if ((off - BIN_RES_HDR_SIZE + reshdr.data_size + reshdr.header_size) > omax)
+    return 0;
   return 1;
 }
 
This page took 0.023726 seconds and 4 git commands to generate.