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

gbox_to_string: Address snprintf warning #165

Closed
wants to merge 1 commit into from

Conversation

Algunenano
Copy link
Member

GCC 7.2 warning in gbox_to_string:

g_box.c: In function 'gbox_to_string'
g_box.c:421:21: warning: '))' directive output may be truncated writing 2 bytes into a region of size between 0 and 105 [-Wformat-truncation=]
   snprintf(str, sz, "GBOX((%.8g,%.8g,%.8g,%.8g),(%.8g,%.8g,%.8g,%.8g))", gbox->xmin, gbox->ymin, gbox->zmin, gbox->mmin, gbox->xmax, gbox->ymax, gbox->zmax, gbox->mmax);
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:862:0,
                 from liblwgeom_internal.h:40,
                 from g_box.c:29:
/usr/include/bits/stdio2.h:64:10: note: '__builtin___snprintf_chk' output between 26 and 138 bytes into a destination of size 128
   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        __bos (__s), __fmt, __va_arg_pack ());
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The destination buffer was set too small to handle the max size of the string.

@Algunenano
Copy link
Member Author

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

@pramsey
Copy link
Member

pramsey commented Oct 17, 2017

committed

@pramsey pramsey closed this Oct 17, 2017
@Algunenano Algunenano deleted the gbox_warning branch November 15, 2019 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants