2012-11-26  Maxime Villard  <rustyBSD@gmx.fr>
	    Pedro Alves  <palves@redhat.com>

	* common/linux-osdata.c (linux_xfer_osdata_fds): Decrease buffer
	size parameter passed to readlink by one byte.
	* fbsd-nat.c (fbsd_pid_to_exec_file): Ditto.
	* linux-nat.c (linux_child_pid_to_exec_file): Ditto.
	* nbsd-nat.c (nbsd_pid_to_exec_file): Ditto.
	* inf-child.c (inf_child_fileio_readlink): Decrease local buffer's
	size by one byte.

gdb/gdbserver/
2012-11-26  Maxime Villard  <rustyBSD@gmx.fr>

	* hostio.c (handle_readlink): Decrease buffer size
	parameter passed to readlink by one byte.
This commit is contained in:
Pedro Alves 2012-11-26 14:19:33 +00:00
parent 8c29b58e98
commit 0270a750ba
8 changed files with 22 additions and 6 deletions

View file

@ -1,3 +1,14 @@
2012-11-26 Maxime Villard <rustyBSD@gmx.fr>
Pedro Alves <palves@redhat.com>
* common/linux-osdata.c (linux_xfer_osdata_fds): Decrease buffer
size parameter passed to readlink by one byte.
* fbsd-nat.c (fbsd_pid_to_exec_file): Ditto.
* linux-nat.c (linux_child_pid_to_exec_file): Ditto.
* nbsd-nat.c (nbsd_pid_to_exec_file): Ditto.
* inf-child.c (inf_child_fileio_readlink): Decrease local buffer's
size by one byte.
2012-11-26 Yao Qi <yao@codesourcery.com>
* f-valprint.c (f77_create_arrayprint_offset_tbl): Remove

View file

@ -737,7 +737,7 @@ linux_xfer_osdata_fds (gdb_byte *readbuf,
continue;
fdname = xstrprintf ("%s/%s", pathname, dp2->d_name);
rslt = readlink (fdname, buf, 1000);
rslt = readlink (fdname, buf, sizeof (buf) - 1);
if (rslt >= 0)
buf[rslt] = '\0';

View file

@ -55,7 +55,7 @@ fbsd_pid_to_exec_file (int pid)
#endif
path = xstrprintf ("/proc/%d/file", pid);
if (readlink (path, buf, MAXPATHLEN) == -1)
if (readlink (path, buf, MAXPATHLEN - 1) == -1)
{
xfree (buf);
buf = NULL;

View file

@ -1,3 +1,8 @@
2012-11-26 Maxime Villard <rustyBSD@gmx.fr>
* hostio.c (handle_readlink): Decrease buffer size
parameter passed to readlink by one byte.
2012-11-26 Yao Qi <yao@codesourcery.com>
* configure.ac (build_warnings): Append '-Wempty-body'.

View file

@ -483,7 +483,7 @@ handle_readlink (char *own_buf, int *new_packet_len)
return;
}
ret = readlink (filename, linkname, sizeof linkname);
ret = readlink (filename, linkname, sizeof (linkname) - 1);
if (ret == -1)
{
hostio_error (own_buf);

View file

@ -346,7 +346,7 @@ inf_child_fileio_readlink (const char *filename, int *target_errno)
/* We support readlink only on systems that also provide a compile-time
maximum path length (MAXPATHLEN), at least for now. */
#if defined (HAVE_READLINK) && defined (MAXPATHLEN)
char buf[MAXPATHLEN];
char buf[MAXPATHLEN - 1];
int len;
char *ret;

View file

@ -4319,7 +4319,7 @@ linux_child_pid_to_exec_file (int pid)
memset (name2, 0, MAXPATHLEN);
sprintf (name1, "/proc/%d/exe", pid);
if (readlink (name1, name2, MAXPATHLEN) > 0)
if (readlink (name1, name2, MAXPATHLEN - 1) > 0)
return name2;
else
return name1;

View file

@ -34,7 +34,7 @@ nbsd_pid_to_exec_file (int pid)
char *path;
path = xstrprintf ("/proc/%d/exe", pid);
if (readlink (path, buf, MAXPATHLEN) == -1)
if (readlink (path, buf, MAXPATHLEN - 1) == -1)
{
xfree (buf);
buf = NULL;