| ... | ... | @@ -226,11 +226,17 @@ fn posixCallMainAndExit() noreturn { |
| 226 | 226 | // "The address of sixteen bytes containing a random value." |
| 227 | 227 | const addr = auxv[i].a_un.a_val; |
| 228 | 228 | if (addr == 0) break; |
| 229 | | const ptr = @intToPtr(*const [16]u8, addr); |
| 229 | const ptr = @intToPtr(*[16]u8, addr); |
| 230 | 230 | var seed: [32]u8 = undefined; |
| 231 | 231 | seed[0..16].* = ptr.*; |
| 232 | 232 | seed[16..].* = ptr.*; |
| 233 | 233 | tlcsprng.init(seed); |
| 234 | // Overwrite AT_RANDOM after we use it, otherwise our secure |
| 235 | // seed is sitting in memory ready for some other code in the |
| 236 | // program to reuse, and hence break our security. |
| 237 | // We play nice by refreshing it with fresh random bytes |
| 238 | // rather than clearing it. |
| 239 | std.crypto.random.bytes(ptr); |
| 234 | 240 | break; |
| 235 | 241 | }, |
| 236 | 242 | else => continue, |