noodle: Use a sane temp buf for streaming

This commit is contained in:
Matthew Barr 2017-05-30 16:12:41 +10:00
parent bf3ced92f4
commit 4be7d6fecc
4 changed files with 7 additions and 10 deletions

View File

@ -228,8 +228,7 @@ hwlm_error_t hwlmExecStreaming(const struct HWLM *t, struct hs_scratch *scratch,
cb, ctxt); cb, ctxt);
} else { } else {
return noodExecStreaming(HWLM_C_DATA(t), hbuf, hlen, buf, len, cb, return noodExecStreaming(HWLM_C_DATA(t), hbuf, hlen, buf, len, cb,
ctxt, scratch->fdr_temp_buf, ctxt);
FDR_TEMP_BUF_SIZE);
} }
} else { } else {
// t->type == HWLM_ENGINE_FDR // t->type == HWLM_ENGINE_FDR

View File

@ -370,8 +370,7 @@ hwlm_error_t noodExec(const struct noodTable *n, const u8 *buf, size_t len,
/** \brief Streaming-mode scanner. */ /** \brief Streaming-mode scanner. */
hwlm_error_t noodExecStreaming(const struct noodTable *n, const u8 *hbuf, hwlm_error_t noodExecStreaming(const struct noodTable *n, const u8 *hbuf,
size_t hlen, const u8 *buf, size_t len, size_t hlen, const u8 *buf, size_t len,
HWLMCallback cb, void *ctxt, u8 *temp_buf, HWLMCallback cb, void *ctxt) {
UNUSED size_t temp_buffer_size) {
assert(n); assert(n);
struct cb_info cbi = {cb, n->id, ctxt, 0}; struct cb_info cbi = {cb, n->id, ctxt, 0};
@ -380,10 +379,12 @@ hwlm_error_t noodExecStreaming(const struct noodTable *n, const u8 *hbuf,
if (hlen) { if (hlen) {
assert(hbuf); assert(hbuf);
u8 ALIGN_DIRECTIVE temp_buf[16]; // HWLM_LITERAL_MAX_LEN * 2
size_t tl1 = MIN(n->len - 1, hlen); size_t tl1 = MIN(n->len - 1, hlen);
size_t tl2 = MIN(n->len - 1, len); size_t tl2 = MIN(n->len - 1, len);
size_t temp_len = tl1 + tl2; size_t temp_len = tl1 + tl2;
assert(temp_len < temp_buffer_size); assert(temp_len < sizeof(temp_buf));
memcpy(temp_buf, hbuf + hlen - tl1, tl1); memcpy(temp_buf, hbuf + hlen - tl1, tl1);
memcpy(temp_buf + tl1, buf, tl2); memcpy(temp_buf + tl1, buf, tl2);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Intel Corporation * Copyright (c) 2015-2017, Intel Corporation
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
@ -49,8 +49,7 @@ hwlm_error_t noodExec(const struct noodTable *n, const u8 *buf, size_t len,
/** \brief Streaming-mode scanner. */ /** \brief Streaming-mode scanner. */
hwlm_error_t noodExecStreaming(const struct noodTable *n, const u8 *hbuf, hwlm_error_t noodExecStreaming(const struct noodTable *n, const u8 *hbuf,
size_t hlen, const u8 *buf, size_t len, size_t hlen, const u8 *buf, size_t len,
HWLMCallback cb, void *ctxt, u8 *temp_buf, HWLMCallback cb, void *ctxt);
size_t temp_buffer_size);
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */

View File

@ -45,7 +45,6 @@ extern "C"
#endif #endif
UNUSED static const u32 SCRATCH_MAGIC = 0x544F4259; UNUSED static const u32 SCRATCH_MAGIC = 0x544F4259;
#define FDR_TEMP_BUF_SIZE 222
struct fatbit; struct fatbit;
struct hs_scratch; struct hs_scratch;
@ -201,7 +200,6 @@ struct ALIGN_CL_DIRECTIVE hs_scratch {
u32 delay_fatbit_size; /**< size of each delay fatbit in bytes */ u32 delay_fatbit_size; /**< size of each delay fatbit in bytes */
u32 scratchSize; u32 scratchSize;
char *scratch_alloc; /* user allocated scratch object */ char *scratch_alloc; /* user allocated scratch object */
u8 ALIGN_DIRECTIVE fdr_temp_buf[FDR_TEMP_BUF_SIZE];
}; };
/* array of fatbit ptr; TODO: why not an array of fatbits? */ /* array of fatbit ptr; TODO: why not an array of fatbits? */