diff options
author | Christopher Baines <mail@cbaines.net> | 2023-05-22 11:34:32 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2023-05-22 11:34:32 +0100 |
commit | db1775332c83a8d0943bea4b69c49ea5b47cc2a6 (patch) | |
tree | 909723f004a58ff1b1a4336e66123a06228c7cc8 | |
parent | b2b8b37c112c676fffe8d65a86d96690ae97d20e (diff) | |
download | nar-herder-db1775332c83a8d0943bea4b69c49ea5b47cc2a6.tar nar-herder-db1775332c83a8d0943bea4b69c49ea5b47cc2a6.tar.gz |
Better handle invalid GET /nar/ requests
-rw-r--r-- | nar-herder/server.scm | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/nar-herder/server.scm b/nar-herder/server.scm index 07cb1c4..f07cb9d 100644 --- a/nar-herder/server.scm +++ b/nar-herder/server.scm @@ -283,20 +283,24 @@ (values (build-response #:code 404) "404")))) (('GET "nar" compression filename) - (let* ((hash (string-take filename 32)) + (let* ((hash (and (>= (string-length filename) 32) + (string-take filename 32))) (narinfo - (database-select-narinfo-by-hash - database - hash)) + (and hash + (database-select-narinfo-by-hash + database + hash))) (narinfo-files - (database-select-narinfo-files-by-narinfo-id - database - (assq-ref narinfo 'id))) + (and=> (assq-ref narinfo 'id) + (lambda (id) + (database-select-narinfo-files-by-narinfo-id + database + id)))) (narinfo-file-for-compression (find (lambda (file) (string=? (assq-ref file 'compression) compression)) - narinfo-files)) + (or narinfo-files '()))) (compression-symbol (if (member compression |