aboutsummaryrefslogtreecommitdiff
path: root/src/kernel
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2015-03-14 13:46:44 +0100
committerAlex Auvolat <alex@adnab.me>2015-03-14 13:46:44 +0100
commitf811e0126639c3cc14c285f2e2093d0df1b556af (patch)
tree170ac684774303ddddda1e33bb0bcf3559a0b6e8 /src/kernel
parentdabd2355f355abd7d1d58641f6cc496adb1482d1 (diff)
downloadkogata-f811e0126639c3cc14c285f2e2093d0df1b556af.tar.gz
kogata-f811e0126639c3cc14c285f2e2093d0df1b556af.zip
Fix a bug: malloc() with wrong size
Diffstat (limited to 'src/kernel')
-rw-r--r--src/kernel/user/ipc.c8
-rw-r--r--src/kernel/user/process.c2
2 files changed, 7 insertions, 3 deletions
diff --git a/src/kernel/user/ipc.c b/src/kernel/user/ipc.c
index 308a9c1..2a43da1 100644
--- a/src/kernel/user/ipc.c
+++ b/src/kernel/user/ipc.c
@@ -324,8 +324,8 @@ STATIC_MUTEX(token_table_mutex);
typedef struct {
token_t tok;
- fs_handle_t *h;
uint64_t time;
+ fs_handle_t *h;
} token_table_entry_t;
static token_table_entry_t *expired_token = 0;
@@ -344,7 +344,7 @@ void token_expiration_check(void* x) {
}
hashtbl_iter(token_table, find_expired_token);
- if (expired_token) {
+ if (expired_token != 0) {
hashtbl_remove(token_table, &expired_token->tok);
unref_file(expired_token->h);
free(expired_token);
@@ -370,7 +370,7 @@ bool gen_token_for(fs_handle_t *h, token_t *tok) {
while (!worker_push_in(1000000, token_expiration_check, 0)) yield();
}
- e = (token_table_entry_t*)malloc(sizeof(token_t));
+ e = (token_table_entry_t*)malloc(sizeof(token_table_entry_t));
if (!e) goto end;
prng_bytes((uint8_t*)e->tok.bytes, TOKEN_LENGTH);
@@ -418,6 +418,8 @@ hash_t token_hash_fun(const void* v) {
}
bool token_eq_fun(const void* a, const void* b) {
+ if (a == b) return true;
+
token_t *ta = (token_t*)a, *tb = (token_t*)b;
for (int i = 0; i < TOKEN_LENGTH; i++) {
if (ta->bytes[i] != tb->bytes[i]) return false;
diff --git a/src/kernel/user/process.c b/src/kernel/user/process.c
index f56998e..320638d 100644
--- a/src/kernel/user/process.c
+++ b/src/kernel/user/process.c
@@ -449,6 +449,8 @@ bool proc_add_fs(process_t *p, fs_t *fs, const char* name) {
if (hashtbl_find(p->filesystems, n) != 0) goto end;
add_ok = hashtbl_add(p->filesystems, n, fs);
+
+ dbg_printf("Bind %s: 0x%p\n", name, fs);
end:
mutex_unlock(&p->lock);