I spun up an s390x VM to do some testing and found a couple of instances of incorrect pointer usage.
Patches attached. J.
From 9e70aed92e88af93378aa9a450426f156bdda4c9 Mon Sep 17 00:00:00 2001 From: Jeremy Sowden <jer...@azazel.net> Date: Fri, 28 Jun 2019 15:34:11 +0100 Subject: [PATCH 1/2] wmbiff: fixed endianness problems connecting to POP and IMAP servers. `addr.sin_addr.s_addr` is a `uint32_t` in NBO, so assigning a `struct in_addr` cast to `unsigned long` will break on 64-bit big-endian architectures. Signed-off-by: Jeremy Sowden <jer...@azazel.net> --- wmbiff/socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wmbiff/socket.c b/wmbiff/socket.c index 87d0732cfb50..6c722f90483e 100644 --- a/wmbiff/socket.c +++ b/wmbiff/socket.c @@ -62,7 +62,7 @@ static int ipv4_sock_connect(struct in_addr *address, uint16_t port) perror("fcntl(FD_CLOEXEC)"); addr.sin_family = AF_INET; - addr.sin_addr.s_addr = *(u_long *) address; + addr.sin_addr = *address; addr.sin_port = htons(port); i = connect(fd, (struct sockaddr *) &addr, sizeof(struct sockaddr)); if (i == -1) { -- 2.20.1
From 5034d3b24a54058deccd7bdc20dc0693eff5b65d Mon Sep 17 00:00:00 2001 From: Jeremy Sowden <jer...@azazel.net> Date: Fri, 28 Jun 2019 15:16:16 +0100 Subject: [PATCH 2/2] wmbiff: fixed endianness problems parsing server-ports. `regulo_atoi` expects a pointer-to-int and `PCU.serverPort` is a `uint16_t`, so `&PCU.serverPort` is not compatible and we need to use an `int` temporary variable to avoid endianness problems. Signed-off-by: Jeremy Sowden <jer...@azazel.net> --- wmbiff/Imap4Client.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/wmbiff/Imap4Client.c b/wmbiff/Imap4Client.c index ea24dd9d075a..395db2ba903b 100644 --- a/wmbiff/Imap4Client.c +++ b/wmbiff/Imap4Client.c @@ -501,13 +501,19 @@ int imap4Create( /*@notnull@ */ Pop3 pc, const char *const str) NULL }; char *unaliased_str; + /* + * regulo_atoi expects a pointer-to-int and pop_imap.serverPort is a + * uint16_t, so &pop_imap.serverPort is not compatible and we need to use an + * int temporary variable to avoid endianness problems. + */ + int serverPort; struct regulo regulos[] = { {1, PCU.userName, regulo_strcpy}, {2, PCU.password, regulo_strcpy}, {3, PCU.serverName, regulo_strcpy}, {4, pc->path, regulo_strcpy_skip1}, - {7, &PCU.serverPort, regulo_atoi}, + {7, &serverPort, regulo_atoi}, {9, PCU.authList, regulo_strcpy_tolower}, {0, NULL, NULL} }; @@ -536,7 +542,7 @@ int imap4Create( /*@notnull@ */ Pop3 pc, const char *const str) } /* defaults */ - PCU.serverPort = (PCU.dossl != 0) ? 993 : 143; + serverPort = (PCU.dossl != 0) ? 993 : 143; PCU.authList[0] = '\0'; /* argh, str and pc->path are aliases, so we can't just write the default @@ -559,6 +565,8 @@ int imap4Create( /*@notnull@ */ Pop3 pc, const char *const str) return -1; } + PCU.serverPort = serverPort; + PCU.password_len = strlen(PCU.password); if (PCU.password[0] == '\0') { PCU.interactive_password = 1; -- 2.20.1
signature.asc
Description: PGP signature