Libc: zero sysctl buffer before strncpy

The uname utility from coreutils needs its read buffer zero-terminated,
regardless of read length.

Fix #2657
This commit is contained in:
Ehmry - 2018-01-29 21:31:02 +01:00 committed by Norman Feske
parent 4a444651c5
commit abd536d5d3
2 changed files with 48 additions and 29 deletions

View File

@ -90,6 +90,8 @@ extern "C" int __sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
if (namelen != 2) return Libc::Errno(ENOENT);
if (index_a >= CTL_MAXID) return Libc::Errno(EINVAL);
Genode::memset(buf, 0x00, *oldlenp);
switch(index_a) {
case CTL_KERN:
if (index_b >= KERN_MAXID) return Libc::Errno(EINVAL);

View File

@ -1,5 +1,11 @@
build { core init drivers/timer noux/minimal
lib/libc_noux noux-pkg/coreutils }
build {
core init
app/sequence
drivers/timer
lib/libc_noux
noux/minimal
noux-pkg/coreutils
}
create_boot_directory
@ -18,13 +24,16 @@ install_config {
<default-route>
<any-service> <any-child/> <parent/> </any-service>
</default-route>
<default caps="256"/>
<start name="timer">
<resource name="RAM" quantum="1M"/>
<provides><service name="Timer"/></provides>
</start>
<start name="sequence">
<resource name="RAM" quantum="16M"/>
<config>
<start name="spoof">
<binary name="noux"/>
<resource name="RAM" quantum="16M"/>
<config verbose="yes" stdin="/null" stdout="/log" stderr="/log">
<fstab>
<null/> <log/>
@ -50,15 +59,23 @@ install_config {
</config>
</start>
</config>
</start>
</config>
}
build_boot_image {
core init timer ld.lib.so noux libc.lib.so libm.lib.so posix.lib.so
libc_noux.lib.so coreutils.tar
core init ld.lib.so
coreutils.tar
libc_noux.lib.so
libm.lib.so
noux libc.lib.so
posix.lib.so
sequence
timer
}
append qemu_args " -nographic -serial mon:stdio "
# coreutils.tar is really huge when built for x86_64
run_genode_until {child "noux" exited with exit value 0.*\n} 30
run_genode_until {child "sequence" exited with exit value 0.*\n} 30