guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#45983] [PATCH 0/3] Fix non-recursive importers gnu and json


From: Ludovic Courtès
Subject: [bug#45983] [PATCH 0/3] Fix non-recursive importers gnu and json
Date: Tue, 26 Jan 2021 23:17:56 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

zimoun <zimon.toutoune@gmail.com> skribis:

> Fixes partially <https://bugs.gnu.org/44115>.
>
> * guix/scripts/import/json.scm (guix-import-json): Handle error.

[...]

> -       (or (json->code file-name)
> -           (leave (G_ "invalid JSON in file '~a'~%") file-name)))
> +       (if (file-exists? file-name)
> +         (or (json->code file-name)
> +             (leave (G_ "invalid JSON in file '~a'~%") file-name))
> +         (leave (G_ "invalid file name~%"))))

I’d suggest this:

  (catch 'system-error
    (lambda ()
      (or (json->code …) …))
    (lambda args
      (leave (G_ "failed to access '~a': ~a~%")
             file-name (strerror (system-error-errno args)))))

This avoids TOCTTOU and gives details about the failure.

Could you send updated patches?

Thanks,
Ludo’.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]