All of lore.kernel.org
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: Xu Wang <cngesaint@gmail.com>
Cc: kwolf@redhat.com, Stefan Hajnoczi <stefanha@gmail.com>,
	qemu-devel@nongnu.org, xiawenc@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH V2 2/5] Add WIN32 platform support for backing_file_loop_check()
Date: Mon, 15 Jul 2013 14:30:21 +0800	[thread overview]
Message-ID: <20130715063021.GB27534@T430s.nay.redhat.com> (raw)
In-Reply-To: <CA+2Di9TX8KVrEZrFRYbGLuqkCbH23nA-NUeE03=EWeUCHzUfkw@mail.gmail.com>

On Mon, 07/15 14:09, Xu Wang wrote:
> 2013/7/10 Fam Zheng <famz@redhat.com>
> 
> > On Mon, 07/08 03:26, Xu Wang wrote:
> > > +        error_report("get file %s stat error.", path);
> > > +        return -1;
> > > +    }
> > > +    if (GetFullPathName(path, MAX_PATH_LEN, pbuf, &p) != 0) {
> > How big is MAX_PATH_LEN?
> > MSDN: If the buffer is too small to contain the path, the return value
> > is the size, in TCHARs, of the buffer that is required to hold the path
> > and the terminating null character. Please try to handle this case. (And
> > is pbuf NULL terminated in this case?)
> >
> This is really a hard desicion to set value of it because length of path on
> Windows
> could be unlimited. So here I just set an value and want to get some tips
> from others.
> Now it's set as 8192 but I missed it when I made this patch.
> 

Yes, if you use heap allocated buffer, you can work with longer
filename. If you use fixed length buffer, ideally you should detect
whether return value is greater than your buffer size: in this case the
pbuf content is invalid (or incomplete), so your hash computation below
is inaccurate, consequentially false alarm.

-- 
Fam

  reply	other threads:[~2013-07-15  6:30 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-08  7:26 [Qemu-devel] [PATCH V2 0/5] Add infinite loop check for backing file chain Xu Wang
2013-07-08  7:26 ` [Qemu-devel] [PATCH V2 1/5] Refine and export infinite loop checking in collect_image_info_list() Xu Wang
2013-07-10 10:25   ` Fam Zheng
2013-07-10 10:49     ` Fam Zheng
2013-07-12  2:58     ` Xu Wang
2013-07-08  7:26 ` [Qemu-devel] [PATCH V2 2/5] Add WIN32 platform support for backing_file_loop_check() Xu Wang
2013-07-10 10:44   ` Fam Zheng
2013-07-15  6:09     ` Xu Wang
2013-07-15  6:30       ` Fam Zheng [this message]
2013-07-08  7:26 ` [Qemu-devel] [PATCH V2 3/5] Check infinite loop in bdrv_img_create() Xu Wang
2013-07-10 10:52   ` Fam Zheng
2013-07-08  7:26 ` [Qemu-devel] [PATCH V2 4/5] Add backing file loop check in change_backing_file() Xu Wang
2013-07-10 10:57   ` Fam Zheng
2013-07-08  7:26 ` [Qemu-devel] [PATCH V2 5/5] Add infinite loop check in drive_init() Xu Wang
2013-07-10 11:00   ` Fam Zheng
2013-07-10 11:13 ` [Qemu-devel] [PATCH V2 0/5] Add infinite loop check for backing file chain Fam Zheng
2013-07-10 11:42   ` Kevin Wolf
2013-07-10 17:20     ` Eric Blake

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=20130715063021.GB27534@T430s.nay.redhat.com \
    --to=famz@redhat.com \
    --cc=cngesaint@gmail.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=xiawenc@linux.vnet.ibm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.