Bug 283356

Summary: wtf/SHA1.cpp fails to build with Clang 18 and -Wunsafe-buffer-usage
Product: WebKit Reporter: Carlos Bentzen <cadubentzen>
Component: Web Template FrameworkAssignee: Carlos Bentzen <cadubentzen>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Linux   

Carlos Bentzen
Reported 2024-11-19 05:23:39 PST
``` /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:111:9: error: unsafe buffer access [-Werror,-Wunsafe-buffer-usage] 111 | m_buffer[m_cursor++] = std::to_integer<uint8_t>(byte); | ^~~~~~~~ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:124:30: error: unsafe buffer access [-Werror,-Wunsafe-buffer-usage] 124 | uint32_t hashValue = m_hash[i]; | ^~~~~~ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:137:5: error: unsafe buffer access [-Werror,-Wunsafe-buffer-usage] 137 | m_buffer[m_cursor++] = 0x80; | ^~~~~~~~ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:141:13: error: unsafe buffer access [-Werror,-Wunsafe-buffer-usage] 141 | m_buffer[m_cursor++] = 0x00; | ^~~~~~~~ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:146:9: error: unsafe buffer access [-Werror,-Wunsafe-buffer-usage] 146 | m_buffer[i] = 0x00; | ^~~~~~~~ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:151:9: error: unsafe buffer access [-Werror,-Wunsafe-buffer-usage] 151 | m_buffer[56 + (7 - i)] = bits & 0xFF; | ^~~~~~~~ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:164:17: error: unsafe buffer access [-Werror,-Wunsafe-buffer-usage] 164 | w[t] = (m_buffer[t * 4] << 24) | (m_buffer[t * 4 + 1] << 16) | (m_buffer[t * 4 + 2] << 8) | m_buffer[t * 4 + 3]; | ^~~~~~~~ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:164:43: error: unsafe buffer access [-Werror,-Wunsafe-buffer-usage] 164 | w[t] = (m_buffer[t * 4] << 24) | (m_buffer[t * 4 + 1] << 16) | (m_buffer[t * 4 + 2] << 8) | m_buffer[t * 4 + 3]; | ^~~~~~~~ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:164:73: error: unsafe buffer access [-Werror,-Wunsafe-buffer-usage] 164 | w[t] = (m_buffer[t * 4] << 24) | (m_buffer[t * 4 + 1] << 16) | (m_buffer[t * 4 + 2] << 8) | m_buffer[t * 4 + 3]; | ^~~~~~~~ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:164:101: error: unsafe buffer access [-Werror,-Wunsafe-buffer-usage] 164 | w[t] = (m_buffer[t * 4] << 24) | (m_buffer[t * 4 + 1] << 16) | (m_buffer[t * 4 + 2] << 8) | m_buffer[t * 4 + 3]; | ^~~~~~~~ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:169:18: error: unsafe buffer access [-Werror,-Wunsafe-buffer-usage] 169 | uint32_t b = m_hash[1]; | ^~~~~~ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:170:18: error: unsafe buffer access [-Werror,-Wunsafe-buffer-usage] 170 | uint32_t c = m_hash[2]; | ^~~~~~ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:171:18: error: unsafe buffer access [-Werror,-Wunsafe-buffer-usage] 171 | uint32_t d = m_hash[3]; | ^~~~~~ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:172:18: error: unsafe buffer access [-Werror,-Wunsafe-buffer-usage] 172 | uint32_t e = m_hash[4]; | ^~~~~~ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:184:5: error: unsafe buffer access [-Werror,-Wunsafe-buffer-usage] 184 | m_hash[1] += b; | ^~~~~~ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:185:5: error: unsafe buffer access [-Werror,-Wunsafe-buffer-usage] 185 | m_hash[2] += c; | ^~~~~~ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:186:5: error: unsafe buffer access [-Werror,-Wunsafe-buffer-usage] 186 | m_hash[3] += d; | ^~~~~~ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:187:5: error: unsafe buffer access [-Werror,-Wunsafe-buffer-usage] 187 | m_hash[4] += e; | ^~~~~~ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:162:14: error: 'w' is an unsafe buffer that does not perform bounds checks [-Werror,-Wunsafe-buffer-usage] 162 | uint32_t w[80] = { 0 }; | ~~~~~~~~~^~~~~~~~~~~~~ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:164:9: note: used in buffer access here 164 | w[t] = (m_buffer[t * 4] << 24) | (m_buffer[t * 4 + 1] << 16) | (m_buffer[t * 4 + 2] << 8) | m_buffer[t * 4 + 3]; | ^ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:166:64: note: used in buffer access here 166 | w[t] = rotateLeft(1, w[t - 3] ^ w[t - 8] ^ w[t - 14] ^ w[t - 16]); | ^ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:166:52: note: used in buffer access here 166 | w[t] = rotateLeft(1, w[t - 3] ^ w[t - 8] ^ w[t - 14] ^ w[t - 16]); | ^ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:166:41: note: used in buffer access here 166 | w[t] = rotateLeft(1, w[t - 3] ^ w[t - 8] ^ w[t - 14] ^ w[t - 16]); | ^ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:166:30: note: used in buffer access here 166 | w[t] = rotateLeft(1, w[t - 3] ^ w[t - 8] ^ w[t - 14] ^ w[t - 16]); | ^ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:166:9: note: used in buffer access here 166 | w[t] = rotateLeft(1, w[t - 3] ^ w[t - 8] ^ w[t - 14] ^ w[t - 16]); | ^ /host/home/cadubentzen/Projects/UpstreamWebKit/WebKit/Source/WTF/wtf/SHA1.cpp:175:64: note: used in buffer access here 175 | uint32_t temp = rotateLeft(5, a) + f(t, b, c, d) + e + w[t] + k(t); | ^ fatal error: too many errors emitted, stopping now [-ferror-limit=] ``` (working on a patch)
Attachments
Carlos Bentzen
Comment 1 2024-11-19 05:31:46 PST
EWS
Comment 2 2024-11-19 07:55:10 PST
Committed 286802@main (3a08f985baf7): <https://commits.webkit.org/286802@main> Reviewed commits have been landed. Closing PR #36845 and removing active labels.
Radar WebKit Bug Importer
Comment 3 2024-11-19 07:56:14 PST
Alexey Proskuryakov
Comment 4 2024-11-19 10:07:35 PST
I don't think that this is Gtk specific, re-titling. Thank you for the fix!
Note You need to log in before you can comment on or make changes to this bug.