aboutsummaryrefslogtreecommitdiff
path: root/src/main/extractor_ipc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/extractor_ipc.c')
-rw-r--r--src/main/extractor_ipc.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/main/extractor_ipc.c b/src/main/extractor_ipc.c
index eb21993..4c8a14d 100644
--- a/src/main/extractor_ipc.c
+++ b/src/main/extractor_ipc.c
@@ -46,8 +46,8 @@ EXTRACTOR_IPC_process_reply_ (struct EXTRACTOR_PluginList *plugin,
46{ 46{
47 const char *cdata = data; 47 const char *cdata = data;
48 unsigned char code; 48 unsigned char code;
49 int64_t seek_position; 49 struct SeekRequestMessage seek;
50 struct IpcHeader hdr; 50 struct MetaMessage meta;
51 const char *mime_type; 51 const char *mime_type;
52 const char *value; 52 const char *value;
53 53
@@ -60,49 +60,51 @@ EXTRACTOR_IPC_process_reply_ (struct EXTRACTOR_PluginList *plugin,
60 plugin->seek_request = -1; 60 plugin->seek_request = -1;
61 plugin->round_finished = 1; 61 plugin->round_finished = 1;
62 return 1; 62 return 1;
63 case MESSAGE_SEEK: /* Seek */ 63 case MESSAGE_SEEK: /* Seek */
64 if (size < 1 + sizeof (int64_t)) 64 if (size < sizeof (struct SeekRequestMessage))
65 { 65 {
66 plugin->seek_request = -1; 66 plugin->seek_request = -1;
67 return 0; 67 return 0;
68 } 68 }
69 memcpy (&seek_position, &cdata[1], sizeof (int64_t)); 69 memcpy (&seek, cdata, sizeof (seek));
70 plugin->seek_request = seek_position; 70 plugin->seek_request = seek.file_offset;
71 return 1 + sizeof (int64_t); 71 return sizeof (struct SeekRequestMessage);
72 case MESSAGE_META: /* Meta */ 72 case MESSAGE_META: /* Meta */
73 if (size < 1 + sizeof (hdr) ) 73 if (size < sizeof (struct MetaMessage))
74 { 74 {
75 plugin->seek_request = -1; 75 plugin->seek_request = -1;
76 return 0; 76 return 0;
77 } 77 }
78 memcpy (&hdr, &cdata[1], sizeof (hdr)); 78 memcpy (&meta, cdata, sizeof (meta));
79 /* check hdr for sanity */ 79 /* check hdr for sanity */
80 if (hdr.data_len > MAX_META_DATA) 80 if (meta.value_size > MAX_META_DATA)
81 return -1; /* not allowing more than MAX_META_DATA meta data */ 81 return -1; /* not allowing more than MAX_META_DATA meta data */
82 if (size < 1 + sizeof (hdr) + hdr.mime_len + hdr.data_len) 82 if (size < sizeof (meta) + meta.mime_length + meta.value_size)
83 { 83 {
84 plugin->seek_request = -1; 84 plugin->seek_request = -1;
85 return 0; 85 return 0;
86 } 86 }
87 if (0 == hdr.mime_len) 87 if (0 == meta.mime_length)
88 { 88 {
89 mime_type = NULL; 89 mime_type = NULL;
90 } 90 }
91 else 91 else
92 { 92 {
93 mime_type = &cdata[1 + sizeof (hdr)]; 93 mime_type = &cdata[sizeof (struct MetaMessage)];
94 if ('\0' != mime_type[hdr.mime_len-1]) 94 if ('\0' != mime_type[meta.mime_length - 1])
95 return -1; 95 return -1;
96 } 96 }
97 if (0 == hdr.data_len) 97 if (0 == meta.value_size)
98 value = NULL; 98 value = NULL;
99 else 99 else
100 value = &cdata[1 + sizeof (hdr) + hdr.mime_len]; 100 value = &cdata[sizeof (struct MetaMessage) + meta.mime_length];
101 proc (proc_cls, 101 proc (proc_cls,
102 plugin, 102 plugin,
103 &hdr, 103 (enum EXTRACTOR_MetaType) meta.meta_type,
104 (enum EXTRACTOR_MetaFormat) meta.meta_format,
105 meta.value_size,
104 mime_type, value); 106 mime_type, value);
105 return 1 + sizeof (hdr) + hdr.mime_len + hdr.data_len; 107 return sizeof (struct MetaMessage) + meta.mime_length + meta.value_size;
106 default: 108 default:
107 return -1; 109 return -1;
108 } 110 }