Skip to content

Commit

Permalink
Guard against ill-formed responses in snow remote-command.
Browse files Browse the repository at this point in the history
  • Loading branch information
ashinn committed Dec 2, 2024
1 parent 3716d99 commit c437ede
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/chibi/snow/commands.scm
Original file line number Diff line number Diff line change
Expand Up @@ -794,10 +794,18 @@
(http-post uri params))))

(define (remote-command cfg name path params)
(let ((uri (remote-uri cfg name path)))
(sxml-display-as-text
(read (snow-post cfg uri (cons '(fmt . "sexp") params))))
(newline)))
(let* ((uri (remote-uri cfg name path))
(response
(port->string (snow-post cfg uri (cons '(fmt . "sexp") params)))))
(guard (exn (else
(display "ERROR: couldn't display sxml response: ")
(write response)
(newline)))
(let ((sxml (call-with-input-string response read)))
(if (null? sxml)
(display "WARN: () response from server")
(sxml-display-as-text sxml))
(newline)))))

(define (command/reg-key cfg spec)
(let* ((keys (call-with-input-file
Expand Down

0 comments on commit c437ede

Please sign in to comment.