xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Dario Faggioli <dfaggioli@suse.com>
To: Wei Liu <wei.liu2@citrix.com>
Cc: xen-devel@lists.xenproject.org, Ian Jackson <ian.jackson@eu.citrix.com>
Subject: Re: [PATCH] tools: libxenstat: fix format string overflow
Date: Fri, 16 Feb 2018 18:55:08 +0100	[thread overview]
Message-ID: <1518803708.3813.18.camel@suse.com> (raw)
In-Reply-To: <20180216174405.z2dut66rkh3x5pnw@citrix.com>


[-- Attachment #1.1: Type: text/plain, Size: 1191 bytes --]

On Fri, 2018-02-16 at 17:44 +0000, Wei Liu wrote:
> On Fri, Feb 16, 2018 at 06:36:51PM +0100, Dario Faggioli wrote:
> > 
> > --- a/tools/xenstat/libxenstat/src/xenstat_linux.c
> > +++ b/tools/xenstat/libxenstat/src/xenstat_linux.c
> > @@ -69,18 +69,20 @@ void getBridge(char *excludeName, char *result,
> > size_t resultLen)
> >  	struct dirent *de;
> >  	DIR *d;
> >  
> > -	char tmp[256] = { 0 };
> > -
> >  	d = opendir("/sys/class/net");
> >  	while ((de = readdir(d)) != NULL) {
> >  		if ((strlen(de->d_name) > 0) && (de->d_name[0] !=
> > '.')
> >  			&& (strstr(de->d_name, excludeName) ==
> > NULL)) {
> > -				sprintf(tmp,
> > "/sys/class/net/%s/bridge", de->d_name);
> > +				char *tmp;
> > +
> > +				asprintf(&tmp,
> > "/sys/class/net/%s/bridge", de->d_name);
> 
> Need to check the return value of asprintf.
> 
Right! And what do I do if it fails, 'continue' the while(), I guess?

Thanks and Regards,
Dario
-- 
<<This happens because I choose it to happen!>> (Raistlin Majere)
-----------------------------------------------------------------
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Software Engineer @ SUSE https://www.suse.com/

[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

[-- Attachment #2: Type: text/plain, Size: 157 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2018-02-16 17:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-16 17:36 [PATCH] tools: libxenstat: fix format string overflow Dario Faggioli
2018-02-16 17:42 ` Andrew Cooper
2018-02-16 17:44 ` Wei Liu
2018-02-16 17:46   ` Wei Liu
2018-02-16 17:55   ` Dario Faggioli [this message]
2018-02-16 17:58     ` Wei Liu
2018-02-16 18:09       ` Dario Faggioli
2018-02-16 17:55   ` Dario Faggioli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1518803708.3813.18.camel@suse.com \
    --to=dfaggioli@suse.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).