diff options
| author | Jesper Jensen <jesper@jnsn.dev> | 2025-04-14 13:06:26 +0200 |
|---|---|---|
| committer | Jesper Jensen <jesper@jnsn.dev> | 2025-04-14 13:06:26 +0200 |
| commit | a2f18ae0234bc6dbccaebd21bc7ea07ceac2ee7a (patch) | |
| tree | 549b76c49039fe57e616f1e17678b68189425dd8 | |
| parent | fd0f0b52da637714fb4471ea8c06afe9ea709140 (diff) | |
Don't crash on invalid dictionary
| -rw-r--r-- | src/proto.c | 7 | ||||
| -rw-r--r-- | src/query.c | 12 |
2 files changed, 13 insertions, 6 deletions
diff --git a/src/proto.c b/src/proto.c index 4ea9b20..d4f8b59 100644 --- a/src/proto.c +++ b/src/proto.c @@ -368,7 +368,8 @@ PROCESS_REPONSE(getclient_response) { bcur_next(&bcursor, 1); break; case -BENC_EBADP: - fatal("Bad dict"); + err("Bad Dictionary, Discard packet"); + return PROTO_EDISC; } } @@ -763,7 +764,9 @@ int proto_run(struct dht* dht, char* buff, size_t recv_len, struct sockaddr_in* break; } case -BENC_EBADP: - fatal("Bad dict"); + err("Bad Dictionary, we drop this packet"); + recalulate_waketime(dht); + return 0; } } diff --git a/src/query.c b/src/query.c index f0b9014..2276ac1 100644 --- a/src/query.c +++ b/src/query.c @@ -64,7 +64,8 @@ int handle_request(struct nodeid* self, struct tokens *tokens, time_t now, const bcur_next(&bcursor, 1); break; case -BENC_EBADP: - fatal("Bad dict"); + err("Bad query: Bad Dictionary"); + return QUERY_EBADQ; } } @@ -135,7 +136,8 @@ int handle_request(struct nodeid* self, struct tokens *tokens, time_t now, const bcur_next(&bcursor, 1); break; case -BENC_EBADP: - fatal("Bad dict"); + err("Bad query: Bad Dictionary"); + return QUERY_EBADQ; } } @@ -233,7 +235,8 @@ int handle_request(struct nodeid* self, struct tokens *tokens, time_t now, const bcur_next(&bcursor, 1); break; case -BENC_EBADP: - fatal("Bad dict"); + err("Bad query: Bad Dictionary"); + return QUERY_EBADQ; } } @@ -443,7 +446,8 @@ int handle_request(struct nodeid* self, struct tokens *tokens, time_t now, const bcur_next(&bcursor, 1); break; case -BENC_EBADP: - fatal("Bad dict"); + err("Bad query: Bad Dictionary"); + return QUERY_EBADQ; } } |
