error_t tcpAddOption(TcpHeader *segment, uint8_t kind, const void *value,
   uint8_t length)
{
   uint_t i;
   size_t paddingSize;
   TcpOption *option;

   //Length of the complete option field
   length += sizeof(TcpOption);

   //Make sure there is enough space to add the specified option
   if((segment->dataOffset * 4 + length) > TCP_MAX_HEADER_LENGTH)
      return ERROR_FAILURE;

   //Index of the first available byte
   i = segment->dataOffset * 4 - sizeof(TcpHeader);

   //Calculate the number of padding bytes
   paddingSize = (length % 4) ? 4 - (length % 4) : 0;
   //Write padding bytes
   while(paddingSize--)
      segment->options[i++] = TCP_OPTION_NOP;

   //Point to the current location
   option = (TcpOption *) (segment->options + i);
   //Write specified option
   option->kind = kind;
   option->length = length;
   osMemcpy(option->value, value, length - sizeof(TcpOption));
   //Adjust index value
   i += length;

   //Update TCP header length
   segment->dataOffset = (sizeof(TcpHeader) + i) / 4;

   //Option successfully added
   return NO_ERROR;
}
The product receives input or data, but it does
        not validate or incorrectly validates that the input has the
        properties that are required to process the data safely and
        correctly.