Skip to content

Commit d074bc9

Browse files
Fix error set in create_hdr functions
1 parent ab4f79d commit d074bc9

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

src/proxy_protocol.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ uint8_t *pp2_create_hdr(const pp_info_t *pp_info, uint16_t *pp2_hdr_len, int32_t
589589
proxy_hdr_v2.ver_cmd = '\x20';
590590
if (!pp_info->pp2_info.local)
591591
{
592-
*error = ERR_PP2_CMD;
592+
*error = -ERR_PP2_CMD;
593593
return NULL;
594594
}
595595
}
@@ -598,12 +598,12 @@ uint8_t *pp2_create_hdr(const pp_info_t *pp_info, uint16_t *pp2_hdr_len, int32_t
598598
proxy_addr_len = 12;
599599
if (inet_pton(AF_INET, pp_info->src_addr, &proxy_addr.ipv4_addr.src_addr) != 1)
600600
{
601-
*error = ERR_PP2_IPV4_SRC_IP;
601+
*error = -ERR_PP2_IPV4_SRC_IP;
602602
return NULL;
603603
}
604604
if (inet_pton(AF_INET, pp_info->dst_addr, &proxy_addr.ipv4_addr.dst_addr) != 1)
605605
{
606-
*error = ERR_PP2_IPV4_DST_IP;
606+
*error = -ERR_PP2_IPV4_DST_IP;
607607
return NULL;
608608
}
609609
proxy_addr.ipv4_addr.src_port = htons(pp_info->src_port);
@@ -614,12 +614,12 @@ uint8_t *pp2_create_hdr(const pp_info_t *pp_info, uint16_t *pp2_hdr_len, int32_t
614614
proxy_addr_len = 36;
615615
if (inet_pton(AF_INET6, pp_info->src_addr, &proxy_addr.ipv6_addr.src_addr) != 1)
616616
{
617-
*error = ERR_PP2_IPV6_SRC_IP;
617+
*error = -ERR_PP2_IPV6_SRC_IP;
618618
return NULL;
619619
}
620620
if (inet_pton(AF_INET6, pp_info->dst_addr, &proxy_addr.ipv6_addr.dst_addr) != 1)
621621
{
622-
*error = ERR_PP2_IPV6_DST_IP;
622+
*error = -ERR_PP2_IPV6_DST_IP;
623623
return NULL;
624624
}
625625
proxy_addr.ipv6_addr.src_port = htons(pp_info->src_port);
@@ -633,13 +633,13 @@ uint8_t *pp2_create_hdr(const pp_info_t *pp_info, uint16_t *pp2_hdr_len, int32_t
633633
}
634634
else
635635
{
636-
*error = ERR_PP2_ADDR_FAMILY;
636+
*error = -ERR_PP2_ADDR_FAMILY;
637637
return NULL;
638638
}
639639

640640
if (pp_info->transport_protocol > TRANSPORT_PROTOCOL_DGRAM)
641641
{
642-
*error = ERR_PP2_TRANSPORT_PROTOCOL;
642+
*error = -ERR_PP2_TRANSPORT_PROTOCOL;
643643
return NULL;
644644
}
645645

@@ -683,7 +683,7 @@ uint8_t *pp2_create_hdr(const pp_info_t *pp_info, uint16_t *pp2_hdr_len, int32_t
683683
uint8_t *pp2_hdr = malloc(*pp2_hdr_len);
684684
if (!pp2_hdr)
685685
{
686-
*error = ERR_HEAP_ALLOC;
686+
*error = -ERR_HEAP_ALLOC;
687687
return NULL;
688688
}
689689
uint16_t index = 0;
@@ -739,7 +739,7 @@ static uint8_t *pp1_create_hdr(const pp_info_t *pp_info, uint16_t *pp1_hdr_len,
739739
{
740740
if (pp_info->transport_protocol != TRANSPORT_PROTOCOL_UNSPEC && pp_info->transport_protocol != TRANSPORT_PROTOCOL_STREAM)
741741
{
742-
*error = ERR_PP1_TRANSPORT_FAMILY;
742+
*error = -ERR_PP1_TRANSPORT_FAMILY;
743743
return NULL;
744744
}
745745

@@ -755,12 +755,12 @@ static uint8_t *pp1_create_hdr(const pp_info_t *pp_info, uint16_t *pp1_hdr_len,
755755
const char *fam = pp_info->address_family == ADDR_FAMILY_INET ? "TCP4" : "TCP6";
756756
if (strlen(pp_info->src_addr) > 39)
757757
{
758-
*error = ERR_PP1_IPV4_SRC_IP;
758+
*error = -ERR_PP1_IPV4_SRC_IP;
759759
return NULL;
760760
}
761761
if (strlen(pp_info->dst_addr) > 39)
762762
{
763-
*error = ERR_PP1_IPV4_DST_IP;
763+
*error = -ERR_PP1_IPV4_DST_IP;
764764
return NULL;
765765
}
766766
char src_addr[39+1];
@@ -771,15 +771,15 @@ static uint8_t *pp1_create_hdr(const pp_info_t *pp_info, uint16_t *pp1_hdr_len,
771771
}
772772
else
773773
{
774-
*error = ERR_PP1_TRANSPORT_FAMILY;
774+
*error = -ERR_PP1_TRANSPORT_FAMILY;
775775
return NULL;
776776
}
777777

778778
/* Create the PROXY protocol header */
779779
uint8_t *pp1_hdr = malloc(*pp1_hdr_len);
780780
if (!pp1_hdr)
781781
{
782-
*error = ERR_HEAP_ALLOC;
782+
*error = -ERR_HEAP_ALLOC;
783783
return NULL;
784784
}
785785
memcpy(pp1_hdr, block, *pp1_hdr_len);
@@ -799,7 +799,7 @@ uint8_t *pp_create_hdr(uint8_t version, const pp_info_t *pp_info, uint16_t *pp_h
799799
}
800800
else
801801
{
802-
*error = ERR_PP_VERSION;
802+
*error = -ERR_PP_VERSION;
803803
return NULL;
804804
}
805805
}

0 commit comments

Comments
 (0)