static gpointer process_get_versioninfo_block (gpointer data,
version_data *block)
{
- block->data_len=*(((guint16 *)data)++);
- block->value_len=*(((guint16 *)data)++);
+ block->data_len=*((guint16 *)data);
+ data = (char *)data + sizeof(guint16);
+ block->value_len=*((guint16 *)data);
+ data = (char *)data + sizeof(guint16);
/* No idea what the type is supposed to indicate */
- block->type=*(((guint16 *)data)++);
+ block->type=*((guint16 *)data);
+ data = (char *)data + sizeof(guint16);
block->key=((gunichar2 *)data);
/* skip over the key (including the terminator) */
return(data_ptr);
}
-/* Returns a pointer to the byte following the String block */
+/* Returns a pointer to the byte following the String block, or NULL
+ * if the data read hits padding. We can't recover from this because
+ * the data length does not include padding bytes, so it's not
+ * possible to just return the start position + length.
+ */
static gpointer process_read_string_block (MonoObject *filever,
gpointer data_ptr,
guint16 data_len,
data_ptr=(gpointer)(((unsigned)data_ptr+3) & (~3));
data_ptr=process_get_versioninfo_block (data_ptr, &block);
+ if(block.data_len==0) {
+ /* We must have hit padding, so give up
+ * processing now
+ */
+#ifdef DEBUG
+ g_message (G_GNUC_PRETTY_FUNCTION
+ ": Hit 0-length block, giving up");
+#endif
+ return(NULL);
+ }
+
string_len=string_len+block.data_len;
value=(gunichar2 *)data_ptr;
/* Skip over the value */
return(data_ptr);
}
-/* returns a pointer to the byte following the Stringtable block */
+/* returns a pointer to the byte following the Stringtable block, or
+ * NULL if the data read hits padding. We can't recover from this
+ * because the data length does not include padding bytes, so it's not
+ * possible to just return the start position + length
+ */
static gpointer process_read_stringtable_block (MonoObject *filever,
gpointer data_ptr,
guint16 data_len)
data_ptr=(gpointer)(((unsigned)data_ptr+3) & (~3));
data_ptr=process_get_versioninfo_block (data_ptr, &block);
+ if(block.data_len==0) {
+ /* We must have hit padding, so give up
+ * processing now
+ */
+#ifdef DEBUG
+ g_message (G_GNUC_PRETTY_FUNCTION
+ ": Hit 0-length block, giving up");
+#endif
+ return(NULL);
+ }
string_len=string_len+block.data_len;
if(!memcmp (block.key, &uni_key, unicode_bytes (block.key)) ||
block.data_len,
FALSE);
}
+
+ if(data_ptr==NULL) {
+ /* Child block hit padding */
+#ifdef DEBUG
+ g_message (G_GNUC_PRETTY_FUNCTION ": Child block hit 0-length block, giving up");
+#endif
+ return(NULL);
+ }
}
return(data_ptr);
return;
}
- ffi=(((VS_FIXEDFILEINFO *)data_ptr)++);
+ ffi=((VS_FIXEDFILEINFO *)data_ptr);
+ data_ptr = (char *)data_ptr + sizeof(VS_FIXEDFILEINFO);
if((ffi->dwSignature!=VS_FFI_SIGNATURE) ||
(ffi->dwStrucVersion!=VS_FFI_STRUCVERSION)) {
#ifdef DEBUG
data_ptr=(gpointer)(((unsigned)data_ptr+3) & (~3));
data_ptr=process_get_versioninfo_block (data_ptr, &block);
+ if(block.data_len==0) {
+ /* We must have hit padding, so give up
+ * processing now
+ */
+#ifdef DEBUG
+ g_message (G_GNUC_PRETTY_FUNCTION
+ ": Hit 0-length block, giving up");
+#endif
+ return;
+ }
+
data_len=data_len-block.data_len;
if(!memcmp (block.key, &var_key, unicode_bytes (block.key))) {
return;
#endif
}
+
+ if(data_ptr==NULL) {
+ /* Child block hit padding */
+#ifdef DEBUG
+ g_message (G_GNUC_PRETTY_FUNCTION ": Child block hit 0-length block, giving up");
+#endif
+ return;
+ }
}
}
ret=CreateProcess (NULL, mono_string_chars (cmd), NULL, NULL, TRUE, CREATE_UNICODE_ENVIRONMENT, NULL, dir, &startinfo, &procinfo);
- if(ret==TRUE) {
+ if(ret) {
process_info->process_handle=procinfo.hProcess;
process_info->thread_handle=procinfo.hThread;
process_info->pid=procinfo.dwProcessId;