Commit 7ffcd660 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

rpcrt4: Fix GCC12.2 warnings.

GCC12.2 warns about dereferencing a pointer to RpcPktHdr while it has been allocated to the size of one of the packet (hence smaller in some cases). /home/eric/work/wine/dlls/rpcrt4/rpc_message.c:111:26: warning: array subscript 'RpcPktHdr[0]' is partly outside array bounds of 'unsigned char[24]' [-Warray-bounds] 111 | Header->common.rpc_ver = RPC_VER_MAJOR; This patch fixes the warnings by accessing the created object through a pointer to their type (and not through the union). Signed-off-by: 's avatarEric Pouech <eric.pouech@gmail.com>
parent 5d2547ce
...@@ -153,34 +153,34 @@ static RpcPktHdr *RPCRT4_BuildRequestHeader(ULONG DataRepresentation, ...@@ -153,34 +153,34 @@ static RpcPktHdr *RPCRT4_BuildRequestHeader(ULONG DataRepresentation,
RpcPktHdr *RPCRT4_BuildResponseHeader(ULONG DataRepresentation, ULONG BufferLength) RpcPktHdr *RPCRT4_BuildResponseHeader(ULONG DataRepresentation, ULONG BufferLength)
{ {
RpcPktHdr *header; RpcPktResponseHdr *header;
header = calloc(1, sizeof(header->response)); header = calloc(1, sizeof(*header));
if (header == NULL) { if (header == NULL) {
return NULL; return NULL;
} }
RPCRT4_BuildCommonHeader(&header->common, PKT_RESPONSE, DataRepresentation); RPCRT4_BuildCommonHeader(&header->common, PKT_RESPONSE, DataRepresentation);
header->common.frag_len = sizeof(header->response); header->common.frag_len = sizeof(*header);
header->response.alloc_hint = BufferLength; header->alloc_hint = BufferLength;
return header; return (RpcPktHdr *)header;
} }
RpcPktHdr *RPCRT4_BuildFaultHeader(ULONG DataRepresentation, RPC_STATUS Status) RpcPktHdr *RPCRT4_BuildFaultHeader(ULONG DataRepresentation, RPC_STATUS Status)
{ {
RpcPktHdr *header; RpcPktFaultHdr *header;
header = calloc(1, sizeof(header->fault)); header = calloc(1, sizeof(*header));
if (header == NULL) { if (header == NULL) {
return NULL; return NULL;
} }
RPCRT4_BuildCommonHeader(&header->common, PKT_FAULT, DataRepresentation); RPCRT4_BuildCommonHeader(&header->common, PKT_FAULT, DataRepresentation);
header->common.frag_len = sizeof(header->fault); header->common.frag_len = sizeof(*header);
header->fault.status = Status; header->status = Status;
return header; return (RpcPktHdr *)header;
} }
RpcPktHdr *RPCRT4_BuildBindHeader(ULONG DataRepresentation, RpcPktHdr *RPCRT4_BuildBindHeader(ULONG DataRepresentation,
...@@ -214,16 +214,16 @@ RpcPktHdr *RPCRT4_BuildBindHeader(ULONG DataRepresentation, ...@@ -214,16 +214,16 @@ RpcPktHdr *RPCRT4_BuildBindHeader(ULONG DataRepresentation,
static RpcPktHdr *RPCRT4_BuildAuthHeader(ULONG DataRepresentation) static RpcPktHdr *RPCRT4_BuildAuthHeader(ULONG DataRepresentation)
{ {
RpcPktHdr *header; RpcPktAuth3Hdr *header;
header = calloc(1, sizeof(header->auth3)); header = calloc(1, sizeof(*header));
if (header == NULL) if (header == NULL)
return NULL; return NULL;
RPCRT4_BuildCommonHeader(&header->common, PKT_AUTH3, DataRepresentation); RPCRT4_BuildCommonHeader(&header->common, PKT_AUTH3, DataRepresentation);
header->common.frag_len = sizeof(header->auth3); header->common.frag_len = sizeof(*header);
return header; return (RpcPktHdr*)header;
} }
RpcPktHdr *RPCRT4_BuildBindNackHeader(ULONG DataRepresentation, RpcPktHdr *RPCRT4_BuildBindNackHeader(ULONG DataRepresentation,
...@@ -231,21 +231,22 @@ RpcPktHdr *RPCRT4_BuildBindNackHeader(ULONG DataRepresentation, ...@@ -231,21 +231,22 @@ RpcPktHdr *RPCRT4_BuildBindNackHeader(ULONG DataRepresentation,
unsigned char RpcVersionMinor, unsigned char RpcVersionMinor,
unsigned short RejectReason) unsigned short RejectReason)
{ {
RpcPktHdr *header; RpcPktBindNAckHdr *header;
C_ASSERT(sizeof(*header) >= FIELD_OFFSET(RpcPktBindNAckHdr, protocols[1]));
header = calloc(1, FIELD_OFFSET(RpcPktHdr, bind_nack.protocols[1])); header = calloc(1, sizeof(*header));
if (header == NULL) { if (header == NULL) {
return NULL; return NULL;
} }
RPCRT4_BuildCommonHeader(&header->common, PKT_BIND_NACK, DataRepresentation); RPCRT4_BuildCommonHeader(&header->common, PKT_BIND_NACK, DataRepresentation);
header->common.frag_len = FIELD_OFFSET(RpcPktHdr, bind_nack.protocols[1]); header->common.frag_len = FIELD_OFFSET(RpcPktBindNAckHdr, protocols[1]);
header->bind_nack.reject_reason = RejectReason; header->reject_reason = RejectReason;
header->bind_nack.protocols_count = 1; header->protocols_count = 1;
header->bind_nack.protocols[0].rpc_ver = RpcVersion; header->protocols[0].rpc_ver = RpcVersion;
header->bind_nack.protocols[0].rpc_ver_minor = RpcVersionMinor; header->protocols[0].rpc_ver_minor = RpcVersionMinor;
return header; return (RpcPktHdr *)header;
} }
RpcPktHdr *RPCRT4_BuildBindAckHeader(ULONG DataRepresentation, RpcPktHdr *RPCRT4_BuildBindAckHeader(ULONG DataRepresentation,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment