change strcat->strncat

This commit is contained in:
Amin Ben Ramdhane 2020-04-16 12:49:52 +01:00
parent 72c1507f28
commit c0a476dec0
10 changed files with 88 additions and 88 deletions

View file

@ -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) 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 (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 (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) 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 (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 (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) 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 (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 (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) 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 (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(strcmp(tcp_flag, "PSH ACK ") == 0 && strlen(nexthdr) > strlen(FTP_PASV_RESPONSE) && strncmp(nexthdr, FTP_PASV_RESPONSE, strlen(FTP_PASV_RESPONSE)) == 0)
{

View file

@ -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) {
strcat(blist, "Public ");
stnrcat(blist, "Public ", 7);
}
if (n->flags & DM_BASIC_LIST) {
strcat(blist, "Basic ");
strncat(blist, "Basic ", 6);
}
if (n->flags & DM_XXXADMIN_LIST) {
strcat(blist, "xxxAdmin ");
strncat(blist, "xxxAdmin ", 9);
}
if (*blist)
blist[strlen(blist) - 1] = '\0';
if (n->flags & DM_PUBLIC_READ) {
strcat(bread, "Public ");
strncat(bread, "Public ", 7);
}
if (n->flags & DM_BASIC_READ) {
strcat(bread, "Basic ");
strncat(bread, "Basic ", 6);
}
if (n->flags & DM_XXXADMIN_READ) {
strcat(bread, "xxxAdmin ");
strncat(bread, "xxxAdmin ", 9);
}
if (*bread)
bread[strlen(bread) - 1] = '\0';
if (n->flags & DM_PUBLIC_WRITE) {
strcat(bwrite, "Public ");
strncat(bwrite, "Public ", 7);
}
if (n->flags & DM_BASIC_WRITE) {
strcat(bwrite, "Basic ");
strncat(bwrite, "Basic ", 6);
}
if (n->flags & DM_XXXADMIN_WRITE) {
strcat(bwrite, "xxxAdmin ");
strncat(bwrite, "xxxAdmin ", 9);
}
if (*bwrite)
bwrite[strlen(bwrite) - 1] = '\0';

View file

@ -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
strcat(node, param);
strncat(node, param, strlen(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) {
strcat(cmd, zone);
strncat(cmd, zone, strlen(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);
strcat(reset_params[i].node, reset_params[i].param);
strncat(reset_params[i].node, reset_params[i].param, strlen(reset_params[i].param));
}
const char *mode_enabled = "WPA2-Personal";

View file

@ -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') {
strcat(intf_name, " ");
strncat(intf_name, " ", 1);
}
strcat(intf_name, intf);
strncat(intf_name, intf, strlen(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') {
strcat(intf_tag, " ");
strncat(intf_tag, " ", 1);
}
strcat(intf_tag, name);
strncat(intf_tag, name, strlen(name));
/* Remove vlanport section from dmmap_network file. */
struct uci_section *s = NULL, *dmmap_section = NULL;
@ -1247,14 +1247,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') {
strcat(new_ifname, " ");
strncat(new_ifname, " ", 1);
}
strcat(new_ifname, tok);
strncat(new_ifname, tok, strlen(tok));
} else {
if (new_ifname[0] != '\0') {
strcat(new_ifname, " ");
strncat(new_ifname, " ", 1);
}
strcat(new_ifname, nontag_name);
strncat(new_ifname, nontag_name, strlen(nontag_name));
}
tok = strtok(NULL, " ");
}
@ -1355,9 +1355,9 @@ static int delete_br_vlanport(char *refparam, struct dmctx *ctx, void *data, cha
if (strstr(pch_tag, ".") == NULL) {
if( new_ifname[0] != '\0') {
strcat(new_ifname, " ");
strncat(new_ifname, " ", 1);
}
strcat(new_ifname, pch);
strncat(new_ifname, pch, strlen(pch));
} else {
/* Remove the tag. */
char name[50] = {0};
@ -1366,9 +1366,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') {
strcat(new_ifname, " ");
strncat(new_ifname, " ", 1);
}
strcat(new_ifname, tag);
strncat(new_ifname, tag, strlen(tag));
}
if (tag_id != NULL) {
/* Check if the tag_id is 1, then remove the device section. */
@ -1497,9 +1497,9 @@ static int delete_br_vlan(char *refparam, struct dmctx *ctx, void *data, char *i
}
if (final_list[0] != '\0') {
strcat(final_list, " ");
strncat(final_list, " ", 1);
}
strcat(final_list, tag);
strncat(final_list, tag, strlen(tag));
}
tok = strtok_r(NULL, " ", &end);
}
@ -1681,7 +1681,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';
strcat(buf, "1");
strncat(buf, "1", 1);
linker = buf;
}
}
@ -1769,7 +1769,7 @@ static int set_port_lower_layer(char *refparam, struct dmctx *ctx, void *data, c
/* Create untagged upstream interface. */
if (intf_tag[0] != '\0')
strcat(intf_tag, ".1");
strncat(intf_tag, ".1", 2);
if (strncmp(intf, intf_tag, sizeof(intf)) == 0) {
char *tok = strtok(intf, ".");
@ -1798,9 +1798,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') {
strcat(intf_name, " ");
strncat(intf_name, " ", 1);
}
strcat(intf_name, linker);
strncat(intf_name, linker, strlen(linker));
synchronize_multi_config_sections_with_dmmap_set("ports", "ethport", "dmmap_bridge_port", "bridge_port", "ifname", linker, instance, br_key);
@ -1967,9 +1967,9 @@ static int set_vlan_port_port_ref(char *refparam, struct dmctx *ctx, void *data,
}
}
if (new_ifname[0] != '\0') {
strcat(new_ifname, " ");
strncat(new_ifname, " ", 1);
}
strcat(new_ifname, new_if);
strncat(new_ifname, new_if, strlen(new_if));
/* Add ifname to vlanport section in dmmap. */
uci_path_foreach_option_eq(bbfdm, "dmmap_network", "vlanport", "vport_inst", instance, sec) {
@ -1990,9 +1990,9 @@ static int set_vlan_port_port_ref(char *refparam, struct dmctx *ctx, void *data,
}
} else {
if (new_ifname[0] != '\0') {
strcat(new_ifname, " ");
strncat(new_ifname, " ", 1);
}
strcat(new_ifname, tok);
strncat(new_ifname, tok, strlen(tok));
}
tok = strtok_r(NULL, " ", &end);
}

View file

@ -1572,9 +1572,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') {
strcat(buf, ",");
strncat(buf, ",", 1);
} else
strcat(buf, v);
strncat(buf, v, strlen(v));
}
*value = dmstrdup(buf);

View file

@ -276,7 +276,7 @@ static int del_ethernet_link_instance(char *sect_name)
/* Create untagged upstream interface. */
if (intf_tag[0] != '\0')
strcat(intf_tag, ".1");
strncat(intf_tag, ".1", 2);
/* Get section from section_name.*/
uci_foreach_sections("network", "interface", intf_s) {
@ -883,7 +883,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') {
strcat(intf_tag, ".1");
strncat(intf_tag, ".1", 2);
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 = "";
@ -1086,7 +1086,7 @@ static int set_ethlink_lowerlayer_eth_intf(char *lower_layer, char *instance, ch
/* Create untagged upstream interface. */
if (intf_tag[0] != '\0')
strcat(intf_tag, ".1");
strncat(intf_tag, ".1", 2);
char intf[20] = {0};
if (strcmp(linker, intf_tag) == 0)
@ -1280,7 +1280,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') {
strcat(intf_tag, ".1");
strncat(intf_tag, ".1", 2);
linker = get_macaddr_from_device(intf_tag);
}
}

View file

@ -323,8 +323,8 @@ static int get_rule_source_interface(char *refparam, struct dmctx *ctx, void *da
if (vallink == NULL)
continue;
if (*buf != '\0')
strcat(buf, ",");
strcat(buf, vallink);
strncat(buf, ",", 1);
strncat(buf, vallink, strlen(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')
strcat(buf, ",");
strcat(buf, ifaceobj);
strncat(buf, ",", 1);
strncat(buf, ifaceobj, strlen(ifaceobj));
}
}

View file

@ -233,8 +233,8 @@ static int get_nat_interface_setting_interface(char *refparam, struct dmctx *ctx
if (ifaceobj == NULL)
continue;
if (*buf != '\0')
strcat(buf, ",");
strcat(buf, ifaceobj);
strncat(buf, ",", 1);
strncat(buf, ifaceobj, strlen(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')
strcat(buf, ",");
strcat(buf, ifaceobj);
strncat(buf, ",", 1);
strncat(buf, ifaceobj, strlen(ifaceobj));
}
*value = dmstrdup(buf);
return 0;

View file

@ -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)) {
strcat(dmctx->all_instances, ",");
strncat(dmctx->all_instances, ",", 1);
}
strcat(dmctx->all_instances, instance);
strncat(dmctx->all_instances, instance, strlen(instance));
return 0;
}

View file

@ -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);
strcat(ret, delim);
strcat(ret, v);
strncat(ret, delim, strlen(delim));
strncat(ret, v, strlen(v));
}
}
return ret;