Mailing List Archive

Re: [Xen-staging] [xen-unstable] Clean up arch_get_xen_caps() to not use sprintf().
On Tue, 2007-01-30 at 16:24 +0000, Xen staging patchbot-unstable wrote:
> diff -r bd69e83b65ea -r 9578ae319874 xen/arch/ia64/xen/xensetup.c
> --- a/xen/arch/ia64/xen/xensetup.c Tue Jan 30 16:14:16 2007 +0000
> +++ b/xen/arch/ia64/xen/xensetup.c Tue Jan 30 16:23:43 2007 +0000
> @@ -547,18 +547,19 @@ printk("num_online_cpus=%d, max_cpus=%d\
>
> void arch_get_xen_caps(xen_capabilities_info_t info)
> {
> - char *p=info;
> int major = xen_major_version();
> int minor = xen_minor_version();
> -
> - p += snprintf(p,sizeof(info), "xen-%d.%d-ia64 ", major, minor);
> + char s[32];
> +
> + info[0] = '\0';
> +
> + snprintf(s, sizeof(s), "xen-%d.%d-ia54 ", major, minor);
> + safe_strcat(info, s);

This doesn't work. info is just a char* here, so the sizeof() in
safe_strcat() only cats the first 8 bytes (or 4 on x86_32 I suppose).
Thanks,

Alex

--
Alex Williamson HP Open Source & Linux Org.


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Re: Re: [Xen-staging] [xen-unstable] Clean up arch_get_xen_caps() to not use sprintf(). [ In reply to ]
On Tue, 2007-01-30 at 23:20 -0700, Alex Williamson wrote:
> On Tue, 2007-01-30 at 16:24 +0000, Xen staging patchbot-unstable wrote:
> > diff -r bd69e83b65ea -r 9578ae319874 xen/arch/ia64/xen/xensetup.c
> > --- a/xen/arch/ia64/xen/xensetup.c Tue Jan 30 16:14:16 2007 +0000
> > +++ b/xen/arch/ia64/xen/xensetup.c Tue Jan 30 16:23:43 2007 +0000
> > @@ -547,18 +547,19 @@ printk("num_online_cpus=%d, max_cpus=%d\
> >
> > void arch_get_xen_caps(xen_capabilities_info_t info)
> > {
> > - char *p=info;
> > int major = xen_major_version();
> > int minor = xen_minor_version();
> > -
> > - p += snprintf(p,sizeof(info), "xen-%d.%d-ia64 ", major, minor);
> > + char s[32];
> > +
> > + info[0] = '\0';
> > +
> > + snprintf(s, sizeof(s), "xen-%d.%d-ia54 ", major, minor);
> > + safe_strcat(info, s);
>
> This doesn't work. info is just a char* here, so the sizeof() in
> safe_strcat() only cats the first 8 bytes (or 4 on x86_32 I suppose).

And there's a typo, ia64, not 54. Thanks,

Alex

--
Alex Williamson HP Open Source & Linux Org.


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
Re: Re: [Xen-staging] [xen-unstable] Clean up arch_get_xen_caps() to not use sprintf(). [ In reply to ]
On Tue, 2007-01-30 at 23:31 -0700, Alex Williamson wrote:
> On Tue, 2007-01-30 at 23:20 -0700, Alex Williamson wrote:
> > On Tue, 2007-01-30 at 16:24 +0000, Xen staging patchbot-unstable wrote:
> > > diff -r bd69e83b65ea -r 9578ae319874 xen/arch/ia64/xen/xensetup.c
> > > --- a/xen/arch/ia64/xen/xensetup.c Tue Jan 30 16:14:16 2007 +0000
> > > +++ b/xen/arch/ia64/xen/xensetup.c Tue Jan 30 16:23:43 2007 +0000
> > > @@ -547,18 +547,19 @@ printk("num_online_cpus=%d, max_cpus=%d\
> > >
> > > void arch_get_xen_caps(xen_capabilities_info_t info)
> > > {
> > > - char *p=info;
> > > int major = xen_major_version();
> > > int minor = xen_minor_version();
> > > -
> > > - p += snprintf(p,sizeof(info), "xen-%d.%d-ia64 ", major, minor);
> > > + char s[32];
> > > +
> > > + info[0] = '\0';
> > > +
> > > + snprintf(s, sizeof(s), "xen-%d.%d-ia54 ", major, minor);
> > > + safe_strcat(info, s);
> >
> > This doesn't work. info is just a char* here, so the sizeof() in
> > safe_strcat() only cats the first 8 bytes (or 4 on x86_32 I suppose).
>
> And there's a typo, ia64, not 54. Thanks,

Fixed both of these, thanks for the heads up.

Ian.



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel