summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-03-04 23:58:43 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-03-05 00:10:11 -0400
commit93405153c154b6ecd02f377757fad06b413eb434 (patch)
treea99dfd8cdb5d9344ad0d576e6841f428dbcd83fc
parenta9db3fe8b44701cf593bac204920bfbf797c1f8d (diff)
quickcheck says: "a-s--a" is not a legal key filename
Found this in failed armhf build log, where quickcheck found a way to break prop_idempotent_key_decode. The "s" indicates size, but since nothing comes after it, that's not valid. When encoding the resulting key, no size was present, so it encoded to "a--a". Also, "a-sX--a" is not legal, since X is not a number. Not found by quickcheck.
-rw-r--r--Types/Key.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/Types/Key.hs b/Types/Key.hs
index 598d5ed20..ea142e4aa 100644
--- a/Types/Key.hs
+++ b/Types/Key.hs
@@ -78,8 +78,12 @@ file2key s
findfields _ v = v
addbackend k v = Just k { keyBackendName = v }
- addfield 's' k v = Just k { keySize = readish v }
- addfield 'm' k v = Just k { keyMtime = readish v }
+ addfield 's' k v = do
+ sz <- readish v
+ return $ k { keySize = Just sz }
+ addfield 'm' k v = do
+ mtime <- readish v
+ return $ k { keyMtime = Just mtime }
addfield _ _ _ = Nothing
instance Arbitrary Key where