summary refs log tree commit diff
path: root/gnu
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-05-07 10:50:28 +0200
committerLudovic Courtès <ludo@gnu.org>2019-05-07 12:18:44 +0200
commit6c5790a2faf8ffc401e43b13425a707394e40874 (patch)
tree9e22384039a5b35a1d829a758abff1f41f750fa6 /gnu
parent08c06cd8acbd960c483292f9c3df32fe304ef04f (diff)
downloadguix-6c5790a2faf8ffc401e43b13425a707394e40874.tar.gz
uuid: 'fat-uuid->string' preserves leading zeros.
Fixes <https://bugs.gnu.org/35582>.
Reported by sirgazil <sirgazil@zoho.com>.

Previously, leading zeros would be removed, leading to an "invalid"
UUID:

  (uuid->string (uuid "00CA-050E" 'fat32))
  ⇒ "CA-50E"
  (string->uuid "CA-50E" 'fat32)
  ⇒ #f

* gnu/system/uuid.scm (fat-uuid->string): Pad digits with zeros.
* tests/uuid.scm ("uuid, FAT32, leading zeros preserved"): New test.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/system/uuid.scm4
1 files changed, 2 insertions, 2 deletions
diff --git a/gnu/system/uuid.scm b/gnu/system/uuid.scm
index f13960c3e9..e7a3a0439d 100644
--- a/gnu/system/uuid.scm
+++ b/gnu/system/uuid.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2017 Danny Milosavljevic <dannym@scratchpost.org>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -175,7 +175,7 @@ ISO9660 UUID representation."
   "Convert FAT32/FAT16 UUID, a 4-byte bytevector, to its string representation."
   (let ((high  (bytevector-uint-ref uuid 0 %fat-endianness 2))
         (low (bytevector-uint-ref uuid 2 %fat-endianness 2)))
-    (format #f "~:@(~x-~x~)" low high)))
+    (format #f "~:@(~4,'0x-~4,'0x~)" low high)))
 
 (define %fat-uuid-rx
   (make-regexp "^([[:xdigit:]]{4})-([[:xdigit:]]{4})$"))