]> git.ipfire.org Git - thirdparty/curl.git/commit
rand: fix build error with autotools + LibreSSL
authorViktor Szakats <commit@vsz.me>
Sun, 5 Nov 2023 23:27:55 +0000 (23:27 +0000)
committerViktor Szakats <commit@vsz.me>
Mon, 6 Nov 2023 10:11:56 +0000 (10:11 +0000)
commit7925ba431b9a099daee1fa21d36c21887f787ad5
tree460e6e54c5c65f837cf9c42bc4e0787374cdbecd
parent1e4f5a4a745bd1b4018889f88e0ba7c1935992d5
rand: fix build error with autotools + LibreSSL

autotools unexpectedly detects `arc4random` because it is also looking
into dependency libs. One dependency, LibreSSL, happens to publish an
`arc4random` function (via its shared lib before v3.7, also via static
lib as of v3.8.2). When trying to use this function in `lib/rand.c`,
its protoype is missing. To fix that, curl included a prototype, but
that used a C99 type without including `stdint.h`, causing:

```
../../lib/rand.c:37:1: error: unknown type name 'uint32_t'
   37 | uint32_t arc4random(void);
      | ^
1 error generated.
```

This patch improves this by dropping the local prototype and instead
limiting `arc4random` use for non-OpenSSL builds. OpenSSL builds provide
their own random source anyway.

The better fix would be to teach autotools to not link dependency libs
while detecting `arc4random`.

LibreSSL publishing a non-namespaced `arc4random` tracked here:
https://github.com/libressl/portable/issues/928

Regression from 755ddbe901cd0c921fbc3ac5b3775c0dc683bc73 #10672

Reviewed-by: Daniel Stenberg
Fixes #12257
Closes #12274
lib/rand.c