Skip to content
Snippets Groups Projects
Unverified Commit 5e5aa9ba authored by dlorenc's avatar dlorenc Committed by GitHub
Browse files

Make the loginfo command a bit more future/backwards proof. (#718)


The logid field comes back as nil (which is expected), but we break trying
to dereference that for formatting.

Signed-off-by: default avatarDan Lorenc <lorenc.d@gmail.com>
parent db61de95
No related branches found
No related tags found
No related merge requests found
...@@ -49,6 +49,7 @@ type logInfoCmdOutput struct { ...@@ -49,6 +49,7 @@ type logInfoCmdOutput struct {
func (l *logInfoCmdOutput) String() string { func (l *logInfoCmdOutput) String() string {
// Verification is always successful if we return an object. // Verification is always successful if we return an object.
ts := time.Unix(0, int64(l.TimestampNanos)).UTC().Format(time.RFC3339) ts := time.Unix(0, int64(l.TimestampNanos)).UTC().Format(time.RFC3339)
return fmt.Sprintf(`Verification Successful! return fmt.Sprintf(`Verification Successful!
Tree Size: %v Tree Size: %v
Root Hash: %s Root Hash: %s
...@@ -112,11 +113,18 @@ var logInfoCmd = &cobra.Command{ ...@@ -112,11 +113,18 @@ var logInfoCmd = &cobra.Command{
return nil, errors.New("signature on tree head did not verify") return nil, errors.New("signature on tree head did not verify")
} }
pToInt := func(p *int64) int64 {
if p == nil {
return 0
}
return *p
}
cmdOutput := &logInfoCmdOutput{ cmdOutput := &logInfoCmdOutput{
TreeSize: *logInfo.TreeSize, TreeSize: pToInt(logInfo.TreeSize),
RootHash: *logInfo.RootHash, RootHash: *logInfo.RootHash,
TimestampNanos: sth.GetTimestamp(), TimestampNanos: sth.GetTimestamp(),
TreeID: *logInfo.TreeID, TreeID: pToInt(logInfo.TreeID),
} }
oldState := state.Load(serverURL) oldState := state.Load(serverURL)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment