Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

camput: check decode errors, exposes bugs in flat cache

Change-Id: I5fd812300c0c92892447a57d1da49cceedca9e3f
  • Loading branch information...
commit b4bff6a7d9591f10f2300b02a7887d8aa386e57d 1 parent df339b4
@bradfitz bradfitz authored
Showing with 15 additions and 3 deletions.
  1. +15 −3 cmd/camput/flatcache.go
View
18 cmd/camput/flatcache.go
@@ -19,6 +19,7 @@ package main
import (
"encoding/gob"
"errors"
+ "io"
"log"
"os"
"path/filepath"
@@ -69,11 +70,22 @@ func NewFlatStatCache() *FlatStatCache {
defer f.Close()
d := gob.NewDecoder(f)
for {
- var key string
- var val fileInfoPutRes
- if d.Decode(&key) != nil || d.Decode(&val) != nil {
+ var (
+ key string
+ val fileInfoPutRes
+ err error
+ )
+ err = d.Decode(&key)
+ if err == io.EOF {
break
}
+ if err != nil {
+ log.Fatalf("stat cache key decode error: %v", err)
+ }
+ err = d.Decode(&val)
+ if err != nil {
+ log.Fatalf("stat cache value decode error: %v", err)
+ }
val.Result.Skipped = true
fc.m[key] = val
}
Please sign in to comment.
Something went wrong with that request. Please try again.