From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13438 invoked by alias); 13 Nov 2012 09:51:28 -0000 Received: (qmail 13430 invoked by uid 22791); 13 Nov 2012 09:51:27 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,KHOP_THREADED,MSGID_MULTIPLE_AT,TW_XS X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.151) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 13 Nov 2012 09:51:19 +0000 Received: from md13.u-strasbg.fr (md13.u-strasbg.fr [130.79.200.248]) by mailhost.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id qAD9oqkN010229 ; Tue, 13 Nov 2012 10:50:52 +0100 (CET) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from mailserver.u-strasbg.fr (ms17.u-strasbg.fr [130.79.204.117]) by md13.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id qAD9opxO023098 ; Tue, 13 Nov 2012 10:50:51 +0100 (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from E6510Muller (lec67-4-82-230-53-140.fbx.proxad.net [82.230.53.140]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id qAD9om8J007302 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) ; Tue, 13 Nov 2012 10:50:49 +0100 (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: "'Joel Brobecker'" Cc: "'Tom Tromey'" , "'Andreas Schwab'" , References: <4297.05661158568$1352387430@news.gmane.org> <87d2znhj7t.fsf@fleche.redhat.com> <000001cdc061$dad58740$908095c0$@muller@ics-cnrs.unistra.fr> <20121112160741.GT5103@adacore.com> In-Reply-To: <20121112160741.GT5103@adacore.com> Subject: RE: [RFA-v2] ARI fixes: Remove some sprintf calls Date: Tue, 13 Nov 2012 09:51:00 -0000 Message-ID: <006301cdc184$5d925f50$18b71df0$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0064_01CDC18C.BF56C750" Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-11/txt/msg00307.txt.bz2 This is a multi-part message in MIME format. ------=_NextPart_000_0064_01CDC18C.BF56C750 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-length: 4845 > -----Message d'origine----- > De=A0: gdb-patches-owner@sourceware.org [mailto:gdb-patches- > owner@sourceware.org] De la part de Joel Brobecker > Envoy=E9=A0: lundi 12 novembre 2012 17:08 > =C0=A0: Pierre Muller > Cc=A0: 'Tom Tromey'; 'Andreas Schwab'; gdb-patches@sourceware.org > Objet=A0: Re: [RFA-v2] ARI fixes: Remove some sprintf calls >=20 > > 2012-11-11 Pierre Muller > > > > 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. >=20 > This is a nice improvement. Thanks. =20 > I'm wondering if there is any way to provoke an error if we ever > use sprintf again... I am asking because I know that it's easy to > ignore the ARI. I kind of remember not being able to do that, but > perhaps wrong memory. #poison, maybe? As long as we can get also compilers that don't know about #poison to also generate an error if sprint is used, everything is fine. =20 > A few nits... I think it's good to go, after the trivial nits are > corrected. I committed the patch after the modification you suggested below. =20 > Thanks for doing this! >=20 > > Index: nto-tdep.c > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > RCS file: /cvs/src/src/gdb/nto-tdep.c,v > > retrieving revision 1.46 > > diff -u -p -r1.46 nto-tdep.c > > --- nto-tdep.c 9 Nov 2012 19:58:00 -0000 1.46 > > +++ nto-tdep.c 11 Nov 2012 22:42:47 -0000 > > @@ -89,7 +89,7 @@ nto_find_and_open_solib (char *solib, un > > char *buf, *arch_path, *nto_root, *endian; > > const char *base; > > const char *arch; > > - int ret; > > + int archlen, len, ret; >=20 > Can we use "arch_len" instead if "archlen". This would be more in > line with "arch_path", and since both are related... It's also more > in line with the GNU Coding Style, I believe, where we use underscores > to separate words in identifier names. Done.=20 > > + archlen =3D strlen (nto_root) + strlen (arch) + strlen (endian) + 2 > > + + strlen (solib); >=20 > Another tiny nit. GCS require that we put the RHS expression inside > parentheses (to help tools format it correctly). Thus: I hope to correctly understand that you mean that this is for multi-line expressions only... =20 > arch_len =3D (strlen (nto_root) + strlen (arch) + strlen (endian) + 2 > + strlen (solib)); Done.=20 >=20 > > if (!noerror) > > { > > - char *name =3D alloca (strlen (s->filename) + 100); > > - sprintf (name, "%d\t%s", line, s->filename); > > + int len =3D strlen (s->filename) + 100; > > + char *name =3D alloca (len); > > + xsnprintf (name, len, "%d\t%s", line, s->filename); >=20 > Can you add an empty line between variable defs and the rest > of the code? I didn't add them if they were not present... There are of course lots of other places were those are missing, but you are right that we should correct those error if we modify the corresponding code. =20 > > +++ windows-nat.c 11 Nov 2012 22:51:49 -0000 > > @@ -1895,7 +1895,7 @@ windows_pid_to_exec_file (int pid) > > /* Try to find exe name as symlink target of /proc//exe. */ > > int nchars; > > char procexe[sizeof ("/proc/4294967295/exe")]; > > - sprintf (procexe, "/proc/%u/exe", pid); > > + xsnprintf (procexe, sizeof (procexe), "/proc/%u/exe", pid); >=20 > Same here, please? Done.=20 > > #else > > - cygallargs =3D (char *) > > - alloca (sizeof (" -c 'exec '") + strlen (exec_file) > > - + strlen (allargs) + 2); > > - sprintf (cygallargs, " -c 'exec %s %s'", exec_file, allargs); > > + len =3D sizeof (" -c 'exec '") + strlen (exec_file) > > + + strlen (allargs) + 2; >=20 > Can you enclose the RSH expression between parentheses? Final committed patch is attached. ChangeLog is unchanged. Thanks for the approval, Pierre Muller as ARI maintainer ------=_NextPart_000_0064_01CDC18C.BF56C750 Content-Type: application/octet-stream; name="sprintf-v2.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="sprintf-v2.patch" Content-length: 15260 projecttype:gdb=0A= revision:HEAD=0A= email:muller@ics.u-strasbg.fr=0A= =0A= 2012-11-13 Pierre Muller =0A= =0A= ARI fixes: Avoid sprintf function use rule.=0A= * charset.c (convert_between_encodings): Use xsnprintf.=0A= * cli-out.c (cli_field_int): Likewise.=0A= * cp-namespace.c (cp_lookup_nested_symbol): Likewise.=0A= * expprint.c (op_name_standard): Likewise.=0A= * frv-tdep.c (set_variant_num_gprs): Likewise.=0A= (set_variant_num_fprs): Likewise.=0A= * m68hc11-tdep.c (m68hc11_initialize_register_info): Likewise.=0A= * nto-tdep.c (nto_find_and_open_solib): Likewise.=0A= (nto_init_solib_absolute_prefix): Likewise.=0A= * source.c (init_source_path): Likewise.=0A= (print_source_lines_base): Likewise.=0A= * valprint.c (print_wchar): Likewise.=0A= * mi/mi-out.c (mi_field_int): Likewise.=0A= windows-nat.c (windows_pid_to_exec_file): Likewise.=0A= (windows_create_inferior): Likewise.=0A= (_initialize_check_for_gdb_ini): Likewise.=0A= =0A= =0A= Index: charset.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/charset.c,v=0A= retrieving revision 1.50=0A= diff -u -p -r1.50 charset.c=0A= --- charset.c 17 Apr 2012 15:47:09 -0000 1.50=0A= +++ charset.c 13 Nov 2012 08:34:33 -0000=0A= @@ -531,7 +531,7 @@ convert_between_encodings (const char *f=0A= {=0A= char octal[5];=0A= =20=0A= - sprintf (octal, "\\%.3o", *inp & 0xff);=0A= + xsnprintf (octal, sizeof (octal), "\\%.3o", *inp & 0xff);=0A= obstack_grow_str (output, octal);=0A= =20=0A= ++inp;=0A= Index: cli-out.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/cli-out.c,v=0A= retrieving revision 1.34=0A= diff -u -p -r1.34 cli-out.c=0A= --- cli-out.c 4 Jan 2012 08:17:00 -0000 1.34=0A= +++ cli-out.c 13 Nov 2012 08:34:34 -0000=0A= @@ -139,7 +139,7 @@ cli_field_int (struct ui_out *uiout, int=0A= =20=0A= if (data->suppress_output)=0A= return;=0A= - sprintf (buffer, "%d", value);=0A= + xsnprintf (buffer, sizeof (buffer), "%d", value);=0A= =20=0A= /* Always go through the function pointer (virtual function call).=0A= We may have been extended. */=0A= Index: cp-namespace.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/cp-namespace.c,v=0A= retrieving revision 1.58=0A= diff -u -p -r1.58 cp-namespace.c=0A= --- cp-namespace.c 13 Jun 2012 16:10:07 -0000 1.58=0A= +++ cp-namespace.c 13 Nov 2012 08:34:34 -0000=0A= @@ -688,6 +688,7 @@ cp_lookup_nested_symbol (struct type *pa=0A= just like members of namespaces; in particular,=0A= lookup_symbol_namespace works when looking them up. */=0A= =20=0A= + int size;=0A= const char *parent_name =3D type_name_no_tag_or_error (saved_parent_type)= ;=0A= struct symbol *sym=0A= =3D cp_lookup_symbol_in_namespace (parent_name, nested_name,=0A= @@ -703,9 +704,9 @@ cp_lookup_nested_symbol (struct type *pa=0A= namespace seach is is already not C++ compliant and more=0A= assumptions could make it too magic. */=0A= =20=0A= - concatenated_name =3D alloca (strlen (parent_name) + 2=0A= - + strlen (nested_name) + 1);=0A= - sprintf (concatenated_name, "%s::%s",=0A= + size =3D strlen (parent_name) + 2 + strlen (nested_name) + 1;=0A= + concatenated_name =3D alloca (size);=0A= + xsnprintf (concatenated_name, size, "%s::%s",=0A= parent_name, nested_name);=0A= sym =3D lookup_static_symbol_aux (concatenated_name, VAR_DOMAIN);=0A= if (sym !=3D NULL)=0A= Index: expprint.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/expprint.c,v=0A= retrieving revision 1.62=0A= diff -u -p -r1.62 expprint.c=0A= --- expprint.c 2 Nov 2012 00:14:37 -0000 1.62=0A= +++ expprint.c 13 Nov 2012 08:34:34 -0000=0A= @@ -670,7 +670,7 @@ op_name_standard (enum exp_opcode opcode=0A= {=0A= static char buf[30];=0A= =20=0A= - sprintf (buf, "", opcode);=0A= + xsnprintf (buf, sizeof (buf), "", opcode);=0A= return buf;=0A= }=0A= #define OP(name) \=0A= Index: frv-tdep.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/frv-tdep.c,v=0A= retrieving revision 1.138=0A= diff -u -p -r1.138 frv-tdep.c=0A= --- frv-tdep.c 18 May 2012 21:02:47 -0000 1.138=0A= +++ frv-tdep.c 13 Nov 2012 08:34:35 -0000=0A= @@ -233,7 +233,7 @@ set_variant_num_gprs (struct gdbarch_tde=0A= {=0A= char buf[20];=0A= =20=0A= - sprintf (buf, "gr%d", r);=0A= + xsnprintf (buf, sizeof (buf), "gr%d", r);=0A= var->register_names[first_gpr_regnum + r] =3D xstrdup (buf);=0A= }=0A= }=0A= @@ -252,7 +252,7 @@ set_variant_num_fprs (struct gdbarch_tde=0A= {=0A= char buf[20];=0A= =20=0A= - sprintf (buf, "fr%d", r);=0A= + xsnprintf (buf, sizeof (buf), "fr%d", r);=0A= var->register_names[first_fpr_regnum + r] =3D xstrdup (buf);=0A= }=0A= }=0A= Index: m68hc11-tdep.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/m68hc11-tdep.c,v=0A= retrieving revision 1.140=0A= diff -u -p -r1.140 m68hc11-tdep.c=0A= --- m68hc11-tdep.c 25 Sep 2012 12:48:53 -0000 1.140=0A= +++ m68hc11-tdep.c 13 Nov 2012 08:34:35 -0000=0A= @@ -247,7 +247,7 @@ m68hc11_initialize_register_info (void)=0A= {=0A= char buf[10];=0A= =20=0A= - sprintf (buf, "_.d%d", i - SOFT_D1_REGNUM + 1);=0A= + xsnprintf (buf, sizeof (buf), "_.d%d", i - SOFT_D1_REGNUM + 1);=0A= m68hc11_get_register_info (&soft_regs[i], buf);=0A= }=0A= =20=0A= Index: nto-tdep.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/nto-tdep.c,v=0A= retrieving revision 1.46=0A= diff -u -p -r1.46 nto-tdep.c=0A= --- nto-tdep.c 9 Nov 2012 19:58:00 -0000 1.46=0A= +++ nto-tdep.c 13 Nov 2012 08:34:35 -0000=0A= @@ -89,7 +89,7 @@ nto_find_and_open_solib (char *solib, un=0A= char *buf, *arch_path, *nto_root, *endian;=0A= const char *base;=0A= const char *arch;=0A= - int ret;=0A= + int arch_len, len, ret;=0A= #define PATH_FMT \=0A= "%s/lib:%s/usr/lib:%s/usr/photon/lib:%s/usr/photon/dll:%s/lib/dll"=0A= =20=0A= @@ -116,20 +116,22 @@ nto_find_and_open_solib (char *solib, un=0A= =20=0A= /* In case nto_root is short, add strlen(solib)=0A= so we can reuse arch_path below. */=0A= - arch_path =3D=0A= - alloca (strlen (nto_root) + strlen (arch) + strlen (endian) + 2 +=0A= - strlen (solib));=0A= - sprintf (arch_path, "%s/%s%s", nto_root, arch, endian);=0A= -=0A= - buf =3D alloca (strlen (PATH_FMT) + strlen (arch_path) * 5 + 1);=0A= - sprintf (buf, PATH_FMT, arch_path, arch_path, arch_path, arch_path,=0A= - arch_path);=0A= +=0A= + arch_len =3D (strlen (nto_root) + strlen (arch) + strlen (endian) + 2=0A= + + strlen (solib));=0A= + arch_path =3D alloca (arch_len);=0A= + xsnprintf (arch_path, arch_len, "%s/%s%s", nto_root, arch, endian);=0A= +=0A= + len =3D strlen (PATH_FMT) + strlen (arch_path) * 5 + 1;=0A= + buf =3D alloca (len);=0A= + xsnprintf (buf, len, PATH_FMT, arch_path, arch_path, arch_path, arch_pat= h,=0A= + arch_path);=0A= =20=0A= base =3D lbasename (solib);=0A= ret =3D openp (buf, 1, base, o_flags, temp_pathname);=0A= if (ret < 0 && base !=3D solib)=0A= {=0A= - sprintf (arch_path, "/%s", solib);=0A= + xsnprintf (arch_path, arch_len, "/%s", solib);=0A= ret =3D open (arch_path, o_flags, 0);=0A= if (temp_pathname)=0A= {=0A= @@ -170,9 +172,9 @@ nto_init_solib_absolute_prefix (void)=0A= =3D=3D BFD_ENDIAN_BIG ? "be" : "le";=0A= }=0A= =20=0A= - sprintf (arch_path, "%s/%s%s", nto_root, arch, endian);=0A= + xsnprintf (arch_path, sizeof (arch_path), "%s/%s%s", nto_root, arch, end= ian);=0A= =20=0A= - sprintf (buf, "set solib-absolute-prefix %s", arch_path);=0A= + xsnprintf (buf, sizeof (buf), "set solib-absolute-prefix %s", arch_path)= ;=0A= execute_command (buf, 0);=0A= }=0A= =20=0A= Index: source.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/source.c,v=0A= retrieving revision 1.140=0A= diff -u -p -r1.140 source.c=0A= --- source.c 9 Nov 2012 13:23:32 -0000 1.140=0A= +++ source.c 13 Nov 2012 08:34:36 -0000=0A= @@ -384,7 +384,7 @@ init_source_path (void)=0A= {=0A= char buf[20];=0A= =20=0A= - sprintf (buf, "$cdir%c$cwd", DIRNAME_SEPARATOR);=0A= + xsnprintf (buf, sizeof (buf), "$cdir%c$cwd", DIRNAME_SEPARATOR);=0A= source_path =3D xstrdup (buf);=0A= forget_cached_source_info ();=0A= }=0A= @@ -1292,8 +1292,10 @@ print_source_lines_base (struct symtab *=0A= =20=0A= if (!noerror)=0A= {=0A= - char *name =3D alloca (strlen (s->filename) + 100);=0A= - sprintf (name, "%d\t%s", line, s->filename);=0A= + int len =3D strlen (s->filename) + 100;=0A= + char *name =3D alloca (len);=0A= +=0A= + xsnprintf (name, len, "%d\t%s", line, s->filename);=0A= print_sys_errmsg (name, errno);=0A= }=0A= else=0A= @@ -1344,13 +1346,13 @@ print_source_lines_base (struct symtab *=0A= if (c =3D=3D EOF)=0A= break;=0A= last_line_listed =3D current_source_line;=0A= - sprintf (buf, "%d\t", current_source_line++);=0A= + xsnprintf (buf, sizeof (buf), "%d\t", current_source_line++);=0A= ui_out_text (uiout, buf);=0A= do=0A= {=0A= if (c < 040 && c !=3D '\t' && c !=3D '\n' && c !=3D '\r')=0A= {=0A= - sprintf (buf, "^%c", c + 0100);=0A= + xsnprintf (buf, sizeof (buf), "^%c", c + 0100);=0A= ui_out_text (uiout, buf);=0A= }=0A= else if (c =3D=3D 0177)=0A= @@ -1367,7 +1369,7 @@ print_source_lines_base (struct symtab *=0A= }=0A= else=0A= {=0A= - sprintf (buf, "%c", c);=0A= + xsnprintf (buf, sizeof (buf), "%c", c);=0A= ui_out_text (uiout, buf);=0A= }=0A= }=0A= Index: valprint.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/valprint.c,v=0A= retrieving revision 1.130=0A= diff -u -p -r1.130 valprint.c=0A= --- valprint.c 10 Nov 2012 20:19:00 -0000 1.130=0A= +++ valprint.c 13 Nov 2012 08:34:36 -0000=0A= @@ -1974,9 +1974,10 @@ print_wchar (gdb_wint_t w, const gdb_byt=0A= /* If the value fits in 3 octal digits, print it that=0A= way. Otherwise, print it as a hex escape. */=0A= if (value <=3D 0777)=0A= - sprintf (octal, "\\%.3o", (int) (value & 0777));=0A= + xsnprintf (octal, sizeof (octal), "\\%.3o",=0A= + (int) (value & 0777));=0A= else=0A= - sprintf (octal, "\\x%lx", (long) value);=0A= + xsnprintf (octal, sizeof (octal), "\\x%lx", (long) value);=0A= append_string_as_wide (octal, output);=0A= }=0A= /* If we somehow have extra bytes, print them now. */=0A= @@ -1984,7 +1985,7 @@ print_wchar (gdb_wint_t w, const gdb_byt=0A= {=0A= char octal[5];=0A= =20=0A= - sprintf (octal, "\\%.3o", orig[i] & 0xff);=0A= + xsnprintf (octal, sizeof (octal), "\\%.3o", orig[i] & 0xff);=0A= append_string_as_wide (octal, output);=0A= ++i;=0A= }=0A= Index: mi/mi-out.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/mi/mi-out.c,v=0A= retrieving revision 1.43=0A= diff -u -p -r1.43 mi-out.c=0A= --- mi/mi-out.c 6 Mar 2012 22:48:53 -0000 1.43=0A= +++ mi/mi-out.c 13 Nov 2012 08:34:37 -0000=0A= @@ -198,7 +198,7 @@ mi_field_int (struct ui_out *uiout, int=20=0A= if (data->suppress_output)=0A= return;=0A= =20=0A= - sprintf (buffer, "%d", value);=0A= + xsnprintf (buffer, sizeof (buffer), "%d", value);=0A= mi_field_string (uiout, fldno, width, alignment, fldname, buffer);=0A= }=0A= =20=0A= Index: windows-nat.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/windows-nat.c,v=0A= retrieving revision 1.235=0A= diff -u -p -r1.235 windows-nat.c=0A= --- windows-nat.c 9 Nov 2012 19:58:02 -0000 1.235=0A= +++ windows-nat.c 13 Nov 2012 09:28:25 -0000=0A= @@ -1895,7 +1895,8 @@ windows_pid_to_exec_file (int pid)=0A= /* Try to find exe name as symlink target of /proc//exe. */=0A= int nchars;=0A= char procexe[sizeof ("/proc/4294967295/exe")];=0A= - sprintf (procexe, "/proc/%u/exe", pid);=0A= +=0A= + xsnprintf (procexe, sizeof (procexe), "/proc/%u/exe", pid);=0A= nchars =3D readlink (procexe, path, sizeof(path));=0A= if (nchars > 0 && nchars < sizeof (path))=0A= {=0A= @@ -2093,10 +2094,10 @@ windows_create_inferior (struct target_o=0A= cygallargs =3D (wchar_t *) alloca (len * sizeof (wchar_t));=0A= swprintf (cygallargs, len, L" -c 'exec %s %s'", exec_file, allargs);= =0A= #else=0A= - cygallargs =3D (char *)=0A= - alloca (sizeof (" -c 'exec '") + strlen (exec_file)=0A= - + strlen (allargs) + 2);=0A= - sprintf (cygallargs, " -c 'exec %s %s'", exec_file, allargs);=0A= + len =3D (sizeof (" -c 'exec '") + strlen (exec_file)=0A= + + strlen (allargs) + 2);=0A= + cygallargs =3D (char *) alloca (len);=0A= + xsnprintf (cygallargs, len, " -c 'exec %s %s'", exec_file, allargs);= =0A= #endif=0A= toexec =3D shell;=0A= flags |=3D DEBUG_PROCESS;=0A= @@ -2724,8 +2725,9 @@ _initialize_check_for_gdb_ini (void)=0A= {=0A= int len =3D strlen (oldini);=0A= char *newini =3D alloca (len + 1);=0A= - sprintf (newini, "%.*s.gdbinit",=0A= - (int) (len - (sizeof ("gdb.ini") - 1)), oldini);=0A= +=0A= + xsnprintf (newini, len + 1, "%.*s.gdbinit",=0A= + (int) (len - (sizeof ("gdb.ini") - 1)), oldini);=0A= warning (_("obsolete '%s' found. Rename to '%s'."), oldini, newini);=0A= }=0A= }=0A= ------=_NextPart_000_0064_01CDC18C.BF56C750--