wuzhipeng2014 / freenos

Automatically exported from code.google.com/p/freenos
GNU General Public License v3.0
0 stars 0 forks source link

Executing partly typed commands with forkexec() are successful in Shell #2

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When entering only partly typed commands like 'host' (should be 'hostname') or
'mou' (i.e. 'mount'), the command seems to execute successfully while it
shouldn't:

(localhost) # host
localhost
(localhost) # mou
/dev
/proc
/img
(localhost) # mem
Total: 130620 KB
Available: 90540 KB

Note that the problem only occurs for commands executed by forkexec().

Original issue reported on code.google.com by coenbijlsma on 7 Aug 2009 at 10:12

GoogleCodeExporter commented 9 years ago
ORIGINAL COMMENT FROM nieklinnenbank
I've discovered that similar behavior occurs when outputting the
contents of a file using cat in Shell:

(localhost) # cat /img/VERSIONZ
0.0.2 

Original comment by coenbijlsma on 7 Aug 2009 at 10:13

GoogleCodeExporter commented 9 years ago
ORIGINAL COMMENT FROM nieklinnenbank
The problem was in the Ext2Directory::getEntry() function. It compared too few 
bytes
using the strncmp() function: only dent->nameLength at maximum, while the input
may be strlen(name) bytes long. Simple solution was to use dent->nameLength as 
the
count parameter to strncmp() only when it was larger than strlen(name).

Original comment by coenbijlsma on 7 Aug 2009 at 10:14