From e43aba6e56f6d95c0fc6f36ad5860cc6a1c83173 Mon Sep 17 00:00:00 2001 From: Wolfywolfy Date: Tue, 13 Aug 2024 17:28:48 -0300 Subject: [PATCH 1/2] Add ps3 to configure.ac. --- .github/workflows/ccpp.yml | 8 +- Makefile.platform | 8 ++ README | 3 +- include/ps3/config.h | 139 ----------------------------------- lib/Makefile.PS3_PPU | 100 ------------------------- lib/compat.h | 1 + lib/dcerpc.c | 6 +- lib/ntlmssp.c | 146 ++++++++++++++++++------------------- lib/smb3-seal.c | 12 +-- 9 files changed, 96 insertions(+), 327 deletions(-) delete mode 100644 include/ps3/config.h delete mode 100644 lib/Makefile.PS3_PPU diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 4c826ddf..b3df6c87 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -95,17 +95,17 @@ jobs: id: slug run: | echo "sha_name=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_ENV + # using pre-compiled sdk - name: Download PSL1GHT Toolchain run: | curl -sL https://github.com/bucanero/ps3toolchain/releases/download/ubuntu-latest-fad3b5fb/ps3dev-ubuntu-latest-2020-08-31.tar.gz | tar xvz -C ./ echo "PS3DEV=${GITHUB_WORKSPACE}/ps3dev" >> $GITHUB_ENV - echo "PSL1GHT=${GITHUB_WORKSPACE}/ps3dev" >> $GITHUB_ENV + echo "PSL1GHT=${GITHUB_WORKSPACE}/ps3dev" >> $GITHUB_ENV + - name: build libsmb2 run: | - cd lib - make -f Makefile.PS3_PPU clean - make -f Makefile.PS3_PPU + make ps3_ppu_install -f Makefile.platform build-ps4: name: PS4 diff --git a/Makefile.platform b/Makefile.platform index e3d804dd..92b50cf3 100644 --- a/Makefile.platform +++ b/Makefile.platform @@ -94,6 +94,14 @@ ps2_irx_all: ps2_irx_install: ps2_irx_all cmake --build build --target install +ps3_ppu_all: + sh ./bootstrap AR="powerpc64-ps3-elf-ar" CC="powerpc64-ps3-elf-gcc" LD="powerpc64-ps3-elf-ld" NM="powerpc64-ps3-elf-nm" RANLIB="powerpc64-ps3-elf-ranlib" STRIP="powerpc64-ps3-elf-strip" + sh ./configure --prefix="${PS3DEV}/host/ppu" --host=powerpc64-ps3-elf --includedir="${PS3DEV}/portlibs/include" --libdir="${PS3DEV}/portlibs/ppu/lib" CFLAGS="-DPS3_PPU_PLATFORM -DNEED_READV -DNEED_WRITEV -DNEED_GETLOGIN_R -DNEED_RANDOM -DNEED_SRANDOM -DNEED_GETADDRINFO -DNEED_FREEADDRINFO -O2 -Wall -fno-strict-aliasing -I${PSL1GHT}/ppu/include -I${PS3DEV}/portlibs/ppu/include" LDFLAGS="-L${PSL1GHT}/ppu/lib -L${PS3DEV}/portlibs/ppu/lib -lrt -llv2" PKG_CONFIG_PATH="${PS3DEV}/portlibs/ppu/lib/pkgconfig" --enable-examples=no --without-libkrb5 + make all + +ps3_ppu_install: ps3_ppu_all + make install clean + ps4_all: cmake -S . -B build "-DCMAKE_TOOLCHAIN_FILE=/opt/pacbrew/ps4/openorbis/cmake/ps4.cmake" "-DCMAKE_INSTALL_PREFIX=/opt/pacbrew/ps4/openorbis/" "-DCMAKE_PREFIX_PATH=/opt/pacbrew/ps4/openorbis/" cmake --build build diff --git a/README b/README index 8ffa5fce..f186fde4 100644 --- a/README +++ b/README @@ -243,8 +243,7 @@ To compile libsmb2 for the PS3 PPU, first install the PS3 toolchain and PSL1GHT SDK and set it up. Then to build libsmb2, run - $ cd lib - $ make -f Makefile.PS3_PPU install + $ make ps3_ppu_install -f Makefile.platform The process will copy the resulting libsmb2.a and the include/smb2 headers to your PSL1GHT SDK portlibs folder. diff --git a/include/ps3/config.h b/include/ps3/config.h deleted file mode 100644 index 5626016d..00000000 --- a/include/ps3/config.h +++ /dev/null @@ -1,139 +0,0 @@ -/* config.h. Generated from config.h.in by configure. */ -/* config.h.in. Generated from configure.ac by autoheader. */ - -/* Whether or not TCP sockets should be allowed to linger after closure */ -#define CONFIGURE_OPTION_TCP_LINGER 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_ARPA_INET_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_DLFCN_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_ERRNO_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_GSSAPI_GSSAPI_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_INTTYPES_H */ - -/* Whether we use gssapi_krb5 or not */ -/* #undef HAVE_LIBKRB5 */ - -/* Define to 1 if you have the `nsl' library (-lnsl). */ -/* #undef HAVE_LIBNSL */ - -/* Define to 1 if you have the `socket' library (-lsocket). */ -/* #undef HAVE_LIBSOCKET */ - -/* Whether we have linger */ -#define HAVE_LINGER 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_NETDB_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_NETINET_IN_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_NETINET_TCP_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_POLL_H */ - -/* Whether sockaddr struct has sa_len */ -/* #undef HAVE_SOCKADDR_LEN */ - -/* Whether we have sockaddr_Storage */ -/* #undef HAVE_SOCKADDR_STORAGE */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDIO_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_STRINGS_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_ERRNO_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_FCNTL_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_IOCTL_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_POLL_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_SOCKET_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_STAT_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_TIME_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_UIO_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS_UNISTD_H */ - -/* Define to 1 if you have the header file. */ -/* #undef HAVE_SYS__IOVEC_H */ - -/* Define to 1 if you have the header file. */ -#define HAVE_TIME_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to the sub-directory where libtool stores uninstalled libraries. */ -#define LT_OBJDIR ".libs/" - -/* Name of package */ -#define PACKAGE "libsmb2" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "ronniesahlberg@gmail.com" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "libsmb2" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "libsmb2 4.0.0" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "libsmb2" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "4.0.0" - -/* Define to 1 if all of the C90 standard headers exist (not just the ones - required in a freestanding environment). This macro is provided for - backward compatibility; new code need not use it. */ -#define STDC_HEADERS 1 - -/* Version number of package */ -#define VERSION "4.0.0" diff --git a/lib/Makefile.PS3_PPU b/lib/Makefile.PS3_PPU deleted file mode 100644 index 787413be..00000000 --- a/lib/Makefile.PS3_PPU +++ /dev/null @@ -1,100 +0,0 @@ -#--------------------------------------------------------------------------------- -# Clear the implicit built in rules -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- - -ifeq ($(strip $(PSL1GHT)),) -$(error "Please set PSL1GHT in your environment. export PSL1GHT=") -endif - -include $(PSL1GHT)/ppu_rules - - - -#--------------------------------------------------------------------------------- -ifeq ($(strip $(PLATFORM)),) -#--------------------------------------------------------------------------------- -export BASEDIR := $(CURDIR) -export DEPS := $(BASEDIR)/deps -export LIBS := $(BASEDIR)/lib - -#--------------------------------------------------------------------------------- -else -#--------------------------------------------------------------------------------- - -export LIBDIR := $(LIBS)/$(PLATFORM) -export DEPSDIR := $(DEPS)/$(PLATFORM) - -#--------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------- - -TARGET := libsmb2 -BUILD := build -SOURCE := ../lib -INCLUDE := ../include ../include/ps3 ../include/smb2 -DATA := data -LIBS := - -MACHDEP := -DPS3_PPU_PLATFORM -DHAVE_CONFIG_H -DNEED_READV -DNEED_WRITEV -DNEED_GETLOGIN_R -DNEED_RANDOM -DNEED_SRANDOM -DNEED_GETADDRINFO -DNEED_FREEADDRINFO -D_U_=/**/ - -CFLAGS += -O2 -Wall -mcpu=cell $(MACHDEP) -fno-strict-aliasing $(INCLUDES) - -LD := ppu-ld - -ifneq ($(BUILD),$(notdir $(CURDIR))) - -export OUTPUT := $(CURDIR)/$(TARGET) -export VPATH := $(foreach dir,$(SOURCE),$(CURDIR)/$(dir)) \ - $(foreach dir,$(DATA),$(CURDIR)/$(dir)) -export BUILDDIR := $(CURDIR)/$(BUILD) -export DEPSDIR := $(BUILDDIR) - -CFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.c))) -CXXFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.cpp))) -SFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.S))) -BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin))) - - -export OFILES := $(CFILES:.c=.o) \ - $(CXXFILES:.cpp=.o) \ - $(SFILES:.S=.o) \ - $(BINFILES:.bin=.bin.o) - -export BINFILES := $(BINFILES:.bin=.bin.h) - -export INCLUDES = $(foreach dir,$(INCLUDE),-I$(CURDIR)/$(dir)) \ - -I$(CURDIR)/$(BUILD) -I$(PSL1GHT)/ppu/include -I$(PORTLIBS)/include - -.PHONY: $(BUILD) install clean shader - -$(BUILD): - @[ -d $@ ] || mkdir -p $@ - @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile.PS3_PPU - -install: $(BUILD) -ifeq ($(PORTLIBS),) - @echo "$PORTLIBS is not set. Can not install libsmb2." - @exit 1 -endif - @echo Copying... - @[ -d $(PORTLIBS)/include/smb2 ] || mkdir -p $(PORTLIBS)/include/smb2 - @cp -frv ../include/smb2/*.h $(PORTLIBS)/include/smb2 - @cp -frv *.a $(PORTLIBS)/lib - @echo Done! - -clean: - @echo Clean... - @rm -rf $(BUILD) $(OUTPUT).elf $(OUTPUT).self $(OUTPUT).a - -else - -DEPENDS := $(OFILES:.o=.d) - -$(OUTPUT).a: $(OFILES) -$(OFILES): $(BINFILES) $(VCGFILES) $(VSAFILES) - --include $(DEPENDS) - -endif diff --git a/lib/compat.h b/lib/compat.h index 99c7803b..8c96fc19 100644 --- a/lib/compat.h +++ b/lib/compat.h @@ -545,6 +545,7 @@ ssize_t readv(t_socket fd, const struct iovec *iov, int iovcnt); int getlogin_r(char *buf, size_t size); void srandom(unsigned int seed); int random(void); + #define getaddrinfo smb2_getaddrinfo #define freeaddrinfo smb2_freeaddrinfo diff --git a/lib/dcerpc.c b/lib/dcerpc.c index ca0ad355..ac98bea4 100644 --- a/lib/dcerpc.c +++ b/lib/dcerpc.c @@ -647,7 +647,7 @@ static int dcerpc_decode_3264(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu, struct smb2_iovec *iov, int offset, void *ptr) { - uint32_t u32 = 0; + uint32_t u32_val = 0; if (offset < 0) { return offset; @@ -659,8 +659,8 @@ dcerpc_decode_3264(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu, dcerpc_get_uint64(ctx, iov, offset, ptr); offset += 8; } else { - dcerpc_get_uint32(ctx, iov, offset, &u32); - *(uint64_t *)ptr = u32; + dcerpc_get_uint32(ctx, iov, offset, &u32_val); + *(uint64_t *)ptr = u32_val; offset += 4; } return offset; diff --git a/lib/ntlmssp.c b/lib/ntlmssp.c index 833c979a..b0714284 100644 --- a/lib/ntlmssp.c +++ b/lib/ntlmssp.c @@ -177,23 +177,23 @@ static int ntlm_negotiate_message(struct smb2_context *smb2, struct auth_data *auth_data) { unsigned char ntlm[32]; - uint32_t u32; + uint32_t u32_val; memset(ntlm, 0, 32); memcpy(ntlm, "NTLMSSP", 8); - u32 = htole32(NEGOTIATE_MESSAGE); - memcpy(&ntlm[8], &u32, 4); + u32_val = htole32(NEGOTIATE_MESSAGE); + memcpy(&ntlm[8], &u32_val, 4); - u32 = NTLMSSP_NEGOTIATE_128| + u32_val = NTLMSSP_NEGOTIATE_128| NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY| /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN| */ NTLMSSP_NEGOTIATE_SEAL| /* NTLMSSP_NEGOTIATE_SIGN| */ NTLMSSP_REQUEST_TARGET|NTLMSSP_NEGOTIATE_OEM| NTLMSSP_NEGOTIATE_UNICODE; - u32 = htole32(u32); - memcpy(&ntlm[12], &u32, 4); + u32_val = htole32(u32_val); + memcpy(&ntlm[12], &u32_val, 4); if (encoder(&ntlm[0], 32, auth_data) < 0) { return -1; @@ -335,7 +335,7 @@ encode_temp(struct auth_data *auth_data, uint64_t t, char *client_challenge, 0x00, 0x00, 0x00, 0x00}; unsigned char zero[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - uint64_t u64; + uint64_t u64_val; if (encoder(&zero, 8, auth_data) < 0) { return -1; @@ -346,8 +346,8 @@ encode_temp(struct auth_data *auth_data, uint64_t t, char *client_challenge, if (encoder(sign, 8, auth_data) < 0) { return -1; } - u64 = htole64(t); - if (encoder(&u64, 8, auth_data) < 0) { + u64_val = htole64(t); + if (encoder(&u64_val, 8, auth_data) < 0) { return -1; } if (encoder(client_challenge, 8, auth_data) < 0) { @@ -384,7 +384,7 @@ encode_ntlm_auth(struct smb2_context *smb2, time_t ti, struct smb2_timeval tv _U_; char *server_name_buf; uint32_t server_name_len; - uint32_t u32; + uint32_t u32_val; uint32_t server_neg_flags; unsigned char key_exch[SMB2_KEY_SIZE]; uint8_t anonymous = 0; @@ -415,18 +415,18 @@ encode_ntlm_auth(struct smb2_context *smb2, time_t ti, memcpy(&server_neg_flags, &auth_data->ntlm_buf[20], 4); server_neg_flags = le32toh(server_neg_flags); - memcpy(&u32, &auth_data->ntlm_buf[40], 4); - u32 = le32toh(u32); - server_name_len = u32 >> 16; + memcpy(&u32_val, &auth_data->ntlm_buf[40], 4); + u32_val = le32toh(u32_val); + server_name_len = u32_val >> 16; - memcpy(&u32, &auth_data->ntlm_buf[44], 4); - u32 = le32toh(u32); + memcpy(&u32_val, &auth_data->ntlm_buf[44], 4); + u32_val = le32toh(u32_val); /* Server name must fit in the buffer */ - if (u32 >= auth_data->ntlm_len || - (u32 + server_name_len) > auth_data->ntlm_len) { + if (u32_val >= auth_data->ntlm_len || + (u32_val + server_name_len) > auth_data->ntlm_len) { goto finished; } - server_name_buf = (char *)&auth_data->ntlm_buf[u32]; + server_name_buf = (char *)&auth_data->ntlm_buf[u32_val]; if (encode_temp(auth_data, t, (char *)auth_data->client_challenge, server_challenge, server_name_buf, @@ -457,8 +457,8 @@ encode_ntlm_auth(struct smb2_context *smb2, time_t ti, encoder("NTLMSSP", 8, auth_data); /* message type */ - u32 = htole32(AUTHENTICATION_MESSAGE); - encoder(&u32, 4, auth_data); + u32_val = htole32(AUTHENTICATION_MESSAGE); + encoder(&u32_val, 4, auth_data); /* lm challenge response fields */ if (!anonymous) { @@ -466,22 +466,22 @@ encode_ntlm_auth(struct smb2_context *smb2, time_t ti, memcpy(&lm_buf[8], auth_data->client_challenge, 8); smb2_hmac_md5(&lm_buf[0], 16, ResponseKeyNT, 16, LMStr); - u32 = htole32(0x00180018); - encoder(&u32, 4, auth_data); - u32 = 0; - encoder(&u32, 4, auth_data); + u32_val = htole32(0x00180018); + encoder(&u32_val, 4, auth_data); + u32_val = 0; + encoder(&u32_val, 4, auth_data); } else { - u32 = 0; - encoder(&u32, 4, auth_data); - encoder(&u32, 4, auth_data); + u32_val = 0; + encoder(&u32_val, 4, auth_data); + encoder(&u32_val, 4, auth_data); } /* nt challenge response fields */ - u32 = htole32((NTChallengeResponse_len<<16)| + u32_val = htole32((NTChallengeResponse_len<<16)| NTChallengeResponse_len); - encoder(&u32, 4, auth_data); - u32 = 0; - encoder(&u32, 4, auth_data); + encoder(&u32_val, 4, auth_data); + u32_val = 0; + encoder(&u32_val, 4, auth_data); /* domain name fields */ if (!anonymous && auth_data->domain) { @@ -489,15 +489,15 @@ encode_ntlm_auth(struct smb2_context *smb2, time_t ti, if (utf16_domain == NULL) { goto finished; } - u32 = utf16_domain->len * 2; - u32 = htole32((u32 << 16) | u32); - encoder(&u32, 4, auth_data); - u32 = 0; - encoder(&u32, 4, auth_data); + u32_val = utf16_domain->len * 2; + u32_val = htole32((u32_val << 16) | u32_val); + encoder(&u32_val, 4, auth_data); + u32_val = 0; + encoder(&u32_val, 4, auth_data); } else { - u32 = 0; - encoder(&u32, 4, auth_data); - encoder(&u32, 4, auth_data); + u32_val = 0; + encoder(&u32_val, 4, auth_data); + encoder(&u32_val, 4, auth_data); } /* user name fields */ @@ -506,15 +506,15 @@ encode_ntlm_auth(struct smb2_context *smb2, time_t ti, if (utf16_user == NULL) { goto finished; } - u32 = utf16_user->len * 2; - u32 = htole32((u32 << 16) | u32); - encoder(&u32, 4, auth_data); - u32 = 0; - encoder(&u32, 4, auth_data); + u32_val = utf16_user->len * 2; + u32_val = htole32((u32_val << 16) | u32_val); + encoder(&u32_val, 4, auth_data); + u32_val = 0; + encoder(&u32_val, 4, auth_data); } else { - u32 = 0; - encoder(&u32, 4, auth_data); - encoder(&u32, 4, auth_data); + u32_val = 0; + encoder(&u32_val, 4, auth_data); + encoder(&u32_val, 4, auth_data); } /* workstation name fields */ @@ -523,24 +523,24 @@ encode_ntlm_auth(struct smb2_context *smb2, time_t ti, if (utf16_workstation == NULL) { goto finished; } - u32 = utf16_workstation->len * 2; - u32 = htole32((u32 << 16) | u32); - encoder(&u32, 4, auth_data); - u32 = 0; - encoder(&u32, 4, auth_data); + u32_val = utf16_workstation->len * 2; + u32_val = htole32((u32_val << 16) | u32_val); + encoder(&u32_val, 4, auth_data); + u32_val = 0; + encoder(&u32_val, 4, auth_data); } else { - u32 = 0; - encoder(&u32, 4, auth_data); - encoder(&u32, 4, auth_data); + u32_val = 0; + encoder(&u32_val, 4, auth_data); + encoder(&u32_val, 4, auth_data); } /* encrypted random session key */ - u32 = 0; - encoder(&u32, 4, auth_data); - encoder(&u32, 4, auth_data); + u32_val = 0; + encoder(&u32_val, 4, auth_data); + encoder(&u32_val, 4, auth_data); /* negotiate flags */ - u32 = NTLMSSP_NEGOTIATE_128| + u32_val = NTLMSSP_NEGOTIATE_128| NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY| /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN| NTLMSSP_NEGOTIATE_SIGN| @@ -548,44 +548,44 @@ encode_ntlm_auth(struct smb2_context *smb2, time_t ti, NTLMSSP_REQUEST_TARGET|NTLMSSP_NEGOTIATE_OEM| NTLMSSP_NEGOTIATE_UNICODE; if (anonymous) - u32 |= NTLMSSP_NEGOTIATE_ANONYMOUS; + u32_val |= NTLMSSP_NEGOTIATE_ANONYMOUS; else - u32 |= NTLMSSP_NEGOTIATE_SEAL; + u32_val |= NTLMSSP_NEGOTIATE_SEAL; - u32 = htole32(u32); - encoder(&u32, 4, auth_data); + u32_val = htole32(u32_val); + encoder(&u32_val, 4, auth_data); if (!anonymous) { /* append domain */ - u32 = htole32((uint32_t)auth_data->len); - memcpy(&auth_data->buf[32], &u32, 4); + u32_val = htole32((uint32_t)auth_data->len); + memcpy(&auth_data->buf[32], &u32_val, 4); if (utf16_domain) { encoder(utf16_domain->val, utf16_domain->len * 2, auth_data); } /* append user */ - u32 = htole32((uint32_t)auth_data->len); - memcpy(&auth_data->buf[40], &u32, 4); + u32_val = htole32((uint32_t)auth_data->len); + memcpy(&auth_data->buf[40], &u32_val, 4); encoder(utf16_user->val, utf16_user->len * 2, auth_data); /* append workstation */ - u32 = htole32((uint32_t)auth_data->len); - memcpy(&auth_data->buf[48], &u32, 4); + u32_val = htole32((uint32_t)auth_data->len); + memcpy(&auth_data->buf[48], &u32_val, 4); if (utf16_workstation) { encoder(utf16_workstation->val, utf16_workstation->len * 2, auth_data); } /* append LMChallengeResponse */ - u32 = htole32((uint32_t)auth_data->len); - memcpy(&auth_data->buf[16], &u32, 4); + u32_val = htole32((uint32_t)auth_data->len); + memcpy(&auth_data->buf[16], &u32_val, 4); encoder(LMStr, 16, auth_data); encoder(auth_data->client_challenge, 8, auth_data); /* append NTChallengeResponse */ - u32 = htole32((uint32_t)auth_data->len); - memcpy(&auth_data->buf[24], &u32, 4); + u32_val = htole32((uint32_t)auth_data->len); + memcpy(&auth_data->buf[24], &u32_val, 4); encoder(NTChallengeResponse_buf, NTChallengeResponse_len, auth_data); } diff --git a/lib/smb3-seal.c b/lib/smb3-seal.c index 056df0b2..6c2a45bd 100644 --- a/lib/smb3-seal.c +++ b/lib/smb3-seal.c @@ -72,9 +72,9 @@ smb3_encrypt_pdu(struct smb2_context *smb2, struct smb2_pdu *pdu) { struct smb2_pdu *tmp_pdu; - uint32_t spl, u32; + uint32_t spl, u32_val; int i; - uint16_t u16; + uint16_t u16_val; if (!smb2->seal) { return 0; @@ -99,10 +99,10 @@ smb3_encrypt_pdu(struct smb2_context *smb2, for (i = 20; i < 31; i++) { pdu->crypt[i] = random()&0xff; } - u32 = htole32(spl - 52); - memcpy(&pdu->crypt[36], &u32, 4); - u16 = htole16(SMB_ENCRYPTION_AES128_CCM); - memcpy(&pdu->crypt[42], &u16, 2); + u32_val = htole32(spl - 52); + memcpy(&pdu->crypt[36], &u32_val, 4); + u16_val = htole16(SMB_ENCRYPTION_AES128_CCM); + memcpy(&pdu->crypt[42], &u16_val, 2); memcpy(&pdu->crypt[44], &smb2->session_id, 8); spl = 52; /* transform header */ From c01661cefeb23fbbfa8bc854aafeae13c6fc5fd1 Mon Sep 17 00:00:00 2001 From: Wolfywolfy Date: Mon, 19 Aug 2024 07:15:55 -0300 Subject: [PATCH 2/2] Build cleanup. --- Makefile.platform | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.platform b/Makefile.platform index 92b50cf3..b8e76163 100644 --- a/Makefile.platform +++ b/Makefile.platform @@ -95,8 +95,8 @@ ps2_irx_install: ps2_irx_all cmake --build build --target install ps3_ppu_all: - sh ./bootstrap AR="powerpc64-ps3-elf-ar" CC="powerpc64-ps3-elf-gcc" LD="powerpc64-ps3-elf-ld" NM="powerpc64-ps3-elf-nm" RANLIB="powerpc64-ps3-elf-ranlib" STRIP="powerpc64-ps3-elf-strip" - sh ./configure --prefix="${PS3DEV}/host/ppu" --host=powerpc64-ps3-elf --includedir="${PS3DEV}/portlibs/include" --libdir="${PS3DEV}/portlibs/ppu/lib" CFLAGS="-DPS3_PPU_PLATFORM -DNEED_READV -DNEED_WRITEV -DNEED_GETLOGIN_R -DNEED_RANDOM -DNEED_SRANDOM -DNEED_GETADDRINFO -DNEED_FREEADDRINFO -O2 -Wall -fno-strict-aliasing -I${PSL1GHT}/ppu/include -I${PS3DEV}/portlibs/ppu/include" LDFLAGS="-L${PSL1GHT}/ppu/lib -L${PS3DEV}/portlibs/ppu/lib -lrt -llv2" PKG_CONFIG_PATH="${PS3DEV}/portlibs/ppu/lib/pkgconfig" --enable-examples=no --without-libkrb5 + sh ./bootstrap + sh ./configure --prefix="${PS3DEV}/host/ppu" --host=powerpc64-ps3-elf --target=-ps3-elf --build=powerpc64 --includedir="${PS3DEV}/portlibs/include" --libdir="${PS3DEV}/portlibs/ppu/lib" CFLAGS="-DPS3_PPU_PLATFORM -DNEED_READV -DNEED_WRITEV -DNEED_GETLOGIN_R -DNEED_RANDOM -DNEED_SRANDOM -DNEED_GETADDRINFO -DNEED_FREEADDRINFO -I${PSL1GHT}/ppu/include -I${PS3DEV}/portlibs/ppu/include" LDFLAGS="-L${PSL1GHT}/ppu/lib -L${PS3DEV}/portlibs/ppu/lib -lnet" --enable-examples=no --without-libkrb5 make all ps3_ppu_install: ps3_ppu_all