Re: [PATCH v2 2/5] sha1_file.c: keep a good name for "unknown" hash_algos[UNKNOWN]
- From
brian m. carlson <sandals@crustytoothpaste.net>
- Date
- Feb 24, 2018, 22:39 UTC
- Message-ID
- <20180224223915.GB4620@genre.crustytoothpaste.net>
- In-Reply-To
- <20180224033429.9656-3-pclouds@gmail.com>
On Sat, Feb 24, 2018 at 10:34:26AM +0700, Nguyễn Thái Ngọc Duy wrote:
> This is mostly for displaying the hash algorithm name when we report > errors. Printing "unknown" with '%s' is much better than '(null)' in > glibc printf version (and probably could crash if other implementations > do not check for NULL pointer)
This is a good change. Using a NULL pointer with %s on the BSDs definitely did cause a crash, last I checked.
I looked at the comment I wrote in hash.h, and based on that, it is indeed very likely that someone would accidentally write code this way.
-- brian m. carlson / brian with sandals: Houston, Texas, US https://www.crustytoothpaste.net/~bmc | My opinion only OpenPGP: https://keybase.io/bk2204