]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - bfd/vms-misc.c
problem debugging ravenscar programs if runtime is stripped
[thirdparty/binutils-gdb.git] / bfd / vms-misc.c
index 5fdce508784be62caa5b5a52e0f3652a31876d59..91e2ec76c223bbdb35783cec7ae949d835456369 100644 (file)
@@ -1,6 +1,6 @@
 /* vms-misc.c -- BFD back-end for VMS/VAX (openVMS/VAX) and
    EVAX (openVMS/Alpha) files.
-   Copyright (C) 1996-2016 Free Software Foundation, Inc.
+   Copyright (C) 1996-2017 Free Software Foundation, Inc.
 
    Miscellaneous functions.
 
@@ -135,11 +135,11 @@ _bfd_hexdump (int level, unsigned char *ptr, int size, int offset)
 #endif
 \f
 
-/* Copy sized string (string with fixed size) to new allocated area
-   size is string size (size of record)  */
+/* Copy sized string (string with fixed size) to new allocated area.
+   Size is string size (size of record).  */
 
 char *
-_bfd_vms_save_sized_string (unsigned char *str, int size)
+_bfd_vms_save_sized_string (unsigned char *str, unsigned int size)
 {
   char *newstr = bfd_malloc ((bfd_size_type) size + 1);
 
@@ -151,14 +151,16 @@ _bfd_vms_save_sized_string (unsigned char *str, int size)
   return newstr;
 }
 
-/* Copy counted string (string with size at first byte) to new allocated area
-   ptr points to size byte on entry  */
+/* Copy counted string (string with size at first byte) to new allocated area.
+   PTR points to size byte on entry.  */
 
 char *
-_bfd_vms_save_counted_string (unsigned char *ptr)
+_bfd_vms_save_counted_string (unsigned char *ptr, unsigned int maxlen)
 {
-  int len = *ptr++;
+  unsigned int len = *ptr++;
 
+  if (len > maxlen)
+    return NULL;
   return _bfd_vms_save_sized_string (ptr, len);
 }
 \f