On Mon, 07/15 14:09, Xu Wang wrote: > 2013/7/10 Fam Zheng <f...@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