Parsing a fixed-size message using variable length array in C My C program has to parse a fixed-length message like this:
uint8_t message[8] = {80, 75, 73, 71, 1, 1, 1, 1};

another message could be:
uint8_t message[8] = {80, 75, 73, 71, 41, 42, 1, 1};

The message contains an ASCII string and 1 shows the end of string. So the actual length of the first message is 4 and the second message is 6.
I use this method to extract the message:
1. Counting the message length
2. Initializing a variable length array with this value.
3. Using memcpy to copy the bytes.

decoder.h
#ifndef DECODER_H_INCLUDED
#define DECODER_H_INCLUDED


#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;stdint.h&gt;
#include &lt;string.h&gt;

#define LENGTH 100
void parse(uint8_t * message);
void get_address(char * addr, int size);
uint8_t get_size(void);

#endif // DECODER_H_INCLUDED

decoder.c
#include &quot;decoder.h&quot;


// Global variables in library
uint8_t parsed_message[LENGTH];
uint8_t len = 0;

void parse(uint8_t * message)
{
len = 0;
for (int i = 0; i &lt; LENGTH; i++)
    {
        if (message[i] != 1)
        {
            parsed_message[i] = message[i];
            len++;
        }
        else
        {
            parsed_message[i] = '\0';
            len++;
            break;
        }

    }
}

void get_address(char * addr, int size)
{
    memcpy(addr, parsed_message, size);
}


uint8_t get_size(void)
{
    return len;
}

In the main function:
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &quot;decoder.h&quot;

int main(void) {

    uint8_t input[8] = {80, 75, 73, 71, 1, 1, 1, 1};
    parse(input);

    char addr[get_size()];
    get_address(addr, get_size());
    printf(&quot;==== %s ==== ADDRESS\n&quot;, addr);

    return 0;
}

I use GCC compiler and C99 standard in ARM-Based 32-bit micro-controller.
My question is that is this method safe? Or I should use another approach.
Overall Observations
The int main(void) function is correctly declared since no arguments are expected.
The code definitely follows the Single Responsibility Principle and this is good!
The use of portable include guards is good.
The program would be more flexible if it accepted the message as input from either the console or a file (would require an alternate declaration for main()).
Use System Defined Constants
The main() function could be made more readable if the system defined constants EXIT_SUCCESS and EXIT_FAILURE were used (only EXIT_SUCCESS in this case). These constants are included in the stdlib.h header file which is already included in the code.
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &quot;decoder.h&quot;

int main(void) {

    uint8_t input[8] = { 80, 75, 73, 71, 1, 1, 1, 1 };
    parse(input);

    char addr[get_size()];
    get_address(addr, get_size());
    printf(&quot;==== %s ==== ADDRESS\n&quot;, addr);

    return EXIT_SUCCESS;
}

Avoid Global Variables
It is very difficult to read, write, debug and maintain programs that use global variables. Global variables can be modified by any function within the program and therefore require each function to be examined before making changes in the code. In C global variables impact the namespace and they can cause linking errors if they are defined in multiple files. The answers in this stackoverflow question provide a fuller explanation.
In C it is possible to have a variable that is global to a file, but does not impact the entire program by using the static keyword.
static uint8_t parsed_message[LENGTH];
static uint8_t len = 0;

In the current implementation this compiles properly.
If you are really going to use global variables throughout the program they should be declared as extern variables in the header file.
#ifndef DECODER_H_INCLUDED
#define DECODER_H_INCLUDED

#include &lt;stdint.h&gt;

#define LENGTH 100
extern uint8_t parsed_message[LENGTH];
extern uint8_t len;

void parse(uint8_t* message);
void get_address(char* addr, int size);
uint8_t get_size(void);

#endif // DECODER_H_INCLUDED

Header Files
Only include header files that are absolutely necessary to make the code compile in header files, it is better to include the necessary header files in the C source file. This makes the code clearer in the source file. In decoder.h the only necessary header file is stdint.h. This could affect compile time and cause link errors if include guards are missing. In most implementations of C a temporary source file is generated by the C pre-processor and all header files are copied into the temporary file.
Variable Types
It isn't clear from reviewing the program why the code is using uint8_t rather than unsigned char. The overall result would be the same and less header files would be necessary.