Red HatThis forum is for the discussion of Red Hat Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I tried in gdb also but not able to find the problem
(gdb) run
Starting program: /ws/anaganes-sjc/junk
warning: no loadable sections found in added symbol-file system-supplied DSO at 0x2aaaaaaab000
Program received signal SIGSEGV, Segmentation fault.
0x0000003c44c7fb30 in wcslen () from /lib64/libc.so.6
(gdb) bt
#0 0x0000003c44c7fb30 in wcslen () from /lib64/libc.so.6
#1 0x0000003c44c80b27 in wcsrtombs () from /lib64/libc.so.6
#2 0x0000003c44c464b2 in vfprintf () from /lib64/libc.so.6
#3 0x0000000000400649 in writeformat (stream=0x601010, format=0x400758 "/modules.php?name=Top&querylang=%20WHERE%201=2%20ALL%20SELECT%201,pwd,1,1%20FROM%20nuke_authors/*") at junk.c:20
#4 0x0000000000400556 in main () at junk.c:9
(gdb)
Could you please help me to solve this issue. I am not sure whether the problem is in the string passing.It is working for other string,even if the other string is more length than that above string.
Last edited by Ananda Bbau; 07-14-2015 at 08:47 AM.
Reason: Missed to mention clearly
When you compile it for gdb, did you use the -ggdb flag?
In running GDB, you should get a backtrace once you reach a segmentation fault, by using "bt". (Sorry, just noticing that you DID use the bt command Looks like the file lines don't match up what you labeled them as in your attempt to put it on the screen though...)
It also says that the problem occurs at main.c:9 which is your fclose() statement, so perhaps put a breakpoint in there and determine if fp is NULL or invalid at that point. Maybe in your case, the file did not open due to permissions. Check that fp is non-NULL when you perform the fopen() call.
In that file stream (fp), whatever the strings in format that only will write file stream(fp). If you see the code, i am passing the line "/modules.php?name=Top&querylang=20WHERE201=2%20ALL%20SELECT%201,pwd,1,1%20FROM%20nuke_authors/*" in format. From the format it will write the stream into fp.
But in compilation, you have got, "/modules.php?name=Top&querylang=20WHERE%201=2-0X1.5BE55B76CEFF4P-138LL " in file1.txt.
In that file stream (fp), whatever the strings in format that only will write file stream(fp). If you see the code, i am passing the line "/modules.php?name=Top&querylang=20WHERE201=2%20ALL%20SELECT%201,pwd,1,1%20FROM%20nuke_authors/*" in format. From the format it will write the stream into fp.
But in compilation, you have got, "/modules.php?name=Top&querylang=20WHERE%201=2-0X1.5BE55B76CEFF4P-138LL " in file1.txt.
Thanks for your reply.
Thanks,
G.Ananda Babu.
Firstly, quite right. How about you start with a less complicated print string by the way just to validate that you don't get errors.
What I can say is that this is how I do something like this to create log files, a'la use of a macro statement:
% is a keyword for the format string and for example %20n would require an argument. You need to protect your % chars if you do not need that (that would be the doubled %)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.