* vms-misc.c (_bfd_vms_save_counted_string): Count length byte
towards maxlen.
+2020-10-25 Alan Modra <amodra@gmail.com>
+
+ * vms-misc.c (_bfd_vms_save_counted_string): Count length byte
+ towards maxlen.
+
2020-10-20 Dr. David Alan Gilbert <dgilbert@redhat.com>
* po/es.po: Fix printf format.
char *
_bfd_vms_save_counted_string (bfd *abfd, unsigned char *ptr, size_t maxlen)
{
- unsigned int len = *ptr++;
+ unsigned int len;
- if (len > maxlen)
+ if (maxlen == 0)
+ return NULL;
+ len = *ptr++;
+ if (len > maxlen - 1)
return NULL;
return _bfd_vms_save_sized_string (abfd, ptr, len);
}