473,388 Members | 1,286 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

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 1878
On Dec 26, 4:58 pm, Shashank <shashank.shanb...@gmail.comwrote:
- 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.netwrote:
On Dec 26, 4:58 pm, Shashank <shashank.shanb...@gmail.comwrote:
- 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
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:...
6
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...
2
by: collinm | last post by:
hi i got some error with parameter my searchFile function: char *tmp; int size; ....
1
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...
8
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...
15
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: ...
5
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"....
26
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...
17
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.