aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/user/ipc.c
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/user/ipc.c
parentdabd2355f355abd7d1d58641f6cc496adb1482d1 (diff)
downloadkogata-f811e0126639c3cc14c285f2e2093d0df1b556af.tar.gz
kogata-f811e0126639c3cc14c285f2e2093d0df1b556af.zip
Fix a bug: malloc() with wrong size
Diffstat (limited to 'src/kernel/user/ipc.c')
-rw-r--r--src/kernel/user/ipc.c8
1 files changed, 5 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;