Advertisement
Outlasted

Untitled

Jun 29th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. long written;
  2. decompress_fn decompress;
  3. const char *compress_name;
  4. static __initdata char msg_buf[64];
  5.  
  6. header_buf = kmalloc(110, GFP_KERNEL);
  7. symlink_buf = kmalloc(PATH_MAX + N_ALIGN(PATH_MAX) + 1, GFP_KERNEL);
  8. name_buf = kmalloc(N_ALIGN(PATH_MAX), GFP_KERNEL);
  9.  
  10. if (!header_buf || !symlink_buf || !name_buf)
  11. panic("can't allocate buffers");
  12.  
  13. state = Start;
  14. this_header = 0;
  15. message = NULL;
  16. while (!message && len) {
  17. loff_t saved_offset = this_header;
  18. if (*buf == '0' && !(this_header & 3)) {
  19. state = Start;
  20. written = write_buffer(buf, len);
  21. buf += written;
  22. len -= written;
  23. continue;
  24. }
  25. if (!*buf) {
  26. buf++;
  27. len--;
  28. this_header++;
  29. continue;
  30. }
  31. this_header = 0;
  32. decompress = decompress_method(buf, len, &compress_name);
  33. pr_debug("Detected %s compressed data\n", compress_name);
  34. if (decompress) {
  35. int res = decompress(buf, len, NULL, flush_buffer, NULL,
  36. &my_inptr, error);
  37. if (res)
  38. error("decompressor failed");
  39. } else if (compress_name) {
  40. if (!message) {
  41. snprintf(msg_buf, sizeof msg_buf,
  42. "compression method %s not configured",
  43. compress_name);
  44. message = msg_buf;
  45. }
  46. } else
  47. error("junk in compressed archive");
  48. if (state != Reset)
  49. error("junk in compressed archive");
  50. this_header = saved_offset + my_inptr;
  51. buf += my_inptr;
  52. len -= my_inptr;
  53. }
  54. dir_utime();
  55. kfree(name_buf);
  56. kfree(symlink_buf);
  57. kfree(header_buf);
  58. return message;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement