Thanks very much Marcus for the bug report and the patch. Applied:<div><br></div><div><a href="http://lists.cs.uiuc.edu/pipermail/vmkit-commits/2011-June/002023.html">http://lists.cs.uiuc.edu/pipermail/vmkit-commits/2011-June/002023.html</a></div>
<div><br></div><div>Cheers,</div><div>Nicolas<br><br><div class="gmail_quote">On Fri, Jun 10, 2011 at 2:58 PM, marcus <span dir="ltr"><<a href="mailto:marcus@mh-development.info">marcus@mh-development.info</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> Please excuse the previous mail. My mailclient misbehaved.<br>
<br>
The below code to check for the environment variable NAME and for<br>
setting a default username of "" fails, because the else paths are only<br>
taken when there inside if condition is false anyways. The elses should<br>
not be there but instead each method should be used until a username is<br>
returned.<br>
<div class="im"><br>
lib/J3/Classpath/ClasspathVMSystemProperties.inc<br>
<br>
</div><div class="im"> tmp = getenv("USERNAME");<br>
if (!tmp) tmp = getenv("LOGNAME");<br>
else if (!tmp) tmp = getenv("NAME");<br>
else if (!tmp) tmp = "";<br>
<br>
</div> The proper way to do this would be<br>
<div class="im"><br>
tmp = getenv("USERNAME");<br>
if (!tmp) tmp = getenv("LOGNAME");<br>
</div><div class="im"> if (!tmp) tmp = getenv("NAME");<br>
if (!tmp) tmp = "";<br>
<br>
</div> because then you don't fall victim to the dangling else problem of the<br>
current implementation.<br>
The bug manifests in that setProperty fails if provided with a null<br>
pointer as value. (Occurs if neither USERNAME nor LOGNAME are set in the<br>
environment)<br>
<br>
Regards,<br>
<br>
Marcus<br>
<br>
--- Patch to fix the behaviour ----<br>
<div><div></div><div class="h5"><br>
diff a/ClasspathVMSystemProperties.inc<br>
b/ClasspathVMSystemProperties.inc<br>
118,119c118,119<br>
< else if (!tmp) tmp = getenv("NAME");<br>
< else if (!tmp) tmp = "";<br>
---<br>
> if (!tmp) tmp = getenv("NAME");<br>
> if (!tmp) tmp = "";<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div><br></div>