You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.4 KiB

  1. From 15bf44fd2c1ad0e3fd87048b3fcc90c4dcff1175 Mon Sep 17 00:00:00 2001
  2. From: Daniel Axtens <dja@axtens.net>
  3. Date: Tue, 4 Dec 2018 14:29:42 +1100
  4. Subject: [PATCH] Skip 0-length ACL fields
  5. Currently, it is possible to create an archive that crashes bsdtar
  6. with a malformed ACL:
  7. Program received signal SIGSEGV, Segmentation fault.
  8. archive_acl_from_text_l (acl=<optimised out>, text=0x7e2e92 "", want_type=<optimised out>, sc=<optimised out>) at libarchive/archive_acl.c:1726
  9. 1726 switch (*s) {
  10. (gdb) p n
  11. $1 = 1
  12. (gdb) p field[n]
  13. $2 = {start = 0x0, end = 0x0}
  14. Stop this by checking that the length is not zero before beginning
  15. the switch statement.
  16. I am pretty sure this is the bug mentioned in the qsym paper [1],
  17. and I was able to replicate it with a qsym + AFL + afl-rb setup.
  18. [1] https://www.usenix.org/conference/usenixsecurity18/presentation/yun
  19. ---
  20. libarchive/archive_acl.c | 5 +++++
  21. 1 file changed, 5 insertions(+)
  22. diff --git a/libarchive/archive_acl.c b/libarchive/archive_acl.c
  23. index 512beee1f..7beeee86e 100644
  24. --- a/libarchive/archive_acl.c
  25. +++ b/libarchive/archive_acl.c
  26. @@ -1723,6 +1723,11 @@ archive_acl_from_text_l(struct archive_acl *acl, const char *text,
  27. st = field[n].start + 1;
  28. len = field[n].end - field[n].start;
  29. + if (len == 0) {
  30. + ret = ARCHIVE_WARN;
  31. + continue;
  32. + }
  33. +
  34. switch (*s) {
  35. case 'u':
  36. if (len == 1 || (len == 4