unarj-2.65-CAN-2004-0947.patch 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. Index: unarj-2.65/unarj.c
  2. ===================================================================
  3. --- unarj-2.65.orig/unarj.c
  4. +++ unarj-2.65/unarj.c
  5. @@ -217,7 +217,7 @@ static uchar arj_flags;
  6. static short method;
  7. static uint file_mode;
  8. static ulong time_stamp;
  9. -static short entry_pos;
  10. +static ushort entry_pos;
  11. static ushort host_data;
  12. static uchar *get_ptr;
  13. static UCRC file_crc;
  14. @@ -608,6 +608,7 @@ char *name;
  15. error(M_BADHEADR, "");
  16. crc = CRC_MASK;
  17. + memset(header, 0, sizeof(header));
  18. fread_crc(header, (int) headersize, fd);
  19. header_crc = fget_crc(fd);
  20. if ((crc ^ CRC_MASK) != header_crc)
  21. @@ -632,9 +633,13 @@ char *name;
  22. if (origsize < 0 || compsize < 0)
  23. error(M_HEADRCRC, "");
  24. + if(first_hdr_size > headersize-2) /* need two \0 for file and comment */
  25. + error(M_BADHEADR, "");
  26. hdr_filename = (char *)&header[first_hdr_size];
  27. strncopy(filename, hdr_filename, sizeof(filename));
  28. + if(entry_pos >= strlen(filename))
  29. + error(M_BADHEADR, "");
  30. if (host_os != OS)
  31. strparity((uchar *)filename);
  32. if ((arj_flags & PATHSYM_FLAG) != 0)
  33. @@ -733,11 +738,11 @@ extract()
  34. no_output = 0;
  35. if (command == 'E')
  36. - strcpy(name, &filename[entry_pos]);
  37. + strncopy(name, &filename[entry_pos], sizeof(name));
  38. else
  39. {
  40. strcpy(name, DEFAULT_DIR);
  41. - strcat(name, filename);
  42. + strncopy(name+strlen(name), filename, sizeof(name)-strlen(name));
  43. }
  44. if (host_os != OS)