Bug 2152978 - exim: pointer truncation bug in downstream-only exim-4.96-dlopen-localscan.patch patch
Summary: exim: pointer truncation bug in downstream-only exim-4.96-dlopen-localscan.pa...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: exim
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Florian Weimer
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PortingToModernCNoUpstream
TreeView+ depends on / blocked
 
Reported: 2022-12-13 17:02 UTC by Florian Weimer
Modified: 2022-12-13 18:46 UTC (History)
4 users (show)

Fixed In Version: exim-4.96-7.fc38
Clone Of:
Environment:
Last Closed: 2022-12-13 18:31:53 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
exim-localscan-c99.patch (482 bytes, patch)
2022-12-13 17:02 UTC, Florian Weimer
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Debian BTS 1026045 0 None None None 2022-12-13 18:46:10 UTC

Description Florian Weimer 2022-12-13 17:02:12 UTC
Created attachment 1932390 [details]
exim-localscan-c99.patch

The build log contains these warnings:

../src/local_scan.c:39:28: warning: implicit declaration of function 'malloc' [-Wimplicit-function-declaration]
   39 |         final_msg = (char*)malloc( final_length*sizeof(char) ) ;
      |                            ^~~~~~
../src/local_scan.c:17:1: note: include '<stdlib.h>' or provide a declaration of 'malloc'
   16 | #include <dlfcn.h>
  +++ |+#include <stdlib.h>
   17 | static int (*local_scan_fn)(int fd, uschar **return_text) = NULL;
../src/local_scan.c:39:28: warning: incompatible implicit declaration of built-in function 'malloc' [-Wbuiltin-declaration-mismatch]
   39 |         final_msg = (char*)malloc( final_length*sizeof(char) ) ;
      |                            ^~~~~~
../src/local_scan.c:39:28: note: include '<stdlib.h>' or provide a declaration of 'malloc'
../src/local_scan.c:45:22: warning: pointer targets in assignment from 'char *' to 'uschar *' {aka 'unsigned char *'} differ in signedness [-Wpointer-sign]
   45 |         *return_text = final_msg ;
      |                      ^

So on 64-bit architectures, the upper 32 bits of malloc are discarded, and this code crashes if it ever executed (assuming Exim is built as PIE).

Found while looking at C99-related build failures (which turn the implicit declaration warning into an error).

Upstream Exim does not have this bug, it's caused by the DLOPEN_LOCAL_SCAN patch.

Comment 1 Florian Weimer 2022-12-13 17:03:31 UTC
I should have added that I think this is harmless because it only happens after:

        base_msg=US"Local configuration error - local_scan() library failure\n";

So it's only relevant to wrong configurations.


Note You need to log in before you can comment on or make changes to this bug.