473,666 Members | 1,992 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem passing a string to a function

Hi,
I am passing a tcpdump filter to a function which compiles the filter
using pcap_compile and then sets it.
Here is the filter,

ip[12:4]>=0x0000 and ip[12:4] <=0xd9295a3 and ip[16:4] >=0x0000 and
ip[16:4] <=0x3ca9b416 and tcp[0:2]>=0 and tcp[0:2]<=23923 and
tcp[2:2]>=0 and tcp[2:2]<=64582 and tcp[2:2]<=655355

I have many threads passing different filters of a similar form to
the same function.

The problem is, 8 out of 10 times, the string gets passed successfully
and compiled without any problem, but the 2 times, the string gets
manipulated in a random manner.

For example, in this case, the filter was passed as

ip[12:4]>=0x0000 and ip[12:4] <=0xd9295a3 and ip[16:4] >=0x0000 and
ip[16:4] <=0x3ca9b416 and tcp[0:2]>=0 and tcp[0:2]<=23923 and
tcp[2:2]>=0 and tcp[2:2]<=64582 tcp[2:2]<=655355

which of course resulted in pcap_compile raising a syntax error.
Here is a part of the output for 10 threads:

ip[12:4]>=0x0000 and ip[12:4] <=0x4e82b543 and ip[16:4] >=0x0000 and
ip[16:4] <=0x6f835b87 and tcp[0:2]>=0 and tcp[0:2]<=13052 and
tcp[2:2]>=0 and tcp[2:2]<=14069n
Couldn't parse filter ip[12:4]>=0x0000 and ip[12:4] <=0x4e82b543 and
ip[16:4] >=0x0000 and ip[16:4] <=0x6f835b87 and tcp[0:2]>=0 and
tcp[0:2]<=13052 and tcp[2:2]>=0 and tcp[2:2]<=14069n: syntax error
*************** ***
PASSED WITHOUT ERROR
ip[12:4]>=0x4e82b544 and ip[12:4] <=0xffffffff and ip[16:4]
>=0x6f835b88 and ip[16:4] <=0xffffffff and tcp[0:2]>=13053 and
tcp[0:2]<=65535 and tcp[2:2]>=14070 and tcp[2:2]<=65535
*************** ***
ip[12:4]>=0x0000 and ip[12:4] <=0xa7997e38 and ip[16:4] >=0x0000 and
ip[16:4] <=0x7b404ab4 and udp[0:2]>=0 and udp[0:2]<=31630 and
udp[2:2]>=0 and udp[2:2]<=27845 tcp[2:2]<=65535
Couldn't parse filter ip[12:4]>=0x0000 and ip[12:4] <=0xa7997e38 and
ip[16:4] >=0x0000 and ip[16:4] <=0x7b404ab4 and udp[0:2]>=0 and
udp[0:2]<=31630 and udp[2:2]>=0 and udp[2:2]<=27845 tcp[2:2]<=65535:
syntax error
*************** ***
PASSED WITHOUT ERROR
ip[12:4]>=0xa7997e39 and ip[12:4] <=0xffffffff and ip[16:4]
>=0x7b404ab5 and ip[16:4] <=0xffffffff and udp[0:2]>=31631 and
udp[0:2]<=65535 and udp[2:2]>=27846 and udp[2:2]<=65535
*************** ***
ip[12:4]>=0x0000 and ip[12:4] <=0x48fee779 and ip[16:4] >=0x0000 and
ip[16:4] <=0xcbdf7c5 and tcp[0:2]>=0 and tcp[0:2]<=24066 and
tcp[2:2]>=0 and tcp[2:2]<=56142d udp[2:2]<=65535
Couldn't parse filter ip[12:4]>=0x0000 and ip[12:4] <=0x48fee779 and
ip[16:4] >=0x0000 and ip[16:4] <=0xcbdf7c5 and tcp[0:2]>=0 and
tcp[0:2]<=24066 and tcp[2:2]>=0 and tcp[2:2]<=56142d udp[2:2]<=65535:
syntax error
*************** ***
PASSED WITHOUT ERROR
ip[12:4]>=0x48fee77a and ip[12:4] <=0xffffffff and ip[16:4]
>=0xcbdf7c6 and ip[16:4] <=0xffffffff and tcp[0:2]>=24067 and
tcp[0:2]<=65535 and tcp[2:2]>=56143 and tcp[2:2]<=655355
*************** ***
ip[12:4]>=0x0000 and ip[12:4] <=0x1e9e35b and ip[16:4] >=0x0000 and
ip[16:4] <=0x675231ed and tcp[0:2]>=0 and tcp[0:2]<=28481 and
tcp[2:2]>=0 and tcp[2:2]<=50549 tcp[2:2]<=655355
Couldn't parse filter ip[12:4]>=0x0000 and ip[12:4] <=0x1e9e35b and
ip[16:4] >=0x0000 and ip[16:4] <=0x675231ed and tcp[0:2]>=0 and
tcp[0:2]<=28481 and tcp[2:2]>=0 and tcp[2:2]<=50549 tcp[2:2]<=655355:
syntax error
*************** ***

As is evident, the error is pretty random, and mostly toward the end
of the filter with the occasional "and"s missing..

Can anyone please confirm that this is indeed a problem with gcc...?
or are there any particular measures I need to take when passing a
long string?

Thanks,
Shashank
Dec 27 '07 #1
2 1906
On Dec 26, 4:58 pm, Shashank <shashank.shanb ...@gmail.comwr ote:
- snip -
Can anyone please confirm that this is indeed a problem with gcc...?
or are there any particular measures I need to take when passing a
long string?
As the other friendly poster said, you haven't provided any evidence
of an issue with GCC.

You have two most likely causes for your issue:

1) Memory corruption in your code or a library you are using.
2) Improper (or lack there of) locking of memory/resources being
accessed/modified from multiple threads in your code or a library you
are using.

Happy bug hunting.

Ivan Novick
http://www.0x4849.net
Dec 27 '07 #2
On Dec 26, 9:15 pm, Ivan Novick <i...@0x4849.ne twrote:
On Dec 26, 4:58 pm, Shashank <shashank.shanb ...@gmail.comwr ote:
- snip -
Can anyone please confirm that this is indeed a problem with gcc...?
or are there any particular measures I need to take when passing a
long string?
THanks a ton! Problem solved..! :)
Appreciate the help..
>
As the other friendly poster said, you haven't provided any evidence
of an issue with GCC.

You have two most likely causes for your issue:

1) Memory corruption in your code or a library you are using.
2) Improper (or lack there of) locking of memory/resources being
accessed/modified from multiple threads in your code or a library you
are using.

Happy bug hunting.

Ivan Novickhttp://www.0x4849.net
Dec 27 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2715
by: Shaun Fleming | last post by:
I've been trying to make this simple script compatible across various browsers. It works for IE 6.0 and NS 7 but doesnt work with Opera (I have version 7.11). This is what is supposed to happen: when the user clicks a button in the main window, a dialog window pops up. In the dialog the user enters a university to search for. When the string is submitted, the dialog then shows all the matches found in the database. The user picks one and...
6
6539
by: lenny | last post by:
Hi, I've been trying to use a Sub or Function in VBA to connect to a database, make a query and return the recordset that results from the query. The connection to the database and the query works fine, but passing the resulting recordset back to the sub's caller is not working out.
2
1564
by: collinm | last post by:
hi i got some error with parameter my searchFile function: char *tmp; int size; ....
1
8465
by: Craig | last post by:
I have added a 'Textboxes (A)' to my UI installer project along with a custom action to pass the value back to a class I've written to override the void Install function. As long as the text is very simple everything is working just fine. I've tested it by writing the string out to a text file to test it. However, the trouble comes in when I use the textbox for what I really intended, a ADO.Net Connection String. The textbox is to...
8
10707
by: intrepid_dw | last post by:
Hello, all. I've created a C# dll that contains, among other things, two functions dealing with byte arrays. The first is a function that returns a byte array, and the other is intended to receive a byte array as one of its parameters. The project is marked for COM interop, and that all proceeds normally. When I reference the type library in the VB6 project, and write the code to call the function that returns the byte array, it works
15
2417
by: Peter Afonin | last post by:
Hello, I'm struggling with the string conversion to MD5 which I've never user before. I have a string that I need to encode which looks approximately like this: "pva:0.05:101214:pa7735tH:inv_desc=205308:shp_Email=petera_gudzon.net:lang =ru:shp_PaymentNo=20040825205308:shp_UserID=pva:shp_Price=2.95:shp_HostPlan= BU:shp_Term=2"
5
8612
by: Sakharam Phapale | last post by:
Hi All, I am using an API function, which takes file path as an input. When file path contains special characters (@,#,$,%,&,^, etc), API function gives an error as "Unable to open input file". Same file path containing special characters works fine in one machine, but doesn't work in other. I am using following API function to get short file path. Declare Auto Function GetShortPathName Lib "kernel32" (ByVal lpszLongPath As
26
2317
by: the.tarquin | last post by:
Okay, this one has me totally baffled. I have a function, getParsedKey(char* key, char* returnString). I pass in the key I want, it retrieves it from a data structure and puts the value in returnString. The problem is that returnString points to the correct value in the function, but after the function has finished, the string that it points to is empty. ..... char* radioList = NULL; ini->getParsedKey("Radio",radioList);
17
2319
by: Ashwin | last post by:
hi guys, i have overloaded the << operator.as shown below. ostream& operator<<(ostream &out, const student &a) { out<<a.idno; out<< " " ; // out<< a.name; out<< " " ; // out<< a.marks << endl;
0
8445
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8871
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7386
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.