jcmturner / gokrb5

Pure Go Kerberos library for clients and services
Apache License 2.0
717 stars 243 forks source link

LoadCCache does not check file length #524

Open hwipl opened 1 year ago

hwipl commented 1 year ago

Currently, the LoadCCache() function does not check the length of the credentials cache file. This causes a panic in Unmarshal() when parsing a short ccache file like, e.g., an empty file.

LoadCCache() already handles file reading errors returned by os.ReadFile(). So, it could be useful to also check a minimum ccache file length and return an error in case of a short file to avoid the panic. I'll open a PR with a suggestion. I hope, that's OK :)