Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/archival/libarchive/get_header_ar.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/archival/libarchive/get_header_ar.c
r3232 r3621 9 9 #include "ar.h" 10 10 11 static unsigned read_num(const char *str, int base) 11 /* WARNING: Clobbers str[len], so fields must be read in reverse order! */ 12 static unsigned read_num(char *str, int base, int len) 12 13 { 14 int err; 15 16 /* ar fields are fixed length text strings (padded with spaces). 17 * Ensure bb_strtou doesn't read past the field in case the full 18 * width is used. */ 19 str[len] = 0; 20 13 21 /* This code works because 14 22 * on misformatted numbers bb_strtou returns all-ones */ 15 interr = bb_strtou(str, NULL, base);23 err = bb_strtou(str, NULL, base); 16 24 if (err == -1) 17 25 bb_error_msg_and_die("invalid ar header"); … … 52 60 bb_error_msg_and_die("invalid ar header"); 53 61 54 /* FIXME: more thorough routine would be in order here 55 * (we have something like that in tar) 56 * but for now we are lax. */ 57 ar.formatted.magic[0] = '\0'; /* else 4G-2 file will have size="4294967294`\n..." */ 58 typed->size = size = read_num(ar.formatted.size, 10); 62 /* 63 * Note that the fields MUST be read in reverse order as 64 * read_num() clobbers the next byte after the field! 65 * Order is: name, date, uid, gid, mode, size, magic. 66 */ 67 typed->size = size = read_num(ar.formatted.size, 10, 68 sizeof(ar.formatted.size)); 59 69 60 70 /* special filenames have '/' as the first character */ … … 88 98 * after dealing with long filename pseudo file. 89 99 */ 90 typed->mode = read_num(ar.formatted.mode, 8 );91 typed-> mtime = read_num(ar.formatted.date, 10);92 typed->uid = read_num(ar.formatted.uid, 10 );93 typed-> gid = read_num(ar.formatted.gid, 10);100 typed->mode = read_num(ar.formatted.mode, 8, sizeof(ar.formatted.mode)); 101 typed->gid = read_num(ar.formatted.gid, 10, sizeof(ar.formatted.gid)); 102 typed->uid = read_num(ar.formatted.uid, 10, sizeof(ar.formatted.uid)); 103 typed->mtime = read_num(ar.formatted.date, 10, sizeof(ar.formatted.date)); 94 104 95 105 #if ENABLE_FEATURE_AR_LONG_FILENAMES … … 99 109 /* The number after the '/' indicates the offset in the ar data section 100 110 * (saved in ar_long_names) that conatains the real filename */ 101 long_offset = read_num(&ar.formatted.name[1], 10); 111 long_offset = read_num(&ar.formatted.name[1], 10, 112 sizeof(ar.formatted.name) - 1); 102 113 if (long_offset >= ar_long_name_size) { 103 114 bb_error_msg_and_die("can't resolve long filename");
Note:
See TracChangeset
for help on using the changeset viewer.