@@ -74,6 +74,25 @@ ObjectContainerBSDArchive::Object::Extract (const DataExtractor& data, lldb::off
74
74
size_t ar_name_len = 0 ;
75
75
std::string str;
76
76
char *err;
77
+
78
+
79
+ // File header
80
+ //
81
+ // The common format is as follows.
82
+ //
83
+ // Offset Length Name Format
84
+ // 0 16 File name ASCII right padded with spaces (no spaces allowed in file name)
85
+ // 16 12 File mod Decimal as cstring right padded with spaces
86
+ // 28 6 Owner ID Decimal as cstring right padded with spaces
87
+ // 34 6 Group ID Decimal as cstring right padded with spaces
88
+ // 40 8 File mode Octal as cstring right padded with spaces
89
+ // 48 10 File byte size Decimal as cstring right padded with spaces
90
+ // 58 2 File magic 0x60 0x0A
91
+
92
+ // Make sure there is enough data for the file header and bail if not
93
+ if (!data.ValidOffsetForDataOfSize (offset, 60 ))
94
+ return LLDB_INVALID_OFFSET;
95
+
77
96
str.assign ((const char *)data.GetData (&offset, 16 ), 16 );
78
97
if (str.find (" #1/" ) == 0 )
79
98
{
@@ -110,7 +129,11 @@ ObjectContainerBSDArchive::Object::Extract (const DataExtractor& data, lldb::off
110
129
{
111
130
if (ar_name_len > 0 )
112
131
{
113
- str.assign ((const char *)data.GetData (&offset, ar_name_len), ar_name_len);
132
+ const void *ar_name_ptr = data.GetData (&offset, ar_name_len);
133
+ // Make sure there was enough data for the string value and bail if not
134
+ if (ar_name_ptr == NULL )
135
+ return LLDB_INVALID_OFFSET;
136
+ str.assign ((const char *)ar_name_ptr, ar_name_len);
114
137
ar_name.SetCString (str.c_str ());
115
138
}
116
139
ar_file_offset = offset;
0 commit comments