S
Stuart Anderson
I am looking to use Ken Stephenson's CirclePack program
(http://www.math.utk.edu/~kens/) with some tiling programs written by
Cannon, Floyd, Parry. The programs I want to use are subdivide.c
tilepack.c squarect.c . They are available from
http://www.math.vt.edu/people/floyd/research/software/subdiv.html.
I tried compiling them on my Redhat 9 box, eg cc subdivide.c. When I do
so I get errors like "In function `Readtilingforvertex':
: the `gets' function is dangerous and should not be used."
I checked the FAQ and is says gets() is BAD and I should use fgets()
instead. I found an example of a code fragment to use, eg
'This is the sort of code you've got:
{
char buf[512];
gets( buf );
/* ... more code ... */
}
which will cause a buffer overrun if more than 512 characters are placed
in the buffer and randomly overwrite other memory. This can cause a
number of hard-to-trace bugs and is just a dangerous idiom.
This is also the source of the the vulnerabilities in BIND and a huge
number of other programs--by feeding the buffer the right sequence, you
can actually get it execute code buried in the buffer---though I don't
think people will use CCP4 to break into UNIX boxes.
The code to replace it is really simple:
{
char buf[512];
fgets( buf, sizeof(buf), stdin );
/* ... more code ... */
}
The header file needed for the prototypes of both functions is still
stdio.h'
So not being a c programmer I just replaced all instances of gets() with
with the above. Now I am getting different errors.
[stuart@localhost cpack]$ cc subdivide.c
subdivide.c: In function `Readrules':
subdivide.c:160: parse error before "sizeof"
subdivide.c:160: conflicting types for `stdin'
/usr/include/stdio.h:142: previous declaration of `stdin'
subdivide.c:160: parse error before ')' token
subdivide.c:167: warning: passing arg 3 of `fgets' makes pointer from integer without a cast
subdivide.c: In function `Readtiling':
subdivide.c:311: parse error before "sizeof"
subdivide.c:311: conflicting types for `stdin'
/usr/include/stdio.h:142: previous declaration of `stdin'
subdivide.c:311: parse error before ')' token
subdivide.c:318: warning: passing arg 3 of `fgets' makes pointer from integer without a cast
subdivide.c: In function `Readtypetiling':
subdivide.c:461: parse error before "sizeof"
subdivide.c:461: conflicting types for `stdin'
/usr/include/stdio.h:142: previous declaration of `stdin'
subdivide.c:461: parse error before ')' token
subdivide.c: In function `Readbdytiling':
subdivide.c:596: parse error before "sizeof"
subdivide.c:596: conflicting types for `stdin'
/usr/include/stdio.h:142: previous declaration of `stdin'
subdivide.c:596: parse error before ')' token
subdivide.c: In function `Subdivide':
subdivide.c:719: parse error before "sizeof"
subdivide.c:719: conflicting types for `stdin'
/usr/include/stdio.h:142: previous declaration of `stdin'
subdivide.c:719: parse error before ')' token
subdivide.c: In function `Writetilingtofile':
subdivide.c:972: parse error before "sizeof"
subdivide.c:972: conflicting types for `stdin'
/usr/include/stdio.h:142: previous declaration of `stdin'
subdivide.c:972: parse error before ')' token
subdivide.c:979: warning: passing arg 3 of `fgets' makes pointer from integer without a cast
Any ideas?
thanks ,
Stuart
(http://www.math.utk.edu/~kens/) with some tiling programs written by
Cannon, Floyd, Parry. The programs I want to use are subdivide.c
tilepack.c squarect.c . They are available from
http://www.math.vt.edu/people/floyd/research/software/subdiv.html.
I tried compiling them on my Redhat 9 box, eg cc subdivide.c. When I do
so I get errors like "In function `Readtilingforvertex':
: the `gets' function is dangerous and should not be used."
I checked the FAQ and is says gets() is BAD and I should use fgets()
instead. I found an example of a code fragment to use, eg
'This is the sort of code you've got:
{
char buf[512];
gets( buf );
/* ... more code ... */
}
which will cause a buffer overrun if more than 512 characters are placed
in the buffer and randomly overwrite other memory. This can cause a
number of hard-to-trace bugs and is just a dangerous idiom.
This is also the source of the the vulnerabilities in BIND and a huge
number of other programs--by feeding the buffer the right sequence, you
can actually get it execute code buried in the buffer---though I don't
think people will use CCP4 to break into UNIX boxes.
The code to replace it is really simple:
{
char buf[512];
fgets( buf, sizeof(buf), stdin );
/* ... more code ... */
}
The header file needed for the prototypes of both functions is still
stdio.h'
So not being a c programmer I just replaced all instances of gets() with
with the above. Now I am getting different errors.
[stuart@localhost cpack]$ cc subdivide.c
subdivide.c: In function `Readrules':
subdivide.c:160: parse error before "sizeof"
subdivide.c:160: conflicting types for `stdin'
/usr/include/stdio.h:142: previous declaration of `stdin'
subdivide.c:160: parse error before ')' token
subdivide.c:167: warning: passing arg 3 of `fgets' makes pointer from integer without a cast
subdivide.c: In function `Readtiling':
subdivide.c:311: parse error before "sizeof"
subdivide.c:311: conflicting types for `stdin'
/usr/include/stdio.h:142: previous declaration of `stdin'
subdivide.c:311: parse error before ')' token
subdivide.c:318: warning: passing arg 3 of `fgets' makes pointer from integer without a cast
subdivide.c: In function `Readtypetiling':
subdivide.c:461: parse error before "sizeof"
subdivide.c:461: conflicting types for `stdin'
/usr/include/stdio.h:142: previous declaration of `stdin'
subdivide.c:461: parse error before ')' token
subdivide.c: In function `Readbdytiling':
subdivide.c:596: parse error before "sizeof"
subdivide.c:596: conflicting types for `stdin'
/usr/include/stdio.h:142: previous declaration of `stdin'
subdivide.c:596: parse error before ')' token
subdivide.c: In function `Subdivide':
subdivide.c:719: parse error before "sizeof"
subdivide.c:719: conflicting types for `stdin'
/usr/include/stdio.h:142: previous declaration of `stdin'
subdivide.c:719: parse error before ')' token
subdivide.c: In function `Writetilingtofile':
subdivide.c:972: parse error before "sizeof"
subdivide.c:972: conflicting types for `stdin'
/usr/include/stdio.h:142: previous declaration of `stdin'
subdivide.c:972: parse error before ')' token
subdivide.c:979: warning: passing arg 3 of `fgets' makes pointer from integer without a cast
Any ideas?
thanks ,
Stuart