projects
/
deliverable
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ubsan: m10300: shift exponent -4
[deliverable/binutils-gdb.git]
/
bfd
/
vms-misc.c
diff --git
a/bfd/vms-misc.c
b/bfd/vms-misc.c
index 984004337d13e0338882fcec836f35110a98c954..d040c79de16ce761e5705eefe951d97160657fd6 100644
(file)
--- a/
bfd/vms-misc.c
+++ b/
bfd/vms-misc.c
@@
-1,7
+1,6
@@
/* vms-misc.c -- BFD back-end for VMS/VAX (openVMS/VAX) and
EVAX (openVMS/Alpha) files.
/* vms-misc.c -- BFD back-end for VMS/VAX (openVMS/VAX) and
EVAX (openVMS/Alpha) files.
- Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
- 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 1996-2020 Free Software Foundation, Inc.
Miscellaneous functions.
Miscellaneous functions.
@@
-136,31
+135,39
@@
_bfd_hexdump (int level, unsigned char *ptr, int size, int offset)
#endif
\f
#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 *
char *
-_bfd_vms_save_sized_string (
unsigned char *str, in
t size)
+_bfd_vms_save_sized_string (
bfd *abfd, unsigned char *str, size_
t size)
{
{
- char *newstr
= bfd_malloc ((bfd_size_type) size + 1)
;
+ char *newstr;
+ if (size == (size_t) -1)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return NULL;
+ }
+ newstr = bfd_alloc (abfd, size + 1);
if (newstr == NULL)
return NULL;
if (newstr == NULL)
return NULL;
- memcpy (newstr,
(char *) str, (size_t)
size);
+ memcpy (newstr,
str,
size);
newstr[size] = 0;
return newstr;
}
newstr[size] = 0;
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 *
char *
-_bfd_vms_save_counted_string (
unsigned char *ptr
)
+_bfd_vms_save_counted_string (
bfd *abfd, unsigned char *ptr, size_t maxlen
)
{
{
- int len = *ptr++;
+
unsigned
int len = *ptr++;
- return _bfd_vms_save_sized_string (ptr, len);
+ if (len > maxlen)
+ return NULL;
+ return _bfd_vms_save_sized_string (abfd, ptr, len);
}
\f
/* Object output routines. */
}
\f
/* Object output routines. */
@@
-251,7
+258,7
@@
_bfd_vms_output_end_subrec (struct vms_rec_wr *recwr)
/* Put length to buffer. */
bfd_putl16 ((bfd_vma) (recwr->size - recwr->subrec_offset),
/* Put length to buffer. */
bfd_putl16 ((bfd_vma) (recwr->size - recwr->subrec_offset),
-
recwr->buf + recwr->subrec_offset + 2);
+ recwr->buf + recwr->subrec_offset + 2);
/* Close the subrecord. */
recwr->subrec_offset = 0;
/* Close the subrecord. */
recwr->subrec_offset = 0;
@@
-357,12
+364,12
@@
_bfd_vms_output_counted (struct vms_rec_wr *recwr, const char *value)
len = strlen (value);
if (len == 0)
{
len = strlen (value);
if (len == 0)
{
-
(*_bfd_error_handler)
(_("_bfd_vms_output_counted called with zero bytes"));
+
_bfd_error_handler
(_("_bfd_vms_output_counted called with zero bytes"));
return;
}
if (len > 255)
{
return;
}
if (len > 255)
{
-
(*_bfd_error_handler)
(_("_bfd_vms_output_counted called with too many bytes"));
+
_bfd_error_handler
(_("_bfd_vms_output_counted called with too many bytes"));
return;
}
_bfd_vms_output_byte (recwr, (unsigned int) len & 0xff);
return;
}
_bfd_vms_output_byte (recwr, (unsigned int) len & 0xff);
@@
-401,8
+408,8
@@
_bfd_vms_output_fill (struct vms_rec_wr *recwr, int value, int count)
using undocumented system call sys$modify().
Pure VMS version. */
using undocumented system call sys$modify().
Pure VMS version. */
-void
-
_bfd_
vms_convert_to_var (char * vms_filename)
+
static
void
+vms_convert_to_var (char * vms_filename)
{
struct FAB fab = cc$rms_fab;
{
struct FAB fab = cc$rms_fab;
@@
-433,8
+440,8
@@
vms_convert_to_var_1 (char *filename, int type)
using undocumented system call sys$modify().
Unix filename version. */
using undocumented system call sys$modify().
Unix filename version. */
-
static
int
-vms_convert_to_var_unix_filename (const char *unix_filename)
+int
+
_bfd_
vms_convert_to_var_unix_filename (const char *unix_filename)
{
if (decc$to_vms (unix_filename, &vms_convert_to_var_1, 0, 1) != 1)
return FALSE;
{
if (decc$to_vms (unix_filename, &vms_convert_to_var_1, 0, 1) != 1)
return FALSE;
@@
-515,12
+522,12
@@
vms_get_module_name (const char *filename, bfd_boolean upcase)
for (fptr = fname; *fptr != 0; fptr++)
{
if (*fptr == ';' || (fptr - fname) >= 31)
for (fptr = fname; *fptr != 0; fptr++)
{
if (*fptr == ';' || (fptr - fname) >= 31)
-
{
-
*fptr = 0;
-
break;
-
}
+ {
+ *fptr = 0;
+ break;
+ }
if (upcase)
if (upcase)
-
*fptr = TOUPPER (*fptr);
+ *fptr = TOUPPER (*fptr);
}
return fname;
}
}
return fname;
}
@@
-530,7
+537,10
@@
vms_get_module_name (const char *filename, bfd_boolean upcase)
- 100ns granularity
- epoch is Nov 17, 1858.
Here has the constants and the routines used to convert VMS from/to UNIX time.
- 100ns granularity
- epoch is Nov 17, 1858.
Here has the constants and the routines used to convert VMS from/to UNIX time.
- The conversion routines don't assume 64 bits arithmetic. */
+ The conversion routines don't assume 64 bits arithmetic.
+
+ Here we assume that the definition of time_t is the UNIX one, ie integer
+ type, expressing seconds since the epoch. */
/* UNIX time granularity for VMS, ie 1s / 100ns. */
#define VMS_TIME_FACTOR 10000000
/* UNIX time granularity for VMS, ie 1s / 100ns. */
#define VMS_TIME_FACTOR 10000000
@@
-546,6
+556,7
@@
vms_time_to_time_t (unsigned int hi, unsigned int lo)
unsigned int tmp;
unsigned int rlo;
int i;
unsigned int tmp;
unsigned int rlo;
int i;
+ time_t res;
/* First convert to seconds. */
tmp = hi % VMS_TIME_FACTOR;
/* First convert to seconds. */
tmp = hi % VMS_TIME_FACTOR;
@@
-562,14
+573,18
@@
vms_time_to_time_t (unsigned int hi, unsigned int lo)
lo = rlo;
/* Return 0 in case of overflow. */
lo = rlo;
/* Return 0 in case of overflow. */
- if (lo > VMS_TIME_OFFSET && hi > 1)
+ if (hi > 1
+ || (hi == 1 && lo >= VMS_TIME_OFFSET))
return 0;
/* Return 0 in case of underflow. */
return 0;
/* Return 0 in case of underflow. */
- if (lo < VMS_TIME_OFFSET)
+ if (
hi == 0 &&
lo < VMS_TIME_OFFSET)
return 0;
return 0;
- return lo - VMS_TIME_OFFSET;
+ res = lo - VMS_TIME_OFFSET;
+ if (res <= 0)
+ return 0;
+ return res;
}
/* Convert a time_t to a VMS time. */
}
/* Convert a time_t to a VMS time. */
This page took
0.026807 seconds
and
4
git commands to generate.