From c437ede2354cd9de9b9256962275ea8952918a06 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Mon, 2 Dec 2024 11:43:36 +0900 Subject: [PATCH] Guard against ill-formed responses in snow remote-command. --- lib/chibi/snow/commands.scm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/chibi/snow/commands.scm b/lib/chibi/snow/commands.scm index ef613f45..4ea4736b 100644 --- a/lib/chibi/snow/commands.scm +++ b/lib/chibi/snow/commands.scm @@ -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