From 4d67121a681279575ea3c5c2a6a08ca159428521 Mon Sep 17 00:00:00 2001 From: Daniel Danzberger Date: Wed, 22 Apr 2020 10:08:39 +0200 Subject: [PATCH] Revert "change strcat->strncat" This reverts commit c0a476dec07f0fe908a1dc63b285265500850a95. --- dmdiagnostics.c | 72 ++++++++++++++++++++--------------------- dmentry.c | 18 +++++------ dmoperate.c | 6 ++-- dmtree/tr181/bridging.c | 44 ++++++++++++------------- dmtree/tr181/dhcpv4.c | 4 +-- dmtree/tr181/ethernet.c | 8 ++--- dmtree/tr181/firewall.c | 8 ++--- dmtree/tr181/nat.c | 8 ++--- libbbf_api/dmbbf.c | 4 +-- libbbf_api/dmjson.c | 4 +-- 10 files changed, 88 insertions(+), 88 deletions(-) diff --git a/dmdiagnostics.c b/dmdiagnostics.c index 0d11bff0..75e34e6e 100644 --- a/dmdiagnostics.c +++ b/dmdiagnostics.c @@ -66,15 +66,15 @@ static void ftp_download_per_packet(libtrace_packet_t *packet) else nexthdr = trace_get_payload_from_tcp(tcp, &remaining); - if (tcp->ecn_ns) strncat(tcp_flag, "ECN_NS ", 7); - if (tcp->cwr) strncat(tcp_flag, "CWR ", 4); - if (tcp->ece) strncat(tcp_flag, "ECE ", 4); - if (tcp->fin) strncat(tcp_flag, "FIN ", 4); - if (tcp->syn) strncat(tcp_flag, "SYN ", 4); - if (tcp->rst) strncat(tcp_flag, "RST ", 4); - if (tcp->psh) strncat(tcp_flag, "PSH ", 4); - if (tcp->ack) strncat(tcp_flag, "ACK ", 4); - if (tcp->urg) strncat(tcp_flag, "URG ", 4); + if (tcp->ecn_ns) strcat(tcp_flag, "ECN_NS "); + if (tcp->cwr) strcat(tcp_flag, "CWR "); + if (tcp->ece) strcat(tcp_flag, "ECE "); + if (tcp->fin) strcat(tcp_flag, "FIN "); + if (tcp->syn) strcat(tcp_flag, "SYN "); + if (tcp->rst) strcat(tcp_flag, "RST "); + if (tcp->psh) strcat(tcp_flag, "PSH "); + if (tcp->ack) strcat(tcp_flag, "ACK "); + if (tcp->urg) strcat(tcp_flag, "URG "); if (strcmp(tcp_flag, "PSH ACK ") == 0 && strlen(nexthdr) > strlen(FTP_SIZE_RESPONSE) && strncmp(nexthdr, FTP_SIZE_RESPONSE, strlen(FTP_SIZE_RESPONSE)) == 0) { @@ -158,15 +158,15 @@ static void http_download_per_packet(libtrace_packet_t *packet) else nexthdr = trace_get_payload_from_tcp(tcp, &remaining); - if (tcp->ecn_ns) strncat(tcp_flag, "ECN_NS ", 7); - if (tcp->cwr) strncat(tcp_flag, "CWR ", 4); - if (tcp->ece) strncat(tcp_flag, "ECE ", 4); - if (tcp->fin) strncat(tcp_flag, "FIN ", 4); - if (tcp->syn) strncat(tcp_flag, "SYN ", 4); - if (tcp->rst) strncat(tcp_flag, "RST ", 4); - if (tcp->psh) strncat(tcp_flag, "PSH ", 4); - if (tcp->ack) strncat(tcp_flag, "ACK ", 4); - if (tcp->urg) strncat(tcp_flag, "URG ", 4); + if (tcp->ecn_ns) strcat(tcp_flag, "ECN_NS "); + if (tcp->cwr) strcat(tcp_flag, "CWR "); + if (tcp->ece) strcat(tcp_flag, "ECE "); + if (tcp->fin) strcat(tcp_flag, "FIN "); + if (tcp->syn) strcat(tcp_flag, "SYN "); + if (tcp->rst) strcat(tcp_flag, "RST "); + if (tcp->psh) strcat(tcp_flag, "PSH "); + if (tcp->ack) strcat(tcp_flag, "ACK "); + if (tcp->urg) strcat(tcp_flag, "URG "); if (strcmp(tcp_flag, "SYN ") == 0 && download_stats.random_seq == 0) { ts = trace_get_timeval(packet); @@ -294,15 +294,15 @@ static void http_upload_per_packet(libtrace_packet_t *packet) else nexthdr = trace_get_payload_from_tcp(tcp, &remaining); - if (tcp->ecn_ns) strncat(tcp_flag, "ECN_NS ", 7); - if (tcp->cwr) strncat(tcp_flag, "CWR ", 4); - if (tcp->ece) strncat(tcp_flag, "ECE ", 4); - if (tcp->fin) strncat(tcp_flag, "FIN ", 4); - if (tcp->syn) strncat(tcp_flag, "SYN ", 4); - if (tcp->rst) strncat(tcp_flag, "RST ", 4); - if (tcp->psh) strncat(tcp_flag, "PSH ", 4); - if (tcp->ack) strncat(tcp_flag, "ACK ", 4); - if (tcp->urg) strncat(tcp_flag, "URG ", 4); + if (tcp->ecn_ns) strcat(tcp_flag, "ECN_NS "); + if (tcp->cwr) strcat(tcp_flag, "CWR "); + if (tcp->ece) strcat(tcp_flag, "ECE "); + if (tcp->fin) strcat(tcp_flag, "FIN "); + if (tcp->syn) strcat(tcp_flag, "SYN "); + if (tcp->rst) strcat(tcp_flag, "RST "); + if (tcp->psh) strcat(tcp_flag, "PSH "); + if (tcp->ack) strcat(tcp_flag, "ACK "); + if (tcp->urg) strcat(tcp_flag, "URG "); if (strcmp(tcp_flag, "SYN ") == 0 && download_stats.random_seq == 0) { @@ -395,15 +395,15 @@ static void ftp_upload_per_packet(libtrace_packet_t *packet) else nexthdr = trace_get_payload_from_tcp(tcp, &remaining); - if (tcp->ecn_ns) strncat(tcp_flag, "ECN_NS ", 7); - if (tcp->cwr) strncat(tcp_flag, "CWR ", 4); - if (tcp->ece) strncat(tcp_flag, "ECE ", 4); - if (tcp->fin) strncat(tcp_flag, "FIN ", 4); - if (tcp->syn) strncat(tcp_flag, "SYN ", 4); - if (tcp->rst) strncat(tcp_flag, "RST ", 4); - if (tcp->psh) strncat(tcp_flag, "PSH ", 4); - if (tcp->ack) strncat(tcp_flag, "ACK ", 4); - if (tcp->urg) strncat(tcp_flag, "URG ", 4); + if (tcp->ecn_ns) strcat(tcp_flag, "ECN_NS "); + if (tcp->cwr) strcat(tcp_flag, "CWR "); + if (tcp->ece) strcat(tcp_flag, "ECE "); + if (tcp->fin) strcat(tcp_flag, "FIN "); + if (tcp->syn) strcat(tcp_flag, "SYN "); + if (tcp->rst) strcat(tcp_flag, "RST "); + if (tcp->psh) strcat(tcp_flag, "PSH "); + if (tcp->ack) strcat(tcp_flag, "ACK "); + if (tcp->urg) strcat(tcp_flag, "URG "); if(strcmp(tcp_flag, "PSH ACK ") == 0 && strlen(nexthdr) > strlen(FTP_PASV_RESPONSE) && strncmp(nexthdr, FTP_PASV_RESPONSE, strlen(FTP_PASV_RESPONSE)) == 0) { diff --git a/dmentry.c b/dmentry.c index de8e1307..a6c790e4 100644 --- a/dmentry.c +++ b/dmentry.c @@ -956,35 +956,35 @@ int cli_output_dm_result(struct dmctx *dmctx, int fault, int cmd, int out) char bwrite[64] = ""; char bfac[32] = ""; if (n->flags & DM_PUBLIC_LIST) { - stnrcat(blist, "Public ", 7); + strcat(blist, "Public "); } if (n->flags & DM_BASIC_LIST) { - strncat(blist, "Basic ", 6); + strcat(blist, "Basic "); } if (n->flags & DM_XXXADMIN_LIST) { - strncat(blist, "xxxAdmin ", 9); + strcat(blist, "xxxAdmin "); } if (*blist) blist[strlen(blist) - 1] = '\0'; if (n->flags & DM_PUBLIC_READ) { - strncat(bread, "Public ", 7); + strcat(bread, "Public "); } if (n->flags & DM_BASIC_READ) { - strncat(bread, "Basic ", 6); + strcat(bread, "Basic "); } if (n->flags & DM_XXXADMIN_READ) { - strncat(bread, "xxxAdmin ", 9); + strcat(bread, "xxxAdmin "); } if (*bread) bread[strlen(bread) - 1] = '\0'; if (n->flags & DM_PUBLIC_WRITE) { - strncat(bwrite, "Public ", 7); + strcat(bwrite, "Public "); } if (n->flags & DM_BASIC_WRITE) { - strncat(bwrite, "Basic ", 6); + strcat(bwrite, "Basic "); } if (n->flags & DM_XXXADMIN_WRITE) { - strncat(bwrite, "xxxAdmin ", 9); + strcat(bwrite, "xxxAdmin "); } if (*bwrite) bwrite[strlen(bwrite) - 1] = '\0'; diff --git a/dmoperate.c b/dmoperate.c index 92111b8e..9aa34c0f 100644 --- a/dmoperate.c +++ b/dmoperate.c @@ -137,7 +137,7 @@ static char *get_param_val_from_op_cmd(char *op_cmd, const char *param) strncpy(node, op_cmd, ret - op_cmd +1); // Append param name to the trimmed path - strncat(node, param, strlen(param)); + strcat(node, param); // Get parameter value val = bbf_get_value_by_id(node); @@ -170,7 +170,7 @@ static opr_ret_t network_interface_reset(struct dmctx *dmctx, char *path, char * char *zone = NULL; zone = get_param_val_from_op_cmd(path, "Name"); if(zone) { - strncat(cmd, zone, strlen(zone)); + strcat(cmd, zone); dmfree(zone); } else { return FAIL; @@ -214,7 +214,7 @@ static opr_ret_t ap_security_reset(struct dmctx *dmctx, char *path, char *input) for (i = 0; i < len; i++) { strncpy(reset_params[i].node, node, 255); - strncat(reset_params[i].node, reset_params[i].param, strlen(reset_params[i].param)); + strcat(reset_params[i].node, reset_params[i].param); } const char *mode_enabled = "WPA2-Personal"; diff --git a/dmtree/tr181/bridging.c b/dmtree/tr181/bridging.c index 90a4c236..d49a4429 100644 --- a/dmtree/tr181/bridging.c +++ b/dmtree/tr181/bridging.c @@ -881,9 +881,9 @@ static int set_br_vlan_vid(char *refparam, struct dmctx *ctx, void *data, char * dmuci_get_value_by_section_string(port_s, "ifname", &intf); if (*intf != '\0') { if (intf_name[0] != '\0') { - strncat(intf_name, " ", 1); + strcat(intf_name, " "); } - strncat(intf_name, intf, strlen(intf)); + strcat(intf_name, intf); } } } else { @@ -935,9 +935,9 @@ static int set_br_vlan_vid(char *refparam, struct dmctx *ctx, void *data, char * } if (intf_tag[0] != '\0') { - strncat(intf_tag, " ", 1); + strcat(intf_tag, " "); } - strncat(intf_tag, name, strlen(name)); + strcat(intf_tag, name); /* Remove vlanport section from dmmap_network file. */ struct uci_section *s = NULL, *dmmap_section = NULL; @@ -1252,14 +1252,14 @@ static int remove_ifname_from_uci(char *ifname, void *data, char *nontag_name) while (tok != NULL) { if (strncmp(intf, tok, sizeof(intf)) != 0) { if (new_ifname[0] != '\0') { - strncat(new_ifname, " ", 1); + strcat(new_ifname, " "); } - strncat(new_ifname, tok, strlen(tok)); + strcat(new_ifname, tok); } else { if (new_ifname[0] != '\0') { - strncat(new_ifname, " ", 1); + strcat(new_ifname, " "); } - strncat(new_ifname, nontag_name, strlen(nontag_name)); + strcat(new_ifname, nontag_name); } tok = strtok(NULL, " "); } @@ -1360,9 +1360,9 @@ static int delete_br_vlanport(char *refparam, struct dmctx *ctx, void *data, cha if (strstr(pch_tag, ".") == NULL) { if( new_ifname[0] != '\0') { - strncat(new_ifname, " ", 1); + strcat(new_ifname, " "); } - strncat(new_ifname, pch, strlen(pch)); + strcat(new_ifname, pch); } else { /* Remove the tag. */ char name[50] = {0}; @@ -1371,9 +1371,9 @@ static int delete_br_vlanport(char *refparam, struct dmctx *ctx, void *data, cha char *tag = strtok_r(name, ".", &tag_id); if (tag != NULL) { if( new_ifname[0] != '\0') { - strncat(new_ifname, " ", 1); + strcat(new_ifname, " "); } - strncat(new_ifname, tag, strlen(tag)); + strcat(new_ifname, tag); } if (tag_id != NULL) { /* Check if the tag_id is 1, then remove the device section. */ @@ -1502,9 +1502,9 @@ static int delete_br_vlan(char *refparam, struct dmctx *ctx, void *data, char *i } if (final_list[0] != '\0') { - strncat(final_list, " ", 1); + strcat(final_list, " "); } - strncat(final_list, tag, strlen(tag)); + strcat(final_list, tag); } tok = strtok_r(NULL, " ", &end); } @@ -1686,7 +1686,7 @@ static int get_port_lower_layer(char *refparam, struct dmctx *ctx, void *data, c if(((struct bridging_port_args *)data)->vlan) { strncpy(buf, linker, 5); buf[5] = '\0'; - strncat(buf, "1", 1); + strcat(buf, "1"); linker = buf; } } @@ -1774,7 +1774,7 @@ static int set_port_lower_layer(char *refparam, struct dmctx *ctx, void *data, c /* Create untagged upstream interface. */ if (intf_tag[0] != '\0') - strncat(intf_tag, ".1", 2); + strcat(intf_tag, ".1"); if (strncmp(intf, intf_tag, sizeof(intf)) == 0) { char *tok = strtok(intf, "."); @@ -1803,9 +1803,9 @@ static int set_port_lower_layer(char *refparam, struct dmctx *ctx, void *data, c strncpy(intf_name, name, sizeof(intf_name) - 1); /* Append the interface name to it. */ if (intf_name[0] != '\0') { - strncat(intf_name, " ", 1); + strcat(intf_name, " "); } - strncat(intf_name, linker, strlen(linker)); + strcat(intf_name, linker); synchronize_multi_config_sections_with_dmmap_set("ports", "ethport", "dmmap_bridge_port", "bridge_port", "ifname", linker, instance, br_key); @@ -1972,9 +1972,9 @@ static int set_vlan_port_port_ref(char *refparam, struct dmctx *ctx, void *data, } } if (new_ifname[0] != '\0') { - strncat(new_ifname, " ", 1); + strcat(new_ifname, " "); } - strncat(new_ifname, new_if, strlen(new_if)); + strcat(new_ifname, new_if); /* Add ifname to vlanport section in dmmap. */ uci_path_foreach_option_eq(bbfdm, "dmmap_network", "vlanport", "vport_inst", instance, sec) { @@ -1995,9 +1995,9 @@ static int set_vlan_port_port_ref(char *refparam, struct dmctx *ctx, void *data, } } else { if (new_ifname[0] != '\0') { - strncat(new_ifname, " ", 1); + strcat(new_ifname, " "); } - strncat(new_ifname, tok, strlen(tok)); + strcat(new_ifname, tok); } tok = strtok_r(NULL, " ", &end); } diff --git a/dmtree/tr181/dhcpv4.c b/dmtree/tr181/dhcpv4.c index 69035e7e..0c2dbfcc 100644 --- a/dmtree/tr181/dhcpv4.c +++ b/dmtree/tr181/dhcpv4.c @@ -1573,9 +1573,9 @@ static int get_DHCPv4Client_IPRouters(char *refparam, struct dmctx *ctx, void *d if (strcmp(v, "0.0.0.0") == 0) continue; if (buf[0] != '\0') { - strncat(buf, ",", 1); + strcat(buf, ","); } else - strncat(buf, v, strlen(v)); + strcat(buf, v); } *value = dmstrdup(buf); diff --git a/dmtree/tr181/ethernet.c b/dmtree/tr181/ethernet.c index 409b541b..872327a1 100644 --- a/dmtree/tr181/ethernet.c +++ b/dmtree/tr181/ethernet.c @@ -276,7 +276,7 @@ static int del_ethernet_link_instance(char *sect_name) /* Create untagged upstream interface. */ if (intf_tag[0] != '\0') - strncat(intf_tag, ".1", 2); + strcat(intf_tag, ".1"); /* Get section from section_name.*/ uci_foreach_sections("network", "interface", intf_s) { @@ -886,7 +886,7 @@ static int get_EthernetLink_LowerLayers(char *refparam, struct dmctx *ctx, void get_upstream_interface(intf_tag, sizeof(intf_tag)); if (intf_tag[0] != '\0') { - strncat(intf_tag, ".1", 2); + strcat(intf_tag, ".1"); adm_entry_get_linker_param(ctx, dm_print_path("%s%cEthernet%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), intf_tag, value); if (*value == NULL) *value = ""; @@ -1089,7 +1089,7 @@ static int set_ethlink_lowerlayer_eth_intf(char *lower_layer, char *instance, ch /* Create untagged upstream interface. */ if (intf_tag[0] != '\0') - strncat(intf_tag, ".1", 2); + strcat(intf_tag, ".1"); char intf[20] = {0}; if (strcmp(linker, intf_tag) == 0) @@ -1284,7 +1284,7 @@ static int get_EthernetVLANTermination_LowerLayers(char *refparam, struct dmctx char intf_tag[64] = {0}; get_upstream_interface(intf_tag, sizeof(intf_tag)); if (intf_tag[0] != '\0') { - strncat(intf_tag, ".1", 2); + strcat(intf_tag, ".1"); linker = get_macaddr_from_device(intf_tag); } } diff --git a/dmtree/tr181/firewall.c b/dmtree/tr181/firewall.c index 86c5b0f2..5bb90e15 100644 --- a/dmtree/tr181/firewall.c +++ b/dmtree/tr181/firewall.c @@ -323,8 +323,8 @@ static int get_rule_source_interface(char *refparam, struct dmctx *ctx, void *da if (vallink == NULL) continue; if (*buf != '\0') - strncat(buf, ",", 1); - strncat(buf, vallink, strlen(vallink)); + strcat(buf, ","); + strcat(buf, vallink); } } else { adm_entry_get_linker_param(ctx, dm_print_path("%s%cIP%cInterface%c", dmroot, dm_delim, dm_delim, dm_delim), zone, &vallink); @@ -357,8 +357,8 @@ static int get_rule_dest_interface(char *refparam, struct dmctx *ctx, void *data if (ifaceobj == NULL) continue; if (*buf != '\0') - strncat(buf, ",", 1); - strncat(buf, ifaceobj, strlen(ifaceobj)); + strcat(buf, ","); + strcat(buf, ifaceobj); } } diff --git a/dmtree/tr181/nat.c b/dmtree/tr181/nat.c index a31b56ef..e6fb3203 100644 --- a/dmtree/tr181/nat.c +++ b/dmtree/tr181/nat.c @@ -233,8 +233,8 @@ static int get_nat_interface_setting_interface(char *refparam, struct dmctx *ctx if (ifaceobj == NULL) continue; if (*buf != '\0') - strncat(buf, ",", 1); - strncat(buf, ifaceobj, strlen(ifaceobj)); + strcat(buf, ","); + strcat(buf, ifaceobj); } *value = dmstrdup(buf); return 0; @@ -349,8 +349,8 @@ static int get_nat_port_mapping_interface(char *refparam, struct dmctx *ctx, voi if (ifaceobj == NULL) continue; if (*buf != '\0') - strncat(buf, ",", 1); - strncat(buf, ifaceobj, strlen(ifaceobj)); + strcat(buf, ","); + strcat(buf, ifaceobj); } *value = dmstrdup(buf); return 0; diff --git a/libbbf_api/dmbbf.c b/libbbf_api/dmbbf.c index 43918de4..513c9f19 100644 --- a/libbbf_api/dmbbf.c +++ b/libbbf_api/dmbbf.c @@ -3050,9 +3050,9 @@ static int mobj_upnp_get_instance_numbers(DMOBJECT_ARGS) if (!node->is_instanceobj || !node->matched) return FAULT_UPNP_703; if (*(dmctx->all_instances)) { - strncat(dmctx->all_instances, ",", 1); + strcat(dmctx->all_instances, ","); } - strncat(dmctx->all_instances, instance, strlen(instance)); + strcat(dmctx->all_instances, instance); return 0; } diff --git a/libbbf_api/dmjson.c b/libbbf_api/dmjson.c index 34663f9c..463f17f2 100644 --- a/libbbf_api/dmjson.c +++ b/libbbf_api/dmjson.c @@ -253,8 +253,8 @@ char *____dmjson_get_value_array_all(json_object *mainjobj, char *delim, char *a ret = dmstrdup(v); } else if (*v) { ret = dmrealloc(ret, strlen(ret) + dlen + strlen(v) + 1); - strncat(ret, delim, strlen(delim)); - strncat(ret, v, strlen(v)); + strcat(ret, delim); + strcat(ret, v); } } return ret;