mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-29 15:44:02 +00:00
libc: fill stdio descriptors even if invalid
Stdin, stdout, and stderr are mapped to descriptors 0, 1, and 2 respectively. If these first three descriptors are not allocated before the application becomes active then normal files and sockets can be opened under these numbers, potentially causing unexpected application behavior. Fix #2628
This commit is contained in:
parent
61e1bed2c2
commit
36104098ad
@ -77,7 +77,7 @@ compare_output_to {
|
||||
[init -> test-ldso] lib_1_local_3 12345676
|
||||
[init -> test-ldso] lib_1_pod_1 8070604d
|
||||
[init -> test-ldso] Libc::read:
|
||||
[init -> test-ldso] Error: no plugin found for read(0)
|
||||
[init -> test-ldso] Error: no plugin found for read(3)
|
||||
[init -> test-ldso] Libc::abs(-10): 10
|
||||
[init -> test-ldso]
|
||||
[init -> test-ldso] Catch exceptions in program
|
||||
|
@ -70,7 +70,10 @@ class Libc::Vfs_plugin : public Libc::Plugin
|
||||
if (fd->fd_path) { Genode::warning("may leak former FD path memory"); }
|
||||
fd->fd_path = strdup(path.string());
|
||||
|
||||
} catch (Xml_node::Nonexistent_attribute) { }
|
||||
} catch (Xml_node::Nonexistent_attribute) {
|
||||
/* fill the stdio number with a EBADF */
|
||||
Libc::file_descriptor_allocator()->alloc(nullptr, nullptr, libc_fd);
|
||||
}
|
||||
}
|
||||
|
||||
void _vfs_sync(Vfs::Vfs_handle *vfs_handle)
|
||||
|
@ -211,7 +211,7 @@ void Libc::Component::construct(Libc::Env &env)
|
||||
lib_1_local_3()->lib_1_local_3();
|
||||
printf("lib_1_pod_1 %x\n", --pod_1);
|
||||
|
||||
int fd = 0;
|
||||
int fd = STDERR_FILENO + 1;
|
||||
char buf[2];
|
||||
printf("Libc::read:\n");
|
||||
Libc::read(fd, buf, 2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user