Solved

C-compiling problem

Posted on 2000-03-06
9
218 Views
Last Modified: 2010-04-02
I'm trying to compile this:
http://packetstorm.securify.com/0003-exploits/sXe.c
(no i'm not a bad as... just trying to check out my own network)
And get this:

sXe.c:63: initializer element is not constant


row 64 looks like this:
FILE * stream  = stderr;

How can i fix that....
0
Comment
Question by:pucko
9 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 2588970
This is only a warning. However, changing the line to read

FILE * stream  = ( const FILE*) stderr;

should do it...
0
 
LVL 1

Author Comment

by:pucko
ID: 2589355
It's not only a warning because I dont get any file to run when i do a gcc file.c -o file

And the changes you said just give me a warning. I still have the error I had before...

Now I get:
sXe.c:63: warning: initialization discards qualifiers from pointer target type
sXe.c:63: initializer element is not constant
0
 
LVL 3

Expert Comment

by:msmits
ID: 2589484
I can compile the code without any errors with gcc 2.7.2.1 on FreeBSD. There seems to be something wrong with your header files.
Can you tell which OS and which version of gcc you are using?
0
 
LVL 1

Author Comment

by:pucko
ID: 2589499
I'm using gcc 2.95 (tried gcc 2.7.2.3 but it did not work either
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:pucko
ID: 2589502
and the header files is from glibc2.1
0
 

Expert Comment

by:042
ID: 2601276
You should look for the declaration/assignement of "stderr" in your header files and post it here, it could help...

For now you can try this:

remove the assignement in the declaration,
replace FILE * stream = stderr;
with FILE * stream;

and move the assignement to the begining of the main

int main (int argc, char * * argv)
{
  FILE * fptr;
  u_int pos = 0;
  u_char type = 0;
  u_char code = 0;
  u_long victim = ERR;
  u_char * ptr = *argv;
  u_char * fname = NULL;

  stream = stderr; /* line to add */

  ++argv; --argc;

0
 
LVL 1

Author Comment

by:pucko
ID: 2601610
That gives me:

[root:/home/pucko/download]$ gcc sXe -o sxe
sXe: In function `_init':
sXe(.init+0x0): multiple definition of `_init'
/usr/lib/crti.o(.init+0x0): first defined here
sXe: In function `_start':
sXe(.text+0x0): multiple definition of `_start'
/usr/lib/crt1.o(.text+0x0): first defined here
sXe: In function `_fini':
sXe(.fini+0x0): multiple definition of `_fini'
/usr/lib/crti.o(.fini+0x0): first defined here
sXe(*ABS*+0x804a3a0): multiple definition of `_GLOBAL_OFFSET_TABLE_'
/usr/lib/crti.o(.got.plt+0x0): first defined here
sXe: In function `__data_start':
sXe(.data+0x0): multiple definition of `__data_start'
/usr/lib/crt1.o(.data+0x0): first defined here
/usr/lib/crti.o(.dynamic+0x0): multiple definition of `_DYNAMIC'
collect2: ld returned 1 exit status

I don't know which header file to post.
stdio.h ?
Shall I post the whole file here?
(its 631 lines)      

Or is this enough?

/* Standard streams.  */
extern FILE *stdin;            /* Standard input stream.  */
extern FILE *stdout;            /* Standard output stream.  */
extern FILE *stderr;            /* Standard error output stream.  */
/* C89/C99 say they're macros.  Make them happy.  */
#define stdin stdin
#define stdout stdout
#define stderr st
0
 

Accepted Solution

by:
042 earned 50 total points
ID: 2611659
Well no need to post any header now,
because it works (yes it does)...
well compilation works ;)
"ld returned 1 exit status"
ld is the linker.

You can check that way:
1) compile: gcc -c sXe
this should generate an sXe.o and everything should be ok (for now).
If this is the case compilation worked.
2) link: gcc sXe.o -o sxe
You should now get the multiple definition error messages.
(or maybe the link will work that way)

Now I'm not sure what's going on, please try this and let me know if i'm right for now.


0
 
LVL 1

Author Comment

by:pucko
ID: 2613448
hmmm it works now... thnks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now