<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Something incredibly stupid&#8230;</title>
	<atom:link href="http://style-vs-substance.com/programming/something-incredibly-stupid/feed/" rel="self" type="application/rss+xml" />
	<link>http://style-vs-substance.com/programming/something-incredibly-stupid/</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Fri, 20 Jan 2012 21:15:37 -0600</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Steve Nguyen</title>
		<link>http://style-vs-substance.com/programming/something-incredibly-stupid/comment-page-1/#comment-2247</link>
		<dc:creator>Steve Nguyen</dc:creator>
		<pubDate>Mon, 21 Dec 2009 07:28:35 +0000</pubDate>
		<guid isPermaLink="false">http://style-vs-substance.com/something-incredibly-stupid/2008/06/#comment-2247</guid>
		<description>I&#039;ve seen some bad code myself.

I once had a co-worker generate a unique user name from using the first two characters of an MD5 string and appending it to a First_Name_Last_Name string.

He kept wondering why there was unique user name collisions. He didn&#039;t realize 2 positions and 16 hexadecimal values meant 2^16 coupled with a small name space (human names). And he thought it was somehow going to be more uniquely generated because it came from an MD5 hash as opposed to a random function.

I also once had a co-worker use recursion as a looping mechanism versus an iterative approach. He didn&#039;t do it for elegance like for GCF, he did it for mundane looping purposes. He kept wondering why the Zend engine ran out of memory. 

And I also knew a guy that used a switch statement on a boolean value. :-p</description>
		<content:encoded><![CDATA[<p>I&#8217;ve seen some bad code myself.</p>
<p>I once had a co-worker generate a unique user name from using the first two characters of an MD5 string and appending it to a First_Name_Last_Name string.</p>
<p>He kept wondering why there was unique user name collisions. He didn&#8217;t realize 2 positions and 16 hexadecimal values meant 2^16 coupled with a small name space (human names). And he thought it was somehow going to be more uniquely generated because it came from an MD5 hash as opposed to a random function.</p>
<p>I also once had a co-worker use recursion as a looping mechanism versus an iterative approach. He didn&#8217;t do it for elegance like for GCF, he did it for mundane looping purposes. He kept wondering why the Zend engine ran out of memory. </p>
<p>And I also knew a guy that used a switch statement on a boolean value. :-p</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim Mayes</title>
		<link>http://style-vs-substance.com/programming/something-incredibly-stupid/comment-page-1/#comment-94</link>
		<dc:creator>Jim Mayes</dc:creator>
		<pubDate>Thu, 12 Jun 2008 17:29:09 +0000</pubDate>
		<guid isPermaLink="false">http://style-vs-substance.com/something-incredibly-stupid/2008/06/#comment-94</guid>
		<description>something else I forgot to suggest in the original post... things as crucial as local root paths should be set as constants not just simple variables.

Had $include_path in the above code instead been defined as a constant, the attack would have failed because a constant can not be redefined within the execution of a script. So if line 1 was instead:

&lt;pre class=&quot;brush:php&quot;&gt;
define(MY_INCLUDE_PATH, dirname(__FILE__));
&lt;/pre&gt;

and the require statements similarly updated to use the constant like:

&lt;pre class=&quot;brush:php&quot;&gt;
require( MY_INCLUDE_PATH.&quot;/include/config.inc.php&quot; );
&lt;/pre&gt;

Then this particular attack vector would have been closed.  However it&#039;s still bad form to use variable variables in this way as it just creates to many opportunities for a user to overwrite local variables. Basically if you&#039;re doing that, you need to validate every variable for integrity in your script. It&#039;s a lot more manageable to deal with (clean &amp; validate) a hand full of known variables supplied by users than it is to do the same for every variable you use throughout your entire script.</description>
		<content:encoded><![CDATA[<p>something else I forgot to suggest in the original post&#8230; things as crucial as local root paths should be set as constants not just simple variables.</p>
<p>Had $include_path in the above code instead been defined as a constant, the attack would have failed because a constant can not be redefined within the execution of a script. So if line 1 was instead:</p>
<pre class="brush:php">
define(MY_INCLUDE_PATH, dirname(__FILE__));
</pre>
<p>and the require statements similarly updated to use the constant like:</p>
<pre class="brush:php">
require( MY_INCLUDE_PATH."/include/config.inc.php" );
</pre>
<p>Then this particular attack vector would have been closed.  However it&#8217;s still bad form to use variable variables in this way as it just creates to many opportunities for a user to overwrite local variables. Basically if you&#8217;re doing that, you need to validate every variable for integrity in your script. It&#8217;s a lot more manageable to deal with (clean &#038; validate) a hand full of known variables supplied by users than it is to do the same for every variable you use throughout your entire script.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

