massalabs / DeWeb

On-chain Decentralized Web Gateway
MIT License
2 stars 1 forks source link

fix pointer dereference when no lastupdate time stamp #166

Closed pivilartisant closed 3 days ago

pivilartisant commented 1 week ago

This pr fixes a server crash when the last updated time stamp is not present.

It's a quick win but we should discuss how to handle this gracefully (like redirect to a specific error page)

goroutine 8 [running]:
net/http.(*conn).serve.func1()
        /usr/local/go/src/net/http/server.go:1947 +0xb0
panic({0x1032b8040?, 0x1037297c0?})
        /usr/local/go/src/runtime/panic.go:785 +0x124
github.com/massalabs/deweb-server/pkg/webmanager.isFileOutdated(0x1400001f8b0, 0xff?, {0x140003861c0, 0x34}, {0x10314e7e1, 0xa})
        /Users/pivi/Code/massa/DeWeb/server/pkg/webmanager/manager.go:106 +0x17c
github.com/massalabs/deweb-server/pkg/webmanager.RequestFile({0x140003861c0, 0x34}, 0x140003b6098, {0x10314e7e1, 0xa})
        /Users/pivi/Code/massa/DeWeb/server/pkg/webmanager/manager.go:38 +0x164
github.com/massalabs/deweb-server/pkg/webmanager.GetWebsiteResource(0x140003b6098, {0x140003861c0, 0x34}, {0x10314e7e1, 0xa})
        /Users/pivi/Code/massa/DeWeb/server/pkg/webmanager/manager.go:18 +0xc8
github.com/massalabs/deweb-server/int/api.getWebsiteResource(0x140003b6098, {0x140003861c0, 0x34}, {0x10314e7e1, 0xa})
        /Users/pivi/Code/massa/DeWeb/server/int/api/middlewares.go:171 +0x144
github.com/massalabs/deweb-server/int/api.serveContent(0x140003861c0?, {0x140003861c0, 0x34}, {0x10314e7e1, 0xa}, {0x103357f98, 0x140001502a0})
        /Users/pivi/Code/massa/DeWeb/server/int/api/middlewares.go:75 +0x44
github.com/massalabs/deweb-server/int/api.(*API).Start.SubdomainMiddleware.func3({0x103357f98, 0x140001502a0}, 0x14000204000)
        /Users/pivi/Code/massa/DeWeb/server/int/api/middlewares.go:69 +0x280
net/http.HandlerFunc.ServeHTTP(0x0?, {0x103357f98?, 0x140001502a0?}, 0x140000a3b60?)
        /usr/local/go/src/net/http/server.go:2220 +0x38
net/http.serverHandler.ServeHTTP({0x1400038cf30?}, {0x103357f98?, 0x140001502a0?}, 0x6?)
        /usr/local/go/src/net/http/server.go:3210 +0xbc
net/http.(*conn).serve(0x140005acab0, {0x103359030, 0x140004001b0})
        /usr/local/go/src/net/http/server.go:2092 +0x4fc
created by net/http.(*Server).Serve in goroutine 29
        /usr/local/go/src/net/http/server.go:3360 +0x3dc