goto fail;
core_regsec (abfd)->vma = 0;
- strncpy (core_command (abfd), u.u_comm, MAXCOMLEN + 1);
+ strncpy (core_command (abfd), u.u_comm, MAXCOMLEN);
+ core_command (abfd)[MAXCOMLEN] = 0;
core_signal (abfd) = u.u_code;
return _bfd_no_cleanup;
struct proc_exec proc_exec;
if (bfd_read (&proc_exec, core_header.len, abfd) != core_header.len)
break;
- strncpy (core_command (abfd), proc_exec.cmd, MAXCOMLEN + 1);
+ strncpy (core_command (abfd), proc_exec.cmd, MAXCOMLEN);
+ core_command (abfd)[MAXCOMLEN] = 0;
good_sections++;
}
break;
if (!core_hdr (abfd))
return NULL;
- strncpy (core_command (abfd), coreout.c_name, CORE_NAMESIZE);
+ strncpy (core_command (abfd), coreout.c_name, CORE_NAMESIZE - 1);
+ core_command (abfd)[CORE_NAMESIZE - 1] = 0;
core_signal (abfd) = coreout.c_sigcause;
if (bfd_seek (abfd, coreout.c_vmapoffset, SEEK_SET) != 0)
if (!core_hdr (abfd))
return NULL;
- strncpy (core_command (abfd), pss.pname, PNMLEN + 1);
+ strncpy (core_command (abfd), pss.pname, PNMLEN);
+ core_command (abfd)[PNMLEN] = 0;
/* Compute the size of the thread contexts */
int ret;
ret = bfd_mach_o_core_fetch_environment (abfd, &buf, &len);
- if (ret < 0)
+ if (ret < 0 || len == 0)
return NULL;
-
+ buf[len - 1] = 0;
return (char *) buf;
}
if (!core_hdr (abfd))
return NULL;
- strncpy (core_command (abfd), core_header.name, MAXCOMLEN + 1);
+ strncpy (core_command (abfd), core_header.name, MAXCOMLEN);
+ core_command (abfd)[MAXCOMLEN] = 0;
core_signal (abfd) = core_header.signo;
for (i = 0; i < core_header.nscns; i++)