New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conflicting declarations of print_header to cause stack underflow #39

Closed
sebastic opened this Issue Jun 6, 2014 · 1 comment

Comments

Projects
None yet
2 participants
@sebastic
Contributor

sebastic commented Jun 6, 2014

print_header() is defined differently multiple times.

Would it make sense to add the prototype to lascommon.h?

Or at least consistently use the same prototype, e.g.:

--- a/apps/las2las-old.c
+++ b/apps/las2las-old.c
@@ -30,7 +30,7 @@
 LASPointSummary* SummarizePoints(LASReaderH reader);
 void print_point_summary(FILE *file, LASPointSummary* summary, LASHeaderH header);
 void print_point(FILE *file, LASPointH point);
-void print_header(FILE *file, LASHeaderH header, const char* file_name, int bSkipVLR);
+void print_header(FILE *file, LASHeaderH header, const char* file_name, int bSkipVLR, int bWKT);
 void repair_header(FILE *file, LASHeaderH header, LASPointSummary* summary) ;

 #define LAS_FORMAT_10 0
--- a/apps/las2txt.c
+++ b/apps/las2txt.c
@@ -18,7 +18,7 @@

 #include "liblas.h"

-void print_header(FILE *file, LASHeaderH header, const char* file_name);
+void print_header(FILE *file, LASHeaderH header, const char* file_name, int bSkipVLR, int bWKT);

 void usage()
 {
--- a/apps/lasmerge.c
+++ b/apps/lasmerge.c
@@ -22,7 +22,7 @@

 LASPointSummary* SummarizePoints(LASReaderH reader);
 void print_point_summary(FILE *file, LASPointSummary* summary, LASHeaderH header);
-void print_header(FILE *file, LASHeaderH header, const char* file_name, int bSkipVLR);
+void print_header(FILE *file, LASHeaderH header, const char* file_name, int bSkipVLR, int bWKT);

 void usage()
 {

As reported in Debian Bug #749403 by Michael Tautschnig:

During a rebuild of all packages in a clean sid chroot (and cowbuilder+pbuilder)
the build failed with the following error. Please note that we use our research
compiler tool-chain (using tools from the cbmc package), which permits extended
reporting on type inconsistencies at link time.

[...]
/usr/bin/cc  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2    -Wl,-z,relro CMakeFiles/las2txt-old.dir/lascommon.c.o CMakeFiles/las2txt-old.dir/las2txt.c.o  -o ../bin/None/las2txt-old -rdynamic ../bin/None/liblas_c.so.2.2.0 ../bin/None/liblas.so.2.2.0 -ltiff -lgeotiff -lgdal -lboost_program_options -lboost_thread -lboost_system -lpthread -Wl,-rpath,/srv/jenkins-slave/workspace/sid-goto-cc-liblas/liblas-1.7.0+dfsg/obj-x86_64-linux-gnu/bin/None: 

error: conflicting function declarations "print_header"
old definition in module lascommon file /srv/jenkins-slave/workspace/sid-goto-cc-liblas/liblas-1.7.0+dfsg/apps/lascommon.c line 407
void (struct _IO_FILE *file, struct LASHeaderHS *header, const char *file_name, signed int bSkipVLR, signed int bWKT)
new definition in module las2txt file /srv/jenkins-slave/workspace/sid-goto-cc-liblas/liblas-1.7.0+dfsg/apps/las2txt.c line 21
void (struct _IO_FILE *, struct LASHeaderHS *, const char *)
apps/CMakeFiles/las2txt-old.dir/build.make:122: recipe for target 'bin/None/las2txt-old' failed
make[4]: *** [bin/None/las2txt-old] Error 64

Indeed there is some variety to be found here. The implementation requires 5
arguments, all of which are actually used (the last ones to make branch
decisions, which will entirely undefined in the following setting):

http://sources.debian.net/src/liblas/1.7.0+dfsg-5/apps/lascommon.c?hl=407#L407

Then there's the 3-argument version here:

http://sources.debian.net/src/liblas/1.7.0+dfsg-5/apps/las2txt.c?hl=21#L21

And a 4-argument version here:

http://sources.debian.net/src/liblas/1.7.0+dfsg-5/apps/lasmerge.c?hl=25#L25

Function calls for all versions exist, so some good amount of undefined
behaviour to be observed.

Best,
Michael

hobu added a commit that referenced this issue Jun 7, 2014

Merge pull request #40 from libLAS/remove-lastools-utilities
remove old LAStools utilities that don't belong in liblas #39
@hobu

This comment has been minimized.

Show comment
Hide comment
@hobu

hobu Jun 10, 2014

Member

This is now fixed in master by removing the old LAStools versions of these utilities, which were in disrepair anyway.

Member

hobu commented Jun 10, 2014

This is now fixed in master by removing the old LAStools versions of these utilities, which were in disrepair anyway.

@hobu hobu closed this Jun 10, 2014

mloskot added a commit that referenced this issue Feb 17, 2017

Cleanup old utilities leftovers
Related to issues #39 and #55
Closes #113
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment