id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc 5114,pgsql2shp segfault with long or many truncated columns,dfuhry2,pramsey,"I experienced this in a real-world query, but a short reproducible test case of pgsql2shp segfault is below. I think the problem may be state->message overflowing with messages about the truncated columns. As a workaround, raising SHPLOADERMSGLEN from 1024 to 8192 caused pgsql2shp to complete successfully. But I assume some bounds checking is needed to prevent the overflow from occurring in the first place. This is against 2.5.3. Sorry to report against an old version, but I did not find a bug report for this against any newer version either. {{{ gdb --args ./pgsql2shp -p 5434 -f test.shp dfuhry 'SELECT 1 AS abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk, 2 AS bcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl, 3 AS cdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklm, 4 AS defghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmn, 5 as efghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmno, 6 AS fghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnop, 7 AS ghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopq, 8 AS hijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqr, 9 AS ijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrs, 10 AS jklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrst' ... (gdb) r ... Initializing... *** buffer overflow detected ***: terminated Program received signal SIGABRT, Aborted. __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory. (gdb) bt #0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 #1 0x00007ffff7d74537 in __GI_abort () at abort.c:79 #2 0x00007ffff7dcd768 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff7edbc24 ""*** %s ***: terminated\n"") at ../sysdeps/posix/libc_fatal.c:155 #3 0x00007ffff7e5c652 in __GI___fortify_fail (msg=msg@entry=0x7ffff7edbbba ""buffer overflow detected"") at fortify_fail.c:26 #4 0x00007ffff7e5b050 in __GI___chk_fail () at chk_fail.c:28 #5 0x00007ffff7e5a999 in __strncat_chk (s1=, s1@entry=0x55555559b068 ""Warning, field abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk renamed to ABCDEFGHIJ\nWarning, field bcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl renamed to BCDEFGHIJ""..., s2=, s2@entry=0x7fffffffdd00 ""No geometry column found.\nThe DBF file will be created but not the shx or shp files.\n"", n=, s1len=, s1len@entry=1024) at strncat_chk.c:33 #6 0x0000555555562c11 in strncat (__len=, __src=0x7fffffffdd00 ""No geometry column found.\nThe DBF file will be created but not the shx or shp files.\n"", __dest=0x55555559b068 ""Warning, field abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk renamed to ABCDEFGHIJ\nWarning, field bcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl renamed to BCDEFGHIJ""...) at /usr/include/x86_64-linux-gnu/bits/string_fortified.h:136 #7 ShpDumperOpenTable (state=state@entry=0x55555559afb0) at pgsql2shp-core.c:1837 #8 0x000055555555774f in main (argc=, argv=) at pgsql2shp-cli.c:191 }}}",defect,closed,medium,PostGIS 3.2.2,postgis,2.3.x,fixed,,