[exim-dev] [Bug 3108] exim SIGSEGV on TLS connections on lat…

Kezdőlap
Üzenet törlése
Válasz az üzenetre
Szerző: Exim Bugzilla
Dátum:  
Címzett: exim-dev
Tárgy: [exim-dev] [Bug 3108] exim SIGSEGV on TLS connections on latest OpenBSD/amd64 -current snaps
https://bugs.exim.org/show_bug.cgi?id=3108

--- Comment #13 from Theo Buehler <tb@???> ---
OpenBSD doesn't provide `strchrnul()`, so the compat implementation is used.
However, there is no prototype and the compilation on OpenBSD shows the
following errors:

```
pdkim.c:671:12: warning: call to undeclared function 'strchrnul'; ISO C99 and
later do not support implicit function declarations
[-Wimplicit-function-declaration]
  end = US strchrnul(CS ele, ';');
           ^
pdkim.c:671:9: warning: cast to 'unsigned char *' from smaller integer type
'int' [-Wint-to-pointer-cast]
```


so llvm ends up truncating the pointer returned by `strchrnul()` to an int and
then sign-extends that back to a pointer which will be invalid and
dereferencing it on line 673 naturally segfaults.

The fix simply is to provide a prototype of `strchrnul()`, presumably in
`src/osfunctions.h`. I've confirmed this by looking at the disassembly on
aarch64. I've also provided Peter with a patch to test and waiting on him to
hear back.

Since most OS provide `strchrnul()` I expect the impact to be small.

As an aside, the `strchrnul()` compat implementation should use a cast for
correctness:

```
while (*US s != c && *s) s++;
```

Otherwise, if `c >= 0x80`, the comparison `*s != c` is always false on
architectures with signed char.

--
You are receiving this mail because:
You are on the CC list for the bug.

--
## subscription configuration (requires account):
## https://lists.exim.org/mailman3/postorius/lists/exim-dev.lists.exim.org/
## unsubscribe (doesn't require an account):
## exim-dev-unsubscribe@???
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/