Skip to content
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

Fix undefined behaviour in SADFWrite #310

Closed
wants to merge 2 commits into from

Conversation

@Algunenano
Copy link
Member

commented Sep 28, 2018

  • Addresses warning under gcc 8.2.1.
  • Fixes undefined behaviour in SADFWrite

Trac issue: https://trac.osgeo.org/postgis/ticket/4189

@Algunenano Algunenano force-pushed the Algunenano:undefined_loader branch 2 times, most recently from 8fe710f to 27b82bb Sep 28, 2018

Algunenano added 2 commits Sep 28, 2018
Address gcc warnings
lwutil.c: In function ‘lwmessage_truncate’
lwutil.c:285:5: warning: ‘strncat’ specified bound 3 equals source length [-Wstringop-overflow=]
     strncat(output, "...", 3);
     ^~~~~~~~~~~~~~~~~~~~~~~~~
lwutil.c:291:5: warning: ‘strncat’ specified bound 3 equals source length [-Wstringop-overflow=]
     strncat(output, "...", 3);
     ^~~~~~~~~~~~~~~~~~~~~~~~~
lwutil.c:312:5: warning: ‘strncat’ specified bound 3 equals source length [-Wstringop-overflow=]
     strncat(output, "...", 3);
     ^~~~~~~~~~~~~~~~~~~~~~~~~
lwutil.c:317:5: warning: ‘strncat’ specified bound 3 equals source length [-Wstringop-overflow=]
     strncat(output, "...", 3);
     ^~~~~~~~~~~~~~~~~~~~~~~~~

pgsql2shp-core.c: In function ‘ShpDumperOpenTable’:
pgsql2shp-core.c:1552:37: error: ‘sprintf’ may write a terminating nul past the end of the destination [-Werror=format-overflow=]
     sprintf(dbffieldname, %.7s_%.2d, ptr, tmpint % 100);
                                     ^
pgsql2shp-core.c:1552:5: note: ‘sprintf’ output between 4 and 12 bytes into a destination of size 11
     sprintf(dbffieldname, %.7s_%.2d, ptr, tmpint % 100);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Address undefined behaviour in loader
Running using gcc '-fsanitize=undefined -fsanitize-undefined-trap-on-error':

Using host libthread_db library "/usr/lib/libthread_db.so.1".
Core was generated by /un/dev_public/postgis/loader/.libs/lt-pgsql2shp -f /tmp/pgis_reg/dumper postgi.
Program terminated with signal SIGILL, Illegal instruction.
(gdb) bt

@Algunenano Algunenano force-pushed the Algunenano:undefined_loader branch from 27b82bb to cd5b32c Oct 1, 2018

@strk strk closed this in 2182c81 Oct 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.