TL;DR: load global variables into local ones before use.
I've spotted a quite widespread misuse of global pointer variables. The issue is easily demonstrated by the following simplified example.
struct some_type_t {
int a1;
int a2;| // | |
| // copyright (c) 2014 by 1801BM1@gmail.com | |
| //______________________________________________________________________________ | |
| // | |
| `timescale 1ns / 1ns | |
| module vm80a | |
| ( | |
| input pin_clk, // global module clock (no in original 8080) | |
| input pin_f1, // clock phase 1 (used as clock enable) |
| //-------------------------------------- | |
| //--- 010 Editor v6.0 Binary Template | |
| // | |
| // File: ff4save.bt | |
| // Author: DJ | |
| // Revision: 1 | |
| // Purpose: Parse FF4 save slot. | |
| //-------------------------------------- | |
| local int doSteam = -1; |
| /* | |
| * D-LINK products formware image unpacker tool. | |
| * Written by dev_zzo for personal research. | |
| * Use at your own risk. | |
| */ | |
| #include <stdio.h> | |
| #include <stdint.h> | |
| #include <endian.h> | |
| #include <malloc.h> |
| # | |
| # BUGS: | |
| # | |
| # * Data is not handled at all. | |
| # | |
| # * Imports which are either IMPORT_NAME_NOPREFIX or IMPORT_NAME_UNDECORATE | |
| # should be properly restored -- make a huge map?.. | |
| # | |
| import idaapi |
| MS16-005 (CVE-2016-0009) Win32k Remote Code Execution Vulnerability info | |
| just look at PFTOBJ::bUnloadAllButPermanentFonts |
| #include <stdio.h> | |
| #include <malloc.h> | |
| #include <math.h> | |
| #include <stdlib.h> | |
| // | |
| // Generic N-layer neuron network code (using unipolar sigmoid activation function) | |
| // | |
| // Data type to operate on; typically double. |
| """ | |
| GitHub API v3 Wrapper | |
| Ref: https://developer.github.com/v3/git/ | |
| """ | |
| import base64 | |
| import json | |
| import requests |
| #include <stdio.h> | |
| #include <malloc.h> | |
| struct _perceptron_t { | |
| size_t weights_count; | |
| float thfunc_param; | |
| float weights[1]; | |
| }; | |
| typedef struct _perceptron_t perceptron_t; |
| void matrix_multiply(const data_t *M, const data_t *x, data_t *y, size_t width, size_t height) | |
| { | |
| // assert(height > 0); | |
| // assert(width >= 4); | |
| // assert((width & 3) == 0); | |
| IACA_START; | |
| #if 1 | |
| if (height >= 4) { |