t/pmc/packfile.t: Warning about invalid Parrot bytecode file
James E Keenan
jkeen at verizon.net
Thu Aug 5 01:54:44 UTC 2010
James E Keenan wrote:
> ok 4 - bytecode_major set
> PackFile_unpack: This is not a valid Parrot bytecode file
> ok 5 - set_string_native with invalid data throws
> ok 6 - get_string(uuid)
Here's the relevant source code:
src/packfile.c
993 PARROT_EXPORT
994 PARROT_WARN_UNUSED_RESULT
995 opcode_t
996 PackFile_unpack(PARROT_INTERP, ARGMOD(PackFile *self),
997 ARGIN(const opcode_t *packed), size_t packed_size)
998 {
999 ASSERT_ARGS(PackFile_unpack)
1000 PackFile_Header * const header = self->header;
1001 const opcode_t *cursor;
1002 int header_read_length;
1003 opcode_t padding;
1004 #if TRACE_PACKFILE
1005 PackFile * const pf = self;
1006 #endif
1007
1008 if (packed_size < PACKFILE_HEADER_BYTES) {
1009 Parrot_io_eprintf(NULL, "PackFile_unpack: "
1010 "Buffer length %d is shorter than PACKFILE_HEADER_BYTES
%d\n",
1011 packed_size, PACKFILE_HEADER_BYTES);
1012 return 0;
1013 }
1014
1015 self->src = packed;
1016 self->size = packed_size;
1017
1018 /* Extract the header. */
1019 memcpy(header, packed, PACKFILE_HEADER_BYTES);
1020
1021 /* Ensure the magic is correct. */
1022 if (memcmp(header->magic, "\376PBC\r\n\032\n", 8) != 0) {
1023 Parrot_io_eprintf(NULL, "PackFile_unpack: "
1024 "This is not a valid Parrot bytecode file\n");
1025 return 0;
1026 }
More information about the parrot-dev
mailing list