1
This commit is contained in:
parent
09f55254d5
commit
a6560ba1a0
@ -1,8 +1,10 @@
|
|||||||
#include "precompile.h"
|
#include "precompile.h"
|
||||||
|
|
||||||
#include <google/protobuf/message.h>
|
#include <google/protobuf/message.h>
|
||||||
|
#include <google/protobuf/descriptor.pb.h>
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
#include "cs_proto.pb.h"
|
||||||
|
|
||||||
time_t Global::BetweenDays(time_t time1, time_t time2)
|
time_t Global::BetweenDays(time_t time1, time_t time2)
|
||||||
{
|
{
|
||||||
@ -28,17 +30,24 @@ bool CustomParser(f8::MsgHdr& hdr, google::protobuf::Message* msg)
|
|||||||
switch (field_desc->cpp_type()) {
|
switch (field_desc->cpp_type()) {
|
||||||
case google::protobuf::FieldDescriptor::CPPTYPE_STRING:
|
case google::protobuf::FieldDescriptor::CPPTYPE_STRING:
|
||||||
{
|
{
|
||||||
if ((size_t)hdr.offset >= (size_t)hdr.buflen) {
|
int fixed_len = field_desc->options().GetExtension(cs::fixed_len);
|
||||||
abort();
|
if (field_desc->type() == google::protobuf::FieldDescriptor::TYPE_BYTES && fixed_len > 0) {
|
||||||
|
if ((size_t)hdr.offset + fixed_len > (size_t)hdr.buflen) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ((size_t)hdr.offset > (size_t)hdr.buflen) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
std::string val(&hdr.buf[hdr.offset]);
|
||||||
|
reflection->SetString(msg, field_desc, val);
|
||||||
|
hdr.offset += val.size() + 1;
|
||||||
}
|
}
|
||||||
std::string val(&hdr.buf[hdr.offset]);
|
|
||||||
reflection->SetString(msg, field_desc, val);
|
|
||||||
hdr.offset += val.size() + 1;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case google::protobuf::FieldDescriptor::CPPTYPE_INT32:
|
case google::protobuf::FieldDescriptor::CPPTYPE_INT32:
|
||||||
{
|
{
|
||||||
if (hdr.offset + sizeof(int) < (size_t)hdr.buflen) {
|
if (hdr.offset + sizeof(int) > (size_t)hdr.buflen) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
int* p_val = (int*)&hdr.buf[hdr.offset];
|
int* p_val = (int*)&hdr.buf[hdr.offset];
|
||||||
@ -48,7 +57,7 @@ bool CustomParser(f8::MsgHdr& hdr, google::protobuf::Message* msg)
|
|||||||
break;
|
break;
|
||||||
case google::protobuf::FieldDescriptor::CPPTYPE_UINT32:
|
case google::protobuf::FieldDescriptor::CPPTYPE_UINT32:
|
||||||
{
|
{
|
||||||
if (hdr.offset + sizeof(unsigned int) < (size_t)hdr.buflen) {
|
if (hdr.offset + sizeof(unsigned int) > (size_t)hdr.buflen) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
unsigned int* p_val = (unsigned int*)&hdr.buf[hdr.offset];
|
unsigned int* p_val = (unsigned int*)&hdr.buf[hdr.offset];
|
||||||
@ -58,7 +67,7 @@ bool CustomParser(f8::MsgHdr& hdr, google::protobuf::Message* msg)
|
|||||||
break;
|
break;
|
||||||
case google::protobuf::FieldDescriptor::CPPTYPE_INT64:
|
case google::protobuf::FieldDescriptor::CPPTYPE_INT64:
|
||||||
{
|
{
|
||||||
if (hdr.offset + sizeof(long long) < (size_t)hdr.buflen) {
|
if (hdr.offset + sizeof(long long) > (size_t)hdr.buflen) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
long long* p_val = (long long*)&hdr.buf[hdr.offset];
|
long long* p_val = (long long*)&hdr.buf[hdr.offset];
|
||||||
@ -68,7 +77,7 @@ bool CustomParser(f8::MsgHdr& hdr, google::protobuf::Message* msg)
|
|||||||
break;
|
break;
|
||||||
case google::protobuf::FieldDescriptor::CPPTYPE_UINT64:
|
case google::protobuf::FieldDescriptor::CPPTYPE_UINT64:
|
||||||
{
|
{
|
||||||
if (hdr.offset + sizeof(unsigned long long) < (size_t)hdr.buflen) {
|
if (hdr.offset + sizeof(unsigned long long) > (size_t)hdr.buflen) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
unsigned long long* p_val = (unsigned long long*)&hdr.buf[hdr.offset];
|
unsigned long long* p_val = (unsigned long long*)&hdr.buf[hdr.offset];
|
||||||
@ -78,7 +87,7 @@ bool CustomParser(f8::MsgHdr& hdr, google::protobuf::Message* msg)
|
|||||||
break;
|
break;
|
||||||
case google::protobuf::FieldDescriptor::CPPTYPE_FLOAT:
|
case google::protobuf::FieldDescriptor::CPPTYPE_FLOAT:
|
||||||
{
|
{
|
||||||
if (hdr.offset + sizeof(float) < (size_t)hdr.buflen) {
|
if (hdr.offset + sizeof(float) > (size_t)hdr.buflen) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
float* p_val = (float*)&hdr.buf[hdr.offset];
|
float* p_val = (float*)&hdr.buf[hdr.offset];
|
||||||
@ -88,7 +97,7 @@ bool CustomParser(f8::MsgHdr& hdr, google::protobuf::Message* msg)
|
|||||||
break;
|
break;
|
||||||
case google::protobuf::FieldDescriptor::CPPTYPE_DOUBLE:
|
case google::protobuf::FieldDescriptor::CPPTYPE_DOUBLE:
|
||||||
{
|
{
|
||||||
if (hdr.offset + sizeof(double) < (size_t)hdr.buflen) {
|
if (hdr.offset + sizeof(double) > (size_t)hdr.buflen) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
double* p_val = (double*)&hdr.buf[hdr.offset];
|
double* p_val = (double*)&hdr.buf[hdr.offset];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user