diff options
-rw-r--r-- | epan/dissectors/packet-ipsec.c | 26 | ||||
-rw-r--r-- | epan/dissectors/packet-srvloc.c | 29 | ||||
-rw-r--r-- | plugins/profinet/packet-dcerpc-pn-io.c | 119 | ||||
-rw-r--r-- | ui/cli/tap-follow.c | 2 | ||||
-rw-r--r-- | ui/gtk/airpcap_gui_utils.c | 7 |
5 files changed, 95 insertions, 88 deletions
diff --git a/epan/dissectors/packet-ipsec.c b/epan/dissectors/packet-ipsec.c index 45ed09af60..c9631bf9a5 100644 --- a/epan/dissectors/packet-ipsec.c +++ b/epan/dissectors/packet-ipsec.c @@ -788,9 +788,13 @@ get_full_ipv4_addr(char* ipv4_address_expanded, char *ipv4_address) } else { - sscanf(addr_byte_string_tmp,"%u",&addr_byte); - if(addr_byte < 16) g_snprintf(addr_byte_string,4,"0%X",addr_byte); - else g_snprintf(addr_byte_string,4,"%X",addr_byte); + if (sscanf(addr_byte_string_tmp,"%u",&addr_byte) != 1) + return FALSE; + + if(addr_byte < 16) + g_snprintf(addr_byte_string,4,"0%X",addr_byte); + else + g_snprintf(addr_byte_string,4,"%X",addr_byte); for(i = 0; i < strlen(addr_byte_string); i++) { ipv4_address_expanded[cpt] = addr_byte_string[i]; @@ -813,9 +817,13 @@ get_full_ipv4_addr(char* ipv4_address_expanded, char *ipv4_address) } else { - sscanf(addr_byte_string_tmp,"%u",&addr_byte); - if(addr_byte < 16) g_snprintf(addr_byte_string,4,"0%X",addr_byte); - else g_snprintf(addr_byte_string,4,"%X",addr_byte); + if (sscanf(addr_byte_string_tmp,"%u",&addr_byte) != 1) + return FALSE; + + if(addr_byte < 16) + g_snprintf(addr_byte_string,4,"0%X",addr_byte); + else + g_snprintf(addr_byte_string,4,"%X",addr_byte); for(i = 0; i < strlen(addr_byte_string); i++) { ipv4_address_expanded[cpt] = addr_byte_string[i]; @@ -908,8 +916,10 @@ filter_address_match(gchar *addr, gchar *filter, gint typ) addr_string_tmp[0] = addr[i]; addr_string_tmp[1] = '\0'; - sscanf(filter_string_tmp,"%x",&filter_tmp); - sscanf(addr_string_tmp,"%x",&addr_tmp); + if (sscanf(filter_string_tmp,"%x",&filter_tmp) != 1) + return FALSE; + if (sscanf(addr_string_tmp,"%x",&addr_tmp) != 1) + return FALSE; for(i = 0; i < (filter_len % 4); i++) { if(((filter_tmp >> (4 -i -1)) & 1) != ((addr_tmp >> (4 -i -1)) & 1)) diff --git a/epan/dissectors/packet-srvloc.c b/epan/dissectors/packet-srvloc.c index b16c8c0c39..df8c467340 100644 --- a/epan/dissectors/packet-srvloc.c +++ b/epan/dissectors/packet-srvloc.c @@ -585,30 +585,26 @@ attr_list(proto_tree *tree, packet_info* pinfo, int hf, tvbuff_t *tvb, int offse } if (svc == 50) { byte_value = unicode_to_bytes(tvb, foffset, 16, TRUE); /* IP Address */ - prot = 0; - sscanf(byte_value,"%x",&prot); + prot = (guint32)strtoul(byte_value, NULL, 16); proto_tree_add_ipv4(srvloc_tree, hf_srvloc_add_ref_ip, tvb, foffset+2, 16, prot); byte_value = unicode_to_bytes(tvb, foffset+18, 8, FALSE); /* Port */ - prot = 0; - sscanf(byte_value,"%x",&prot); + prot = (guint32)strtoul(byte_value, NULL, 16); ti = proto_tree_add_uint(srvloc_tree, hf_srvloc_port, tvb, foffset+18, 4, prot); proto_item_set_len(ti, 8); } else { byte_value = unicode_to_bytes(tvb, foffset+2, 16, FALSE); /* IPX Network Address */ - prot = 0; + prot = (guint32)strtoul(byte_value, NULL, 16); sscanf(byte_value,"%x",&prot); ti = proto_tree_add_uint(srvloc_tree, hf_srvloc_network, tvb, foffset+2, 4, prot); proto_item_set_len(ti, 16); byte_value = unicode_to_bytes(tvb, foffset+18, 24, FALSE); /* IPX Node Address */ - prot = 0; - sscanf(byte_value,"%x",&prot); + prot = (guint32)strtoul(byte_value, NULL, 16); ti = proto_tree_add_uint(srvloc_tree, hf_srvloc_node, tvb, foffset+18, 4, prot); proto_item_set_len(ti, 24); byte_value = unicode_to_bytes(tvb, foffset+42, 8, FALSE); /* Socket */ - prot = 0; - sscanf(byte_value,"%x",&prot); + prot = (guint32)strtoul(byte_value, NULL, 16); ti = proto_tree_add_uint(srvloc_tree, hf_srvloc_socket, tvb, foffset+42, 4, prot); proto_item_set_len(ti, 8); } @@ -661,29 +657,24 @@ attr_list(proto_tree *tree, packet_info* pinfo, int hf, tvbuff_t *tvb, int offse } if (svc == 50) { byte_value = unicode_to_bytes(tvb, foffset, 8, TRUE); /* IP Address */ - prot = 0; - sscanf(byte_value,"%x",&prot); + prot = (guint32)strtoul(byte_value, NULL, 16); proto_tree_add_ipv4(srvloc_tree, hf_srvloc_add_ref_ip, tvb, foffset+1, 8, prot); byte_value = unicode_to_bytes(tvb, foffset+9, 4, FALSE); /* Port */ - prot = 0; - sscanf(byte_value,"%x",&prot); + prot = (guint32)strtoul(byte_value, NULL, 16); proto_tree_add_uint(srvloc_tree, hf_srvloc_port, tvb, foffset+9, 4, prot); } else { byte_value = unicode_to_bytes(tvb, foffset+1, 8, FALSE); /* IPX Network Address */ - prot = 0; - sscanf(byte_value,"%x",&prot); + prot = (guint32)strtoul(byte_value, NULL, 16); ti = proto_tree_add_uint(srvloc_tree, hf_srvloc_network, tvb, foffset+1, 4, prot); proto_item_set_len(ti, 8); byte_value = unicode_to_bytes(tvb, foffset+9, 12, FALSE); /* IPX Node Address */ - prot = 0; - sscanf(byte_value,"%x",&prot); + prot = (guint32)strtoul(byte_value, NULL, 16); ti = proto_tree_add_uint(srvloc_tree, hf_srvloc_node, tvb, foffset+9, 4, prot); proto_item_set_len(ti, 12); byte_value = unicode_to_bytes(tvb, foffset+21, 4, FALSE); /* Socket */ - prot = 0; - sscanf(byte_value,"%x",&prot); + prot = (guint32)strtoul(byte_value, NULL, 16); proto_tree_add_uint(srvloc_tree, hf_srvloc_socket, tvb, foffset+21, 4, prot); } i++; diff --git a/plugins/profinet/packet-dcerpc-pn-io.c b/plugins/profinet/packet-dcerpc-pn-io.c index 0826c71f61..490bb547bf 100644 --- a/plugins/profinet/packet-dcerpc-pn-io.c +++ b/plugins/profinet/packet-dcerpc-pn-io.c @@ -8215,11 +8215,12 @@ dissect_ExpectedSubmoduleBlockReq_block(tvbuff_t *tvb, int offset, if((strstr(puffer, vendorIdStr)) != NULL) { memset (convertStr, 0, sizeof(*convertStr)); pch = strstr(puffer, vendorIdStr); - sscanf(pch, "VendorID=\"%[^\"]", convertStr); - read_vendor_id = (guint32) strtoul (convertStr, NULL, 0); + if (sscanf(pch, "VendorID=\"%[^\"]", convertStr) == 1) { + read_vendor_id = (guint32) strtoul (convertStr, NULL, 0); - if(read_vendor_id == searchVendorID) { - vendorMatch = TRUE; /* found correct VendorID */ + if(read_vendor_id == searchVendorID) { + vendorMatch = TRUE; /* found correct VendorID */ + } } } @@ -8227,11 +8228,12 @@ dissect_ExpectedSubmoduleBlockReq_block(tvbuff_t *tvb, int offset, if((strstr(puffer, deviceIdStr)) != NULL) { memset(convertStr, 0, sizeof(*convertStr)); pch = strstr(puffer, deviceIdStr); - sscanf(pch, "DeviceID=\"%[^\"]", convertStr); - read_device_id = (guint32)strtoul(convertStr, NULL, 0); + if (sscanf(pch, "DeviceID=\"%[^\"]", convertStr) == 1) { + read_device_id = (guint32)strtoul(convertStr, NULL, 0); - if(read_device_id == searchDeviceID) { - deviceMatch = TRUE; /* found correct DeviceID */ + if(read_device_id == searchDeviceID) { + deviceMatch = TRUE; /* found correct DeviceID */ + } } } } @@ -8359,9 +8361,9 @@ dissect_ExpectedSubmoduleBlockReq_block(tvbuff_t *tvb, int offset, memset (convertStr, 0, sizeof(*convertStr)); pch = strstr(temp, fParameterIndexStr); - sscanf(pch, "Index=\"%[^\"]", convertStr); - io_data_object->fParameterIndexNr = (guint32)strtoul(convertStr, NULL, 0); - + if (sscanf(pch, "Index=\"%[^\"]", convertStr) == 1) { + io_data_object->fParameterIndexNr = (guint32)strtoul(convertStr, NULL, 0); + } break; /* found Indexnumber -> break search loop */ } } @@ -8373,62 +8375,65 @@ dissect_ExpectedSubmoduleBlockReq_block(tvbuff_t *tvb, int offset, if((strstr(temp, moduleStr)) != NULL) { /* find the String "ModuleIdentNumber=" */ memset (convertStr, 0, sizeof(*convertStr)); pch = strstr(temp, moduleStr); /* search for "ModuleIdentNumber=\"" within GSD-file */ - sscanf(pch, "ModuleIdentNumber=\"%[^\"]", convertStr); /* Change format of Value string-->numeric string */ - read_module_id = (guint32)strtoul(convertStr, NULL, 0); /* Change numeric string --> unsigned long; read_module_id contains the Value of the ModuleIdentNumber */ - - /* If the found ModuleID matches with the wanted ModuleID, search for the Submodule and break */ - if (read_module_id == io_data_object->moduleIdentNr) { - ++io_data_object->amountInGSDML; /* Save the amount of same (!) Module- & SubmoduleIdentNr in one GSD-file */ - - while(fgets(temp, MAX_LINE_LENGTH, fp) != NULL) { - if((strstr(temp, moduleNameInfo)) != NULL) { /* find the String "<Name" for the TextID */ - long filePosRecord; - - sscanf(temp, "%*s TextId=\"%[^\"]", tmp_moduletext); /* saves the correct TextId for the next searchloop */ - - filePosRecord = ftell(fp); /* save the current position of the filepointer (Offset) */ - /* ftell() may return -1 for error, don't move fp in this case */ - if (filePosRecord >= 0) { - while (fgets(temp, MAX_LINE_LENGTH, fp) != NULL && io_data_object->amountInGSDML == 1) { - /* Find a String with the saved TextID and with a fitting value for it in the same line. This value is the name of the Module! */ - if(((strstr(temp, tmp_moduletext)) != NULL) && ((strstr(temp, moduleValueInfo)) != NULL)) { - pch = strstr(temp, moduleValueInfo); - sscanf(pch, "Value=\"%[^\"]", io_data_object->moduleNameStr); - break; /* Found the name of the module */ - } - } + if (sscanf(pch, "ModuleIdentNumber=\"%[^\"]", convertStr) == 1) { /* Change format of Value string-->numeric string */ + read_module_id = (guint32)strtoul(convertStr, NULL, 0); /* Change numeric string --> unsigned long; read_module_id contains the Value of the ModuleIdentNumber */ - fseek(fp, filePosRecord, SEEK_SET); /* set filepointer to the correct TextID */ - } - } + /* If the found ModuleID matches with the wanted ModuleID, search for the Submodule and break */ + if (read_module_id == io_data_object->moduleIdentNr) { + ++io_data_object->amountInGSDML; /* Save the amount of same (!) Module- & SubmoduleIdentNr in one GSD-file */ - /* Search for Submoduleidentnumber in GSD-file */ - if((strstr(temp, subModuleStr)) != NULL) { - memset (convertStr, 0, sizeof(*convertStr)); - pch = strstr(temp, subModuleStr); - sscanf(pch, "SubmoduleIdentNumber=\"%[^\"]", convertStr); - read_submodule_id = (guint32) strtoul (convertStr, NULL, 0); /* read_submodule_id contains the Value of the SubModuleIdentNumber */ - - /* Find "PROFIsafeSupported" flag of the module in GSD-file */ - if(read_submodule_id == io_data_object->subModuleIdentNr) { - if((strstr(temp, profisafeStr)) != NULL) { - io_data_object->profisafeSupported = TRUE; /* flag is in the same line as SubmoduleIdentNr */ + while(fgets(temp, MAX_LINE_LENGTH, fp) != NULL) { + if((strstr(temp, moduleNameInfo)) != NULL) { /* find the String "<Name" for the TextID */ + long filePosRecord; + + if (sscanf(temp, "%*s TextId=\"%[^\"]", tmp_moduletext) != 1) /* saves the correct TextId for the next searchloop */ break; - } - else { /* flag is not in the same line as Submoduleidentnumber -> search for it */ - while(fgets(temp, MAX_LINE_LENGTH, fp) != NULL) { - if((strstr(temp, profisafeStr)) != NULL) { - io_data_object->profisafeSupported = TRUE; - break; /* Found the PROFIsafeSupported flag of the module */ + + filePosRecord = ftell(fp); /* save the current position of the filepointer (Offset) */ + /* ftell() may return -1 for error, don't move fp in this case */ + if (filePosRecord >= 0) { + while (fgets(temp, MAX_LINE_LENGTH, fp) != NULL && io_data_object->amountInGSDML == 1) { + /* Find a String with the saved TextID and with a fitting value for it in the same line. This value is the name of the Module! */ + if(((strstr(temp, tmp_moduletext)) != NULL) && ((strstr(temp, moduleValueInfo)) != NULL)) { + pch = strstr(temp, moduleValueInfo); + if (sscanf(pch, "Value=\"%[^\"]", io_data_object->moduleNameStr) == 1) + break; /* Found the name of the module */ } + } - else if((strstr(temp, ">")) != NULL) { + fseek(fp, filePosRecord, SEEK_SET); /* set filepointer to the correct TextID */ + } + } + + /* Search for Submoduleidentnumber in GSD-file */ + if((strstr(temp, subModuleStr)) != NULL) { + memset (convertStr, 0, sizeof(*convertStr)); + pch = strstr(temp, subModuleStr); + if (sscanf(pch, "SubmoduleIdentNumber=\"%[^\"]", convertStr) == 1) { + read_submodule_id = (guint32) strtoul (convertStr, NULL, 0); /* read_submodule_id contains the Value of the SubModuleIdentNumber */ + + /* Find "PROFIsafeSupported" flag of the module in GSD-file */ + if(read_submodule_id == io_data_object->subModuleIdentNr) { + if((strstr(temp, profisafeStr)) != NULL) { + io_data_object->profisafeSupported = TRUE; /* flag is in the same line as SubmoduleIdentNr */ break; } + else { /* flag is not in the same line as Submoduleidentnumber -> search for it */ + while(fgets(temp, MAX_LINE_LENGTH, fp) != NULL) { + if((strstr(temp, profisafeStr)) != NULL) { + io_data_object->profisafeSupported = TRUE; + break; /* Found the PROFIsafeSupported flag of the module */ + } + + else if((strstr(temp, ">")) != NULL) { + break; + } + } + } } + break; /* Found the PROFIsafe Module */ } } - break; /* Found the PROFIsafe Module */ } } } diff --git a/ui/cli/tap-follow.c b/ui/cli/tap-follow.c index 9d2b2d0cc9..50ab9b97f9 100644 --- a/ui/cli/tap-follow.c +++ b/ui/cli/tap-follow.c @@ -345,7 +345,7 @@ follow_arg_filter(const char **opt_argp, follow_info_t *follow_info) cli_follow_info_t* cli_follow_info = (cli_follow_info_t*)follow_info->gui_data; gboolean is_ipv6; - if (sscanf(*opt_argp, ",%u%n", &cli_follow_info->stream_index, &len) == 1 && + if (sscanf(*opt_argp, ",%d%n", &cli_follow_info->stream_index, &len) == 1 && ((*opt_argp)[len] == 0 || (*opt_argp)[len] == ',')) { *opt_argp += len; diff --git a/ui/gtk/airpcap_gui_utils.c b/ui/gtk/airpcap_gui_utils.c index 58459987d2..f0ba656dcb 100644 --- a/ui/gtk/airpcap_gui_utils.c +++ b/ui/gtk/airpcap_gui_utils.c @@ -1846,9 +1846,10 @@ airpcap_get_selected_channel_offset(GtkWidget *channel_offset_cb) { { if (airpcap_if_selected != NULL) { - sscanf(off_str, "%d", &offset); - if (offset >= -1 && offset <= 1) { - retval = offset; + if (sscanf(off_str, "%d", &offset) == 1) { + if (offset >= -1 && offset <= 1) { + retval = offset; + } } } } |