From 299c1678820785b1e0762d6d6695cb420228e08f Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 7 Mar 2018 13:01:50 +0100 Subject: [PATCH] dashboard/app: fix 2 crashes on invalud input data --- dashboard/app/access.go | 2 +- dashboard/app/main.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dashboard/app/access.go b/dashboard/app/access.go index d8e31c00..291bd06e 100644 --- a/dashboard/app/access.go +++ b/dashboard/app/access.go @@ -61,7 +61,7 @@ func checkCrashTextAccess(c context.Context, r *http.Request, field string, id i return fmt.Errorf("failed to query crashes: %v", err) } if len(crashes) != 1 { - fmt.Errorf("checkCrashTextAccess: found %v crashes for %v=%v", + return fmt.Errorf("checkCrashTextAccess: found %v crashes for %v=%v", len(crashes), field, id) } bug := new(Bug) diff --git a/dashboard/app/main.go b/dashboard/app/main.go index d13006a5..fd31af53 100644 --- a/dashboard/app/main.go +++ b/dashboard/app/main.go @@ -257,8 +257,9 @@ func handleBug(c context.Context, w http.ResponseWriter, r *http.Request) error func handleText(c context.Context, w http.ResponseWriter, r *http.Request) error { tag := r.FormValue("tag") id, err := strconv.ParseInt(r.FormValue("id"), 10, 64) - if err != nil { - return fmt.Errorf("failed to parse text id: %v", err) + if err != nil || id == 0 { + log.Infof(c, "failed to parse text id: %v", err) + return nil } if err := checkTextAccess(c, r, tag, id); err != nil { return err