Skip to content

Commit

Permalink
ipvs: fix issue #947, a compiling error caused by string overflow war…
Browse files Browse the repository at this point in the history
…ning with gcc version 8.0+

Signed-off-by: ywc689 <[email protected]>
  • Loading branch information
ywc689 committed Apr 19, 2024
1 parent f7b0b50 commit efc101b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/ipvs/ip_vs_proxy_proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,10 @@ int proxy_proto_insert(struct proxy_info *ppinfo, struct dp_vs_conn *conn,
if (unlikely(NULL == inet_ntop(AF_INET, &ppinfo->addr.ip4.dst_addr,
tbuf2, sizeof(tbuf2))))
return EDPVS_INVAL;
sprintf(ppv1buf, "PROXY TCP4 %s %s %d %d\r\n", tbuf1, tbuf2,
ntohs(ppinfo->addr.ip4.src_port), ntohs(ppinfo->addr.ip4.dst_port));
if (unlikely(snprintf(ppv1buf, sizeof(ppv1buf), "PROXY TCP4 %s %s %d %d\r\n",
tbuf1, tbuf2, ntohs(ppinfo->addr.ip4.src_port),
ntohs(ppinfo->addr.ip4.dst_port)) > sizeof(ppv1buf)))
return EDPVS_INVAL;
break;
case AF_INET6:
if (unlikely(NULL == inet_ntop(AF_INET6, ppinfo->addr.ip6.src_addr,
Expand All @@ -494,8 +496,10 @@ int proxy_proto_insert(struct proxy_info *ppinfo, struct dp_vs_conn *conn,
if (unlikely(NULL == inet_ntop(AF_INET6, ppinfo->addr.ip6.dst_addr,
tbuf2, sizeof(tbuf2))))
return EDPVS_INVAL;
sprintf(ppv1buf, "PROXY TCP6 %s %s %d %d\r\n", tbuf1, tbuf2,
ntohs(ppinfo->addr.ip6.src_port), ntohs(ppinfo->addr.ip6.dst_port));
if (unlikely(snprintf(ppv1buf, sizeof(ppv1buf), "PROXY TCP6 %s %s %d %d\r\n",
tbuf1, tbuf2, ntohs(ppinfo->addr.ip6.src_port),
ntohs(ppinfo->addr.ip6.dst_port)) > sizeof(ppv1buf)))
return EDPVS_INVAL;
break;
default:
return EDPVS_NOTSUPP;
Expand Down

0 comments on commit efc101b

Please sign in to comment.