aboutsummaryrefslogtreecommitdiff
path: root/gdb/nto-tdep.c
diff options
context:
space:
mode:
authorPierre Muller <muller@sourceware.org>2012-11-13 09:46:11 +0000
committerPierre Muller <muller@sourceware.org>2012-11-13 09:46:11 +0000
commit08850b56edd752c3792bfb9bfc59dd9a5577ac2d (patch)
treedc5581a48e546d35ecdbb5a832c0a83185cb585e /gdb/nto-tdep.c
parentcec6a5b82ba19f3d8155503da6d7313c9321fcf6 (diff)
downloadgdb-08850b56edd752c3792bfb9bfc59dd9a5577ac2d.zip
gdb-08850b56edd752c3792bfb9bfc59dd9a5577ac2d.tar.gz
gdb-08850b56edd752c3792bfb9bfc59dd9a5577ac2d.tar.bz2
ARI fixes: Avoid sprintf function use rule.
* charset.c (convert_between_encodings): Use xsnprintf. * cli-out.c (cli_field_int): Likewise. * cp-namespace.c (cp_lookup_nested_symbol): Likewise. * expprint.c (op_name_standard): Likewise. * frv-tdep.c (set_variant_num_gprs): Likewise. (set_variant_num_fprs): Likewise. * m68hc11-tdep.c (m68hc11_initialize_register_info): Likewise. * nto-tdep.c (nto_find_and_open_solib): Likewise. (nto_init_solib_absolute_prefix): Likewise. * source.c (init_source_path): Likewise. (print_source_lines_base): Likewise. * valprint.c (print_wchar): Likewise. * mi/mi-out.c (mi_field_int): Likewise. windows-nat.c (windows_pid_to_exec_file): Likewise. (windows_create_inferior): Likewise. (_initialize_check_for_gdb_ini): Likewise.
Diffstat (limited to 'gdb/nto-tdep.c')
-rw-r--r--gdb/nto-tdep.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/gdb/nto-tdep.c b/gdb/nto-tdep.c
index 7c48946..dff87bb 100644
--- a/gdb/nto-tdep.c
+++ b/gdb/nto-tdep.c
@@ -89,7 +89,7 @@ nto_find_and_open_solib (char *solib, unsigned o_flags, char **temp_pathname)
char *buf, *arch_path, *nto_root, *endian;
const char *base;
const char *arch;
- int ret;
+ int arch_len, len, ret;
#define PATH_FMT \
"%s/lib:%s/usr/lib:%s/usr/photon/lib:%s/usr/photon/dll:%s/lib/dll"
@@ -116,20 +116,22 @@ nto_find_and_open_solib (char *solib, unsigned o_flags, char **temp_pathname)
/* In case nto_root is short, add strlen(solib)
so we can reuse arch_path below. */
- arch_path =
- alloca (strlen (nto_root) + strlen (arch) + strlen (endian) + 2 +
- strlen (solib));
- sprintf (arch_path, "%s/%s%s", nto_root, arch, endian);
- buf = alloca (strlen (PATH_FMT) + strlen (arch_path) * 5 + 1);
- sprintf (buf, PATH_FMT, arch_path, arch_path, arch_path, arch_path,
- arch_path);
+ arch_len = (strlen (nto_root) + strlen (arch) + strlen (endian) + 2
+ + strlen (solib));
+ arch_path = alloca (arch_len);
+ xsnprintf (arch_path, arch_len, "%s/%s%s", nto_root, arch, endian);
+
+ len = strlen (PATH_FMT) + strlen (arch_path) * 5 + 1;
+ buf = alloca (len);
+ xsnprintf (buf, len, PATH_FMT, arch_path, arch_path, arch_path, arch_path,
+ arch_path);
base = lbasename (solib);
ret = openp (buf, 1, base, o_flags, temp_pathname);
if (ret < 0 && base != solib)
{
- sprintf (arch_path, "/%s", solib);
+ xsnprintf (arch_path, arch_len, "/%s", solib);
ret = open (arch_path, o_flags, 0);
if (temp_pathname)
{
@@ -170,9 +172,9 @@ nto_init_solib_absolute_prefix (void)
== BFD_ENDIAN_BIG ? "be" : "le";
}
- sprintf (arch_path, "%s/%s%s", nto_root, arch, endian);
+ xsnprintf (arch_path, sizeof (arch_path), "%s/%s%s", nto_root, arch, endian);
- sprintf (buf, "set solib-absolute-prefix %s", arch_path);
+ xsnprintf (buf, sizeof (buf), "set solib-absolute-prefix %s", arch_path);
execute_command (buf, 0);
}