mhulden / foma

Automatically exported from code.google.com/p/foma

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Warn users if name is > 40 characters

dowobeha opened this issue · comments

Current behavior is to segfault when save defined is performed if any defined has a name > 40 characters in length.

I was able to track down the cause using gdb:

Program received signal SIGABRT, Aborted.
0x00007ffff75e2438 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 0x00007ffff75e2438 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1 0x00007ffff75e403a in __GI_abort () at abort.c:89
#2 0x00007ffff76247fa in __libc_message (do_abort=do_abort@entry=2, fmt=fmt@entry=0x7ffff773c55f "*** %s ***: %s terminated\n") at ../sysdeps/posix/libc_fatal.c:175
#3 0x00007ffff76c621c in __GI___fortify_fail (msg=<optimized out>, msg@entry=0x7ffff773c4f0 "buffer overflow detected") at fortify_fail.c:37
#4 0x00007ffff76c4220 in __GI___chk_fail () at chk_fail.c:28
#5 0x00007ffff76c3572 in __strcpy_chk (dest=0x2501b80 "", src=0x2501b30 "ForeignGuessIntermediateToSurfaceGrammar", destlen=40) at strcpy_chk.c:30
#6 0x0000000000421221 in save_defined ()
#7 0x0000000000409d74 in interfacelex ()
#8 0x0000000000401b86 in main ()

The segfault happens here (during strcpy), apparently because the char buffer is hardcoded to be 40 characters in length.

At a minimum, foma should give the user a human-readable error message that explains the failure and how to fix it (use a shorter name).

@dowobeha This issue is fixed in #96