Fix dlmalloc horror bug - mman_map overwrites application code
This commit is contained in:
@ -8,16 +8,21 @@
|
||||
#include <ansiq/all.h>
|
||||
#include <system/system.h>
|
||||
#include <sysdefs/ipcpipe.h>
|
||||
#include <sysdefs/ioctl.h>
|
||||
#include <sysdefs/processctl.h>
|
||||
#include <errors.h>
|
||||
|
||||
static struct {
|
||||
struct {
|
||||
char *modestr;
|
||||
enum { MODE_INTERACTIVE = 1, MODE_RUNFILE = 2 } mode;
|
||||
char *filepath;
|
||||
} CONFIG;
|
||||
|
||||
#define LINEBUF_MAX 1024
|
||||
|
||||
static Arg ARGS[] = {
|
||||
ARG("-m", ARG_STRING, &CONFIG.modestr),
|
||||
ARG("-f", ARG_STRING, &CONFIG.filepath),
|
||||
ARG_END(),
|
||||
};
|
||||
|
||||
@ -38,11 +43,18 @@ void set_config(void) {
|
||||
} else {
|
||||
CONFIG.mode = MODE_RUNFILE;
|
||||
}
|
||||
uprintf("CONFIG.mode = %d\n", CONFIG.mode);
|
||||
}
|
||||
|
||||
void process_cmd(char *cmdtext) {
|
||||
|
||||
}
|
||||
|
||||
void do_file(char *filepath) {
|
||||
int32_t ioh = ioctl(IOCTL_NOHANDLE, IOCTL_OPENF, (uint64_t)filepath, IOCTL_F_READ, 0);
|
||||
if (ioh < 0) {
|
||||
LOG(LOG_ERR, "Could not open %s: %s\n", filepath, ERRSTRING(ioh));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void do_mode_interactive(void) {
|
||||
@ -62,8 +74,6 @@ void do_mode_interactive(void) {
|
||||
}
|
||||
linebuf[cursor - 1] = '\0';
|
||||
uprintf("\n");
|
||||
|
||||
process_cmd(linebuf);
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,5 +82,11 @@ void main(void) {
|
||||
|
||||
if (CONFIG.mode == MODE_INTERACTIVE) {
|
||||
do_mode_interactive();
|
||||
} else if (CONFIG.mode == MODE_RUNFILE) {
|
||||
if (CONFIG.filepath == NULL) {
|
||||
uprintf("No file provided\n");
|
||||
return;
|
||||
}
|
||||
do_file(CONFIG.filepath);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user