Secure coding: Difference between revisions

Content deleted Content added
BattyBot (talk | contribs)
m Removed non-content empty section(s), performed general fixes
Line 1:
{{Short description|Computer software}}
{{Multiple issues|
{{RefimproveMore citations needed|date=September 2017}}
{{More footnotes|date=September 2010}}
}}
Line 57:
}
</syntaxhighlight>
The problem with the code is it does not check for integer overflow on the addition operation. If the sum of x and y is greater than the maximum possible value of an <code>unsigned int</code>, the addition operation will overflow and perhaps<!-- Note that an overflow will not always result in the calculated sum being less than MAX; MAX might be relatively small and both x and y relatively big, so even an overflow might still be greater than MAX. Example: x=y=UINT_MAX, MAX=1000000. --> result in a value less than or equal to MAX, even though the sum of x and y is greater than MAX.
 
Below is a function which checks for overflow by confirming the sum is greater than or equal to both x and y. If the sum did overflow, the sum would be less than x or less than y.
Line 70:
Path traversal is a vulnerability whereby paths provided from an untrusted source are interpreted in such a way that unauthorised file access is possible.
 
For example, consider a script that fetches an article by taking a filename, which is then read by the script and [[Parse|parsedparse]]d. Such a script might use the following hypothetical URL to retrieve an article about [[dog food]]:
<nowiki>https://www.example.net/cgi-bin/article.sh?name=dogfood.html</nowiki>
If the script has no input checking, instead trusting that the filename is always valid, a [[malicious user]] could forge a URL to retrieve configuration files from the web server:
Line 85:
== References ==
* {{Cite book| last = Taylor | first = Art |author2=Brian Buege |author3=Randy Layman | title = Hacking Exposed J2EE & Java | year = 2006 | publisher = McGraw-Hill Primis | pages = 426 | isbn = 0-390-59975-1 }}
 
==External links==
 
{{DEFAULTSORT:Secure Coding}}