Commit Graph

6 Commits

Author SHA1 Message Date
Simon Kelley
65c2d6afd6 Fix standalone SHA256 implementation.
Bug report here:
https://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2023q4/017332.html

This error probably has no practical effect since even if the hash
is wrong, it's only compared internally to other hashes computed using
the same code.

Understanding the error:

hash-questions.c:168:21: runtime error: left shift of 128 by 24 places
cannot be represented in type 'int'

requires a certain amount of c-lawyerliness. I think the problem is that

m[i] = data[j] << 24

promotes the unsigned char data array value to int before doing the shift and
then promotes the result to unsigned char to match the type of m[i].
What needs to happen is to cast the unsigned char to unsigned int
BEFORE the shift.

This patch does that with explicit casts.
2023-11-22 22:02:05 +00:00
Simon Kelley
15dcdc824a Missed copyright date. 2023-04-05 17:42:23 +01:00
Simon Kelley
20b4a4ea5b Fix comment typo. 2022-07-07 20:56:07 +01:00
Simon Kelley
1033130b6c Handle malformed query packets sensibly.
Previously, hash_questions() would return a random hash
if the packet was malformed, and probably the hash of a previous
query. Now handle this as an error.
2022-01-09 23:21:55 +00:00
Etan Kissling
06d01f7ae4 Make comment style consistent.
Majority of code base does not use C90-style // end of line comments.
This formats the few existing exceptions using /* */ for consistency.
2021-08-12 17:02:45 +01:00
Simon Kelley
88a482fdb9 Rename hash_questions.c, for consistency. 2021-06-08 22:16:05 +01:00