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

Another use of strcpy() on overlapping buffers #402

Closed
krader1961 opened this issue Feb 10, 2018 · 1 comment
Closed

Another use of strcpy() on overlapping buffers #402

krader1961 opened this issue Feb 10, 2018 · 1 comment
Assignees
Labels

Comments

@krader1961
Copy link
Contributor

While working on issue #396 and #401 I looked at a core dump from the cubetype test and noticed that strcpy() was called with pointers to overlapping buffers. From the core dump:

(lldb) frame select 8
frame #8: 0x000000010c32c582 ksh`nv_create(name="cc[0].len", root=0x00007fdcd7f00c30, flags=1441792, dp=0x00007ffee3955d28) at name.c:708
   705      if (!dp->disc) copy = dp->nofree & 1;
   706      if (*cp == '.') cp++;
   707      while (1) {
-> 708          if (zerosub && !np) strcpy(sp, cp - 1);
   709          zerosub = 0;
   710          switch (c = *(unsigned char *)(sp = cp)) {
   711              case '[': {
(lldb) p sp
(char *) $0 = 0x00007fdcd8003668 ".len"
(lldb) p cp
(char *) $1 = 0x00007fdcd8003669 "len"

Notice the address of the source buffer is just the destination buffer plus one. This bug occurs even with AST vmalloc rather than stdlib vmalloc. I simply hadn't bothered to investigate this failure before now.

@krader1961 krader1961 added the bug label Feb 10, 2018
@krader1961 krader1961 self-assigned this Feb 10, 2018
@krader1961
Copy link
Contributor Author

Fixing this bug fixes three unit tests on macOS (the three cubetype test variants).

rijalati pushed a commit to rijalati/ast that referenced this issue Jul 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant