code
stringlengths
12
2.05k
label
int64
0
1
programming_language
stringclasses
9 values
cwe_id
stringlengths
6
14
cwe_name
stringlengths
5
103
description
stringlengths
36
1.23k
url
stringlengths
36
48
label_name
stringclasses
2 values
void SetColor(double c, double m, double y, double k,int par) { if ( par == STROKING ) { sprintf(outputbuffer," %12.3f %12.3f %12.3f %12.3f K",c,m,y,k); } else { sprintf(outputbuffer," %12.3f %12.3f %12.3f %12.3f k",c,m,y,k); } sendClean(outputbuffer); }
1
C++
NVD-CWE-noinfo
null
null
null
safe
TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { TF_LITE_ENSURE_EQ(context, NumInputs(node), 1); TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1); const TfLiteTensor* input = GetInput(context, node, kInputTensor); TfLiteTensor* output = GetOutput(context, node, kOutputTensor); output->type = kTfLiteInt32; // By design, the input shape is always known at the time of Prepare, even // if the preceding op that generates |input| is dynamic. Thus, we can // always compute the rank immediately, without waiting for Eval. SetTensorToPersistentRo(output); // Rank produces a 0-D int32 Tensor representing the rank of input. TfLiteIntArray* output_size = TfLiteIntArrayCreate(0); TF_LITE_ENSURE_STATUS(context->ResizeTensor(context, output, output_size)); TF_LITE_ENSURE_EQ(context, NumDimensions(output), 0); // Immediately propagate the known rank to the output tensor. This allows // downstream ops that rely on the value to use it during prepare. if (output->type == kTfLiteInt32) { int32_t* output_data = GetTensorData<int32_t>(output); *output_data = NumDimensions(input); } else { return kTfLiteError; } return kTfLiteOk; }
0
C++
CWE-125
Out-of-bounds Read
The software reads data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/125.html
vulnerable
TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { const TfLiteTensor* input = GetInput(context, node, kInputTensor); TfLiteTensor* output = GetOutput(context, node, kOutputTensor); const TfLiteTensor* multipliers = GetInput(context, node, kInputMultipliers); if (IsDynamicTensor(output)) { TF_LITE_ENSURE_OK(context, ResizeOutput(context, node)); } switch (output->type) { case kTfLiteFloat32: Tile<float>(*(input->dims), input, multipliers, output); break; case kTfLiteUInt8: Tile<uint8_t>(*(input->dims), input, multipliers, output); break; case kTfLiteInt32: Tile<int32_t>(*(input->dims), input, multipliers, output); break; case kTfLiteInt64: Tile<int64_t>(*(input->dims), input, multipliers, output); break; case kTfLiteString: { DynamicBuffer buffer; TileString(*(input->dims), input, multipliers, &buffer, output); buffer.WriteToTensor(output, /*new_shape=*/nullptr); break; } case kTfLiteBool: Tile<bool>(*(input->dims), input, multipliers, output); break; default: context->ReportError(context, "Type '%s' is not supported by tile.", TfLiteTypeGetName(output->type)); return kTfLiteError; } return kTfLiteOk; }
0
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
vulnerable
void CUser::SetClientEncoding(const CString& s) { m_sClientEncoding = s; for (CClient* pClient : GetAllClients()) { pClient->SetEncoding(s); } }
0
C++
CWE-20
Improper Input Validation
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.
https://cwe.mitre.org/data/definitions/20.html
vulnerable
NO_INLINE JsVar *jspeFactorDelete() { JSP_ASSERT_MATCH(LEX_R_DELETE); JsVar *parent = 0; JsVar *a = jspeFactorMember(jspeFactor(), &parent); JsVar *result = 0; if (JSP_SHOULD_EXECUTE) { bool ok = false; if (jsvIsName(a) && !jsvIsNewChild(a)) { // if no parent, check in root? if (!parent && jsvIsChild(execInfo.root, a)) parent = jsvLockAgain(execInfo.root); if (jsvHasChildren(parent)) { // else remove properly. if (jsvIsArray(parent)) { // For arrays, we must make sure we don't change the length JsVarInt l = jsvGetArrayLength(parent); jsvRemoveChild(parent, a); jsvSetArrayLength(parent, l, false); } else { jsvRemoveChild(parent, a); } ok = true; } } result = jsvNewFromBool(ok); } jsvUnLock2(a, parent); return result; }
0
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
vulnerable
static TfLiteRegistration DelegateRegistration() { TfLiteRegistration reg = {nullptr, nullptr, nullptr, nullptr}; reg.prepare = [](TfLiteContext* context, TfLiteNode* node) { // If tensors are resized, the runtime should propagate shapes // automatically if correct flag is set. Ensure values are correct. // Output 0 should be dynamic. TfLiteTensor* output0; TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &output0)); TF_LITE_ENSURE(context, IsDynamicTensor(output0)); // Output 1 has the same shape as input. const TfLiteTensor* input; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &input)); TfLiteTensor* output1; TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 1, &output1)); TF_LITE_ENSURE(context, input->dims->size == output1->dims->size); TF_LITE_ENSURE(context, input->dims->data[0] == output1->dims->data[0]); return kTfLiteOk; }; return reg; }
1
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
safe
static inline bool isValid(const RemoteFsDevice::Details &d) { return d.isLocalFile() || RemoteFsDevice::constSshfsProtocol==d.url.scheme(); }
1
C++
CWE-20
Improper Input Validation
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.
https://cwe.mitre.org/data/definitions/20.html
safe
bool CSecurityTLS::processMsg(CConnection* cc) { rdr::InStream* is = cc->getInStream(); rdr::OutStream* os = cc->getOutStream(); client = cc; initGlobal(); if (!session) { if (!is->checkNoWait(1)) return false; if (is->readU8() == 0) { rdr::U32 result = is->readU32(); CharArray reason; if (result == secResultFailed || result == secResultTooMany) reason.buf = is->readString(); else reason.buf = strDup("Authentication failure (protocol error)"); throw AuthFailureException(reason.buf); } if (gnutls_init(&session, GNUTLS_CLIENT) != GNUTLS_E_SUCCESS) throw AuthFailureException("gnutls_init failed"); if (gnutls_set_default_priority(session) != GNUTLS_E_SUCCESS) throw AuthFailureException("gnutls_set_default_priority failed"); setParam(); } rdr::TLSInStream *tlsis = new rdr::TLSInStream(is, session); rdr::TLSOutStream *tlsos = new rdr::TLSOutStream(os, session); int err; err = gnutls_handshake(session); if (err != GNUTLS_E_SUCCESS) { delete tlsis; delete tlsos; if (!gnutls_error_is_fatal(err)) return false; vlog.error("TLS Handshake failed: %s\n", gnutls_strerror (err)); shutdown(false); throw AuthFailureException("TLS Handshake failed"); } checkSession(); cc->setStreams(fis = tlsis, fos = tlsos); return true; }
0
C++
CWE-119
Improper Restriction of Operations within the Bounds of a Memory Buffer
The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.
https://cwe.mitre.org/data/definitions/119.html
vulnerable
int bmp_validate(jas_stream_t *in) { int n; int i; uchar buf[2]; assert(JAS_STREAM_MAXPUTBACK >= 2); /* Read the first two characters that constitute the signature. */ if ((n = jas_stream_read(in, (char *) buf, 2)) < 0) { return -1; } /* Put the characters read back onto the stream. */ for (i = n - 1; i >= 0; --i) { if (jas_stream_ungetc(in, buf[i]) == EOF) { return -1; } } /* Did we read enough characters? */ if (n < 2) { return -1; } /* Is the signature correct for the BMP format? */ if (buf[0] == (BMP_MAGIC & 0xff) && buf[1] == (BMP_MAGIC >> 8)) { return 0; } return -1; }
0
C++
CWE-190
Integer Overflow or Wraparound
The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.
https://cwe.mitre.org/data/definitions/190.html
vulnerable
TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { // Check for supported activation types. auto* params = reinterpret_cast<TfLiteFullyConnectedParams*>(node->builtin_data); const TfLiteTensor* filter = GetInput(context, node, kWeightsTensor); const TfLiteTensor* input = GetInput(context, node, kInputTensor); const bool is_quantized = ((filter->type == kTfLiteUInt8) || (filter->type == kTfLiteInt8)); const bool is_hybrid = is_quantized && (input->type == kTfLiteFloat32); const bool is_pie = kernel_type == kLegacyPie; // Pie and hybrid path supports all kinds of fused activations, otherwise only // clipping activations are supported. if (!is_pie && !is_hybrid) { TF_LITE_ENSURE(context, params->activation == kTfLiteActNone || params->activation == kTfLiteActRelu || params->activation == kTfLiteActReluN1To1 || params->activation == kTfLiteActRelu6); } return PrepareImpl(context, node); }
0
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
vulnerable
ByteVector ByteVector::mid(uint index, uint length) const { ByteVector v; if(index > size()) return v; ConstIterator endIt; if(length < 0xffffffff && length + index < size()) endIt = d->data.begin() + index + length; else endIt = d->data.end(); v.d->data.insert(v.d->data.begin(), ConstIterator(d->data.begin() + index), endIt); v.d->size = v.d->data.size(); return v; }
0
C++
CWE-189
Numeric Errors
Weaknesses in this category are related to improper calculation or conversion of numbers.
https://cwe.mitre.org/data/definitions/189.html
vulnerable
static ssize_t _consolefs_write(oe_fd_t* file_, const void* buf, size_t count) { ssize_t ret = -1; file_t* file = _cast_file(file_); if (!file) OE_RAISE_ERRNO(OE_EINVAL); if (oe_syscall_write_ocall(&ret, file->host_fd, buf, count) != OE_OK) OE_RAISE_ERRNO(OE_EINVAL); done: return ret; }
0
C++
NVD-CWE-Other
Other
NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
https://nvd.nist.gov/vuln/categories
vulnerable
void jas_matrix_bindsub(jas_matrix_t *mat0, jas_matrix_t *mat1, int r0, int c0, int r1, int c1) { int i; if (mat0->data_) { if (!(mat0->flags_ & JAS_MATRIX_REF)) { jas_free(mat0->data_); } mat0->data_ = 0; mat0->datasize_ = 0; } if (mat0->rows_) { jas_free(mat0->rows_); mat0->rows_ = 0; } mat0->flags_ |= JAS_MATRIX_REF; mat0->numrows_ = r1 - r0 + 1; mat0->numcols_ = c1 - c0 + 1; mat0->maxrows_ = mat0->numrows_; if (!(mat0->rows_ = jas_alloc2(mat0->maxrows_, sizeof(jas_seqent_t *)))) { /* There is no way to indicate failure to the caller. So, we have no choice but to abort. Ideally, this function should have a non-void return type. In practice, a non-void return type probably would not help much anyways as the caller would just have to terminate anyways. */ abort(); } for (i = 0; i < mat0->numrows_; ++i) { mat0->rows_[i] = mat1->rows_[r0 + i] + c0; } mat0->xstart_ = mat1->xstart_ + c0; mat0->ystart_ = mat1->ystart_ + r0; mat0->xend_ = mat0->xstart_ + mat0->numcols_; mat0->yend_ = mat0->ystart_ + mat0->numrows_; }
0
C++
CWE-190
Integer Overflow or Wraparound
The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.
https://cwe.mitre.org/data/definitions/190.html
vulnerable
bool CModules::ValidateModuleName(const CString& sModule, CString& sRetMsg) { for (unsigned int a = 0; a < sModule.length(); a++) { if (((sModule[a] < '0') || (sModule[a] > '9')) && ((sModule[a] < 'a') || (sModule[a] > 'z')) && ((sModule[a] < 'A') || (sModule[a] > 'Z')) && (sModule[a] != '_')) { sRetMsg = t_f("Module names can only contain letters, numbers and " "underscores, [{1}] is invalid")(sModule); return false; } } return true; }
1
C++
CWE-20
Improper Input Validation
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.
https://cwe.mitre.org/data/definitions/20.html
safe
bool createBLSShare(const string &blsKeyName, const char *s_shares, const char *encryptedKeyHex) { CHECK_STATE(s_shares); CHECK_STATE(encryptedKeyHex); vector<char> errMsg(BUF_LEN,0); int errStatus = 0; uint64_t decKeyLen; SAFE_UINT8_BUF(encr_bls_key,BUF_LEN); SAFE_UINT8_BUF(encr_key,BUF_LEN); if (!hex2carray(encryptedKeyHex, &decKeyLen, encr_key, BUF_LEN)) { throw SGXException(INVALID_HEX, "Invalid encryptedKeyHex"); } uint32_t enc_bls_len = 0; sgx_status_t status = trustedCreateBlsKeyAES(eid, &errStatus, errMsg.data(), s_shares, encr_key, decKeyLen, encr_bls_key, &enc_bls_len); HANDLE_TRUSTED_FUNCTION_ERROR(status, errStatus, errMsg.data()); SAFE_CHAR_BUF(hexBLSKey,2 * BUF_LEN) carray2Hex(encr_bls_key, enc_bls_len, hexBLSKey, 2 * BUF_LEN); SGXWalletServer::writeDataToDB(blsKeyName, hexBLSKey); return true; }
0
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
vulnerable
void *UntrustedCacheMalloc::GetBuffer() { void **buffers = nullptr; void *buffer; bool is_pool_empty; { LockGuard spin_lock(&lock_); is_pool_empty = buffer_pool_.empty(); if (is_pool_empty) { buffers = primitives::AllocateUntrustedBuffers(kPoolIncrement, kPoolEntrySize); for (int i = 0; i < kPoolIncrement; i++) { if (!buffers[i] || !TrustedPrimitives::IsOutsideEnclave(buffers[i], kPoolEntrySize)) { abort(); } buffer_pool_.push(buffers[i]); } } buffer = buffer_pool_.top(); buffer_pool_.pop(); busy_buffers_.insert(buffer); } if (is_pool_empty) { // Free memory held by the array of buffer pointers returned by // AllocateUntrustedBuffers. Free(buffers); } return buffer; }
0
C++
CWE-668
Exposure of Resource to Wrong Sphere
The product exposes a resource to the wrong control sphere, providing unintended actors with inappropriate access to the resource.
https://cwe.mitre.org/data/definitions/668.html
vulnerable
static int emulate_store_desc_ptr(struct x86_emulate_ctxt *ctxt, void (*get)(struct x86_emulate_ctxt *ctxt, struct desc_ptr *ptr)) { struct desc_ptr desc_ptr; if (ctxt->mode == X86EMUL_MODE_PROT64) ctxt->op_bytes = 8; get(ctxt, &desc_ptr); if (ctxt->op_bytes == 2) { ctxt->op_bytes = 4; desc_ptr.address &= 0x00ffffff; } /* Disable writeback. */ ctxt->dst.type = OP_NONE; return segmented_write(ctxt, ctxt->dst.addr.mem, &desc_ptr, 2 + ctxt->op_bytes); }
0
C++
CWE-416
Use After Free
Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.
https://cwe.mitre.org/data/definitions/416.html
vulnerable
static std::vector<std::string> AllDirectoryPrefixes(const std::string& d) { std::vector<std::string> dirs; const std::string patched = PatchPattern(d); StringPiece dir(patched); // If the pattern ends with a `/` (or `\\` on Windows), we need to strip it // otherwise we would have one additional matching step and the result set // would be empty. bool is_directory = d[d.size() - 1] == '/'; #ifdef PLATFORM_WINDOWS is_directory = is_directory || (d[d.size() - 1] == '\\'); #endif if (is_directory) { dir = io::Dirname(dir); } while (!dir.empty()) { dirs.emplace_back(dir); StringPiece new_dir(io::Dirname(dir)); // io::Dirname("/") returns "/" so we need to break the loop. // On Windows, io::Dirname("C:\\") would return "C:\\", so we check for // identity of the result instead of checking for dir[0] == `/`. if (dir == new_dir) break; dir = new_dir; } // Order the array from parent to ancestor (reverse order). std::reverse(dirs.begin(), dirs.end()); return dirs; }
1
C++
CWE-125
Out-of-bounds Read
The software reads data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/125.html
safe
void CalculateOutputIndexValueRowID( OpKernelContext* context, const RowPartitionTensor& value_rowids, const vector<INDEX_TYPE>& parent_output_index, INDEX_TYPE output_index_multiplier, INDEX_TYPE output_size, vector<INDEX_TYPE>* result) { const INDEX_TYPE index_size = value_rowids.size(); result->reserve(index_size); if (index_size == 0) { return; } INDEX_TYPE current_output_column = 0; INDEX_TYPE current_value_rowid = value_rowids(0); DCHECK_LT(current_value_rowid, parent_output_index.size()); INDEX_TYPE current_output_index = parent_output_index[current_value_rowid]; result->push_back(current_output_index); for (INDEX_TYPE i = 1; i < index_size; ++i) { INDEX_TYPE next_value_rowid = value_rowids(i); if (next_value_rowid == current_value_rowid) { if (current_output_index >= 0) { ++current_output_column; if (current_output_column < output_size) { current_output_index += output_index_multiplier; } else { current_output_index = -1; } } } else { current_output_column = 0; current_value_rowid = next_value_rowid; DCHECK_LT(next_value_rowid, parent_output_index.size()); current_output_index = parent_output_index[next_value_rowid]; } result->push_back(current_output_index); } OP_REQUIRES(context, result->size() == value_rowids.size(), errors::InvalidArgument("Invalid row ids.")); }
0
C++
CWE-131
Incorrect Calculation of Buffer Size
The software does not correctly calculate the size to be used when allocating a buffer, which could lead to a buffer overflow.
https://cwe.mitre.org/data/definitions/131.html
vulnerable
Array HHVM_FUNCTION(__SystemLib_compact_sl, const Variant& varname, const Array& args /* = null array */) { Array ret = Array::attach(PackedArray::MakeReserve(args.size() + 1)); VarEnv* v = g_context->getOrCreateVarEnv(); if (v) { PointerSet seen; compact(seen, v, ret, varname); if (!args.empty()) compact(seen, v, ret, args); } return ret; }
1
C++
NVD-CWE-Other
Other
NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
https://nvd.nist.gov/vuln/categories
safe
static inline bool isMountable(const RemoteFsDevice::Details &d) { return RemoteFsDevice::constSshfsProtocol==d.url.scheme(); }
1
C++
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
https://cwe.mitre.org/data/definitions/22.html
safe
bool read(ReadonlyBytes buffer) { auto fields_size = sizeof(CentralDirectoryRecord) - (sizeof(u8*) * 3); if (buffer.size() < fields_size) return false; if (memcmp(buffer.data(), central_directory_record_signature, sizeof(central_directory_record_signature)) != 0) return false; memcpy(reinterpret_cast<void*>(&made_by_version), buffer.data() + sizeof(central_directory_record_signature), fields_size); name = buffer.data() + sizeof(central_directory_record_signature) + fields_size; extra_data = name + name_length; comment = extra_data + extra_data_length; return true; }
0
C++
CWE-120
Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')
The program copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer, leading to a buffer overflow.
https://cwe.mitre.org/data/definitions/120.html
vulnerable
__global__ void UnsortedSegmentCustomKernel(const Index input_outer_dim_size, const Index inner_dim_size, const Index output_outer_dim_size, const Index* segment_ids, const T* input, T* output) { const Index input_total_size = input_outer_dim_size * inner_dim_size; const Index output_total_size = output_outer_dim_size * inner_dim_size; for (int input_index : GpuGridRangeX(input_total_size)) { const Index input_segment_index = input_index / inner_dim_size; const Index segment_offset = input_index % inner_dim_size; const Index output_segment_index = segment_ids[input_segment_index]; if (output_segment_index < 0 || output_segment_index >= output_total_size) { continue; } const Index output_index = output_segment_index * inner_dim_size + segment_offset; KernelReductionFunctor()(output + output_index, ldg(input + input_index)); } }
0
C++
CWE-681
Incorrect Conversion between Numeric Types
When converting from one data type to another, such as long to integer, data can be omitted or translated in a way that produces unexpected values. If the resulting values are used in a sensitive context, then dangerous behaviors may occur.
https://cwe.mitre.org/data/definitions/681.html
vulnerable
jas_matrix_t *jas_matrix_create(int numrows, int numcols) { jas_matrix_t *matrix; int i; if (numrows < 0 || numcols < 0) { return 0; } if (!(matrix = jas_malloc(sizeof(jas_matrix_t)))) { return 0; } matrix->flags_ = 0; matrix->numrows_ = numrows; matrix->numcols_ = numcols; matrix->rows_ = 0; matrix->maxrows_ = numrows; matrix->data_ = 0; matrix->datasize_ = numrows * numcols; if (matrix->maxrows_ > 0) { if (!(matrix->rows_ = jas_alloc2(matrix->maxrows_, sizeof(jas_seqent_t *)))) { jas_matrix_destroy(matrix); return 0; } } if (matrix->datasize_ > 0) { if (!(matrix->data_ = jas_alloc2(matrix->datasize_, sizeof(jas_seqent_t)))) { jas_matrix_destroy(matrix); return 0; } } for (i = 0; i < numrows; ++i) { matrix->rows_[i] = &matrix->data_[i * matrix->numcols_]; } for (i = 0; i < matrix->datasize_; ++i) { matrix->data_[i] = 0; } matrix->xstart_ = 0; matrix->ystart_ = 0; matrix->xend_ = matrix->numcols_; matrix->yend_ = matrix->numrows_; return matrix; }
1
C++
CWE-476
NULL Pointer Dereference
A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.
https://cwe.mitre.org/data/definitions/476.html
safe
void resize (std::size_t new_size_) { _buf_size = new_size_; }
0
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
vulnerable
TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { auto* params = reinterpret_cast<TfLiteResizeBilinearParams*>(node->builtin_data); const TfLiteTensor* input = GetInput(context, node, kInputTensor); TfLiteTensor* output = GetOutput(context, node, kOutputTensor); const TfLiteTensor* size = GetInput(context, node, kSizeTensor); if (IsDynamicTensor(output)) { TF_LITE_ENSURE_OK(context, ResizeOutputTensor(context, input, size, output)); } if (output->type == kTfLiteFloat32) { #define TF_LITE_RESIZE_BILINEAR(type, datatype) \ tflite::ResizeBilinearParams op_params; \ op_params.align_corners = params->align_corners; \ op_params.half_pixel_centers = params->half_pixel_centers; \ type::ResizeBilinear(op_params, GetTensorShape(input), \ GetTensorData<datatype>(input), GetTensorShape(size), \ GetTensorData<int32>(size), GetTensorShape(output), \ GetTensorData<datatype>(output)) if (kernel_type == kReference) { TF_LITE_RESIZE_BILINEAR(reference_ops, float); } if (kernel_type == kGenericOptimized || kernel_type == kNeonOptimized) { TF_LITE_RESIZE_BILINEAR(optimized_ops, float); } } else if (output->type == kTfLiteUInt8) { if (kernel_type == kReference) { TF_LITE_RESIZE_BILINEAR(reference_ops, uint8_t); } if (kernel_type == kGenericOptimized || kernel_type == kNeonOptimized) { TF_LITE_RESIZE_BILINEAR(optimized_ops, uint8_t); } } else if (output->type == kTfLiteInt8) { TF_LITE_RESIZE_BILINEAR(reference_ops, int8_t); #undef TF_LITE_RESIZE_BILINEAR } else { context->ReportError(context, "Output type is %d, requires float.", output->type); return kTfLiteError; } return kTfLiteOk; }
0
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
vulnerable
int FdInStream::pos() { return offset + ptr - start; }
0
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
vulnerable
void jas_matrix_asl(jas_matrix_t *matrix, int n) { int i; int j; jas_seqent_t *rowstart; int rowstep; jas_seqent_t *data; if (jas_matrix_numrows(matrix) > 0 && jas_matrix_numcols(matrix) > 0) { assert(matrix->rows_); rowstep = jas_matrix_rowstep(matrix); for (i = matrix->numrows_, rowstart = matrix->rows_[0]; i > 0; --i, rowstart += rowstep) { for (j = matrix->numcols_, data = rowstart; j > 0; --j, ++data) { //*data <<= n; *data = jas_seqent_asl(*data, n); } } } }
0
C++
CWE-190
Integer Overflow or Wraparound
The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.
https://cwe.mitre.org/data/definitions/190.html
vulnerable
unique_ptr<IOBuf> IOBuf::createCombined(std::size_t capacity) { if (capacity > kMaxIOBufSize) { throw_exception<std::bad_alloc>(); } // To save a memory allocation, allocate space for the IOBuf object, the // SharedInfo struct, and the data itself all with a single call to malloc(). size_t requiredStorage = offsetof(HeapFullStorage, align) + capacity; size_t mallocSize = goodMallocSize(requiredStorage); auto storage = static_cast<HeapFullStorage*>(checkedMalloc(mallocSize)); new (&storage->hs.prefix) HeapPrefix(kIOBufInUse | kDataInUse, mallocSize); new (&storage->shared) SharedInfo(freeInternalBuf, storage); if (io_buf_alloc_cb) { io_buf_alloc_cb(storage, mallocSize); } auto bufAddr = reinterpret_cast<uint8_t*>(&storage->align); uint8_t* storageEnd = reinterpret_cast<uint8_t*>(storage) + mallocSize; auto actualCapacity = size_t(storageEnd - bufAddr); unique_ptr<IOBuf> ret(new (&storage->hs.buf) IOBuf( InternalConstructor(), packFlagsAndSharedInfo(0, &storage->shared), bufAddr, actualCapacity, bufAddr, 0)); return ret; }
1
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
safe
CbrDetectorRemote::Result CbrDetectorRemote::Decrypt(cricket::MediaType media_type, const std::vector<uint32_t>& csrcs, rtc::ArrayView<const uint8_t> additional_data, rtc::ArrayView<const uint8_t> encrypted_frame, rtc::ArrayView<uint8_t> frame) { const uint8_t *src = encrypted_frame.data(); uint8_t *dst = frame.data(); uint32_t data_len = encrypted_frame.size(); if (media_type == cricket::MEDIA_TYPE_AUDIO) { if (data_len == frame_size && frame_size >= 40) { frame_count++; if (frame_count > 200 && !detected) { info("CBR detector: remote cbr detected\n"); detected = true; } } else { frame_count = 0; frame_size = data_len; if (detected) { info("CBR detector: remote cbr detected disabled\n"); detected = false; } } } memcpy(dst, src, data_len); out: return CbrDetectorRemote::Result(CbrDetectorRemote::Status::kOk, data_len); }
0
C++
CWE-134
Use of Externally-Controlled Format String
The software uses a function that accepts a format string as an argument, but the format string originates from an external source.
https://cwe.mitre.org/data/definitions/134.html
vulnerable
TF_EXCLUSIVE_LOCKS_REQUIRED(mu_) { if (tuple[index].has_value()) { return errors::InvalidArgument( "The tensor for index '", index, "' for key '", key.scalar<int64>()(), "' was already initialized '", dtypes_.size(), "'."); } return Status::OK(); }
1
C++
CWE-824
Access of Uninitialized Pointer
The program accesses or uses a pointer that has not been initialized.
https://cwe.mitre.org/data/definitions/824.html
safe
R_API RBinJavaAttrInfo *r_bin_java_source_code_file_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) { if (!sz || sz == UT64_MAX) { return NULL; } #if 0 /// XXX this breaks tests if (sz < 8) { return NULL; } #endif ut64 offset = 0; RBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset); offset += 6; if (attr) { attr->type = R_BIN_JAVA_ATTR_TYPE_SOURCE_FILE_ATTR; attr->info.source_file_attr.sourcefile_idx = R_BIN_JAVA_USHORT (buffer, offset); offset += 2; attr->size = offset; // IFDBG r_bin_java_print_source_code_file_attr_summary(attr); } return attr; }
1
C++
CWE-805
Buffer Access with Incorrect Length Value
The software uses a sequential operation to read or write a buffer, but it uses an incorrect length value that causes it to access memory that is outside of the bounds of the buffer.
https://cwe.mitre.org/data/definitions/805.html
safe
static int vorbis_finish_frame(stb_vorbis *f, int len, int left, int right) { int prev,i,j; // we use right&left (the start of the right- and left-window sin()-regions) // to determine how much to return, rather than inferring from the rules // (same result, clearer code); 'left' indicates where our sin() window // starts, therefore where the previous window's right edge starts, and // therefore where to start mixing from the previous buffer. 'right' // indicates where our sin() ending-window starts, therefore that's where // we start saving, and where our returned-data ends. // mixin from previous window if (f->previous_length) { int i,j, n = f->previous_length; float *w = get_window(f, n); if (w == NULL) return 0; for (i=0; i < f->channels; ++i) { for (j=0; j < n; ++j) f->channel_buffers[i][left+j] = f->channel_buffers[i][left+j]*w[ j] + f->previous_window[i][ j]*w[n-1-j]; } } prev = f->previous_length; // last half of this data becomes previous window f->previous_length = len - right; // @OPTIMIZE: could avoid this copy by double-buffering the // output (flipping previous_window with channel_buffers), but // then previous_window would have to be 2x as large, and // channel_buffers couldn't be temp mem (although they're NOT // currently temp mem, they could be (unless we want to level // performance by spreading out the computation)) for (i=0; i < f->channels; ++i) for (j=0; right+j < len; ++j) f->previous_window[i][j] = f->channel_buffers[i][right+j]; if (!prev) // there was no previous packet, so this data isn't valid... // this isn't entirely true, only the would-have-overlapped data // isn't valid, but this seems to be what the spec requires return 0; // truncate a short frame if (len < right) right = len; f->samples_output += right-left; return right - left; }
1
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
safe
static x86newTokenType getToken(const char *str, size_t *begin, size_t *end) { if (*begin > strlen (str)) { return TT_EOF; } // Skip whitespace while (begin && str[*begin] && isspace ((ut8)str[*begin])) { ++(*begin); } if (!str[*begin]) { // null byte *end = *begin; return TT_EOF; } if (isalpha ((ut8)str[*begin])) { // word token *end = *begin; while (end && str[*end] && isalnum ((ut8)str[*end])) { ++(*end); } return TT_WORD; } if (isdigit ((ut8)str[*begin])) { // number token *end = *begin; while (end && isalnum ((ut8)str[*end])) { // accept alphanumeric characters, because hex. ++(*end); } return TT_NUMBER; } else { // special character: [, ], +, *, ... *end = *begin + 1; return TT_SPECIAL; } }
1
C++
CWE-125
Out-of-bounds Read
The software reads data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/125.html
safe
TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { auto* params = reinterpret_cast<TfLiteLSHProjectionParams*>(node->builtin_data); TfLiteTensor* out_tensor; TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &out_tensor)); int32_t* out_buf = out_tensor->data.i32; const TfLiteTensor* hash; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &hash)); const TfLiteTensor* input; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 1, &input)); const TfLiteTensor* weight = NumInputs(node) == 2 ? nullptr : GetInput(context, node, 2); switch (params->type) { case kTfLiteLshProjectionDense: DenseLshProjection(hash, input, weight, out_buf); break; case kTfLiteLshProjectionSparse: SparseLshProjection(hash, input, weight, out_buf); break; default: return kTfLiteError; } return kTfLiteOk; }
1
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
safe
static int makeDirDirective(MaState *state, cchar *key, cchar *value) { MprPath info; char *auth, *dirs, *path, *perms, *tok; cchar *dir, *group, *owner; int gid, mode, uid; if (!maTokenize(state, value, "%S ?*", &auth, &dirs)) { return MPR_ERR_BAD_SYNTAX; } uid = gid = 0; mode = 0750; if (schr(auth, ':')) { owner = ssplit(auth, ":", &tok); if (owner && *owner) { if (snumber(owner)) { uid = (int) stoi(owner); } else if (smatch(owner, "APPWEB")) { uid = HTTP->uid; } else { uid = userToID(owner); } } group = ssplit(tok, ":", &perms); if (group && *group) { if (snumber(group)) { gid = (int) stoi(group); } else if (smatch(owner, "APPWEB")) { gid = HTTP->gid; } else { gid = groupToID(group); } } if (perms && snumber(perms)) { mode = (int) stoiradix(perms, -1, NULL); } else { mode = 0; } if (gid < 0 || uid < 0) { return MPR_ERR_BAD_SYNTAX; } } else { dirs = auth; auth = 0; } tok = dirs; for (tok = sclone(dirs); (dir = stok(tok, ",", &tok)) != 0; ) { path = httpMakePath(state->route, state->configDir, dir); if (mprGetPathInfo(path, &info) == 0 && info.isDir) { continue; } if (mprMakeDir(path, mode, uid, gid, 1) < 0) { return MPR_ERR_BAD_SYNTAX; } } return 0; }
1
C++
NVD-CWE-Other
Other
NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
https://nvd.nist.gov/vuln/categories
safe
bool IsPadOpSupported(const TfLiteRegistration* registration, const TfLiteNode* node, TfLiteContext* context) { // padding is d x 2 tensor, where d is the dimension of input. const TfLiteTensor* padding = GetInput(context, node, 1); if (!IsConstantTensor(padding)) { TF_LITE_KERNEL_LOG(context, "%s: Only constant padding is supported for PAD.", padding->name); return false; } if (padding->dims->data[0] != 4 || padding->dims->data[1] != 2) { TF_LITE_KERNEL_LOG(context, "%s: Only 4D inputs are supported for PAD.", padding->name); return false; } const int32_t* padding_data = GetTensorData<int32_t>(padding); if (!(padding_data[0] == 0 && padding_data[1] == 0)) { TF_LITE_KERNEL_LOG( context, "%s: Padding for batch dimension is not supported in PAD.", padding->name); return false; } if (!(padding_data[6] == 0 && padding_data[7] == 0)) { TF_LITE_KERNEL_LOG( context, "%s: Padding for channel dimension is not supported in PAD.", padding->name); return false; } return true; }
0
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
vulnerable
void *jas_realloc(void *ptr, size_t size) { void *result; JAS_DBGLOG(101, ("jas_realloc called with %x,%zu\n", ptr, size)); result = realloc(ptr, size); JAS_DBGLOG(100, ("jas_realloc(%p, %zu) -> %p\n", ptr, size, result)); return result; }
0
C++
CWE-190
Integer Overflow or Wraparound
The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.
https://cwe.mitre.org/data/definitions/190.html
vulnerable
void CoreUserInputHandler::putPrivmsg(const QString &target, const QString &message, std::function<QByteArray(const QString &, const QString &)> encodeFunc, Cipher *cipher) { QString cmd("PRIVMSG"); QByteArray targetEnc = serverEncode(target); std::function<QList<QByteArray>(QString &)> cmdGenerator = [&] (QString &splitMsg) -> QList<QByteArray> { QByteArray splitMsgEnc = encodeFunc(target, splitMsg); #ifdef HAVE_QCA2 if (cipher && !cipher->key().isEmpty() && !splitMsg.isEmpty()) { cipher->encrypt(splitMsgEnc); } #endif return QList<QByteArray>() << targetEnc << splitMsgEnc; }; putCmd(cmd, network()->splitMessage(cmd, message, cmdGenerator)); }
1
C++
CWE-399
Resource Management Errors
Weaknesses in this category are related to improper management of system resources.
https://cwe.mitre.org/data/definitions/399.html
safe
void Transform::interpolate_nearestneighbour( RawTile& in, unsigned int resampled_width, unsigned int resampled_height ){ // Pointer to input buffer unsigned char *input = (unsigned char*) in.data; int channels = in.channels; unsigned int width = in.width; unsigned int height = in.height; // Pointer to output buffer unsigned char *output; // Create new buffer if size is larger than input size bool new_buffer = false; if( resampled_width*resampled_height > in.width*in.height ){ new_buffer = true; output = new unsigned char[(unsigned long long)resampled_width*resampled_height*in.channels]; } else output = (unsigned char*) in.data; // Calculate our scale float xscale = (float)width / (float)resampled_width; float yscale = (float)height / (float)resampled_height; for( unsigned int j=0; j<resampled_height; j++ ){ for( unsigned int i=0; i<resampled_width; i++ ){ // Indexes in the current pyramid resolution and resampled spaces // Make sure to limit our input index to the image surface unsigned long ii = (unsigned int) floorf(i*xscale); unsigned long jj = (unsigned int) floorf(j*yscale); unsigned long pyramid_index = (unsigned int) channels * ( ii + jj*width ); unsigned long long resampled_index = (unsigned long long)(i + j*resampled_width)*channels; for( int k=0; k<in.channels; k++ ){ output[resampled_index+k] = input[pyramid_index+k]; } } } // Delete original buffer if( new_buffer ) delete[] (unsigned char*) input; // Correctly set our Rawtile info in.width = resampled_width; in.height = resampled_height; in.dataLength = resampled_width * resampled_height * channels * (in.bpc/8); in.data = output; }
0
C++
CWE-190
Integer Overflow or Wraparound
The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.
https://cwe.mitre.org/data/definitions/190.html
vulnerable
Error HeifContext::get_id_of_non_virtual_child_image(heif_item_id id, heif_item_id& out) const { std::string image_type = m_heif_file->get_item_type(id); if (image_type=="grid" || image_type=="iden" || image_type=="iovl") { auto iref_box = m_heif_file->get_iref_box(); if (!iref_box) { return Error(heif_error_Invalid_input, heif_suberror_No_item_data, "Derived image does not reference any other image items"); } std::vector<heif_item_id> image_references = iref_box->get_references(id, fourcc("dimg")); // TODO: check whether this really can be recursive (e.g. overlay of grid images) if (image_references.empty()) { return Error(heif_error_Invalid_input, heif_suberror_No_item_data, "Derived image does not reference any other image items"); } else { return get_id_of_non_virtual_child_image(image_references[0], out); } } else { out = id; return Error::Ok; } }
1
C++
CWE-125
Out-of-bounds Read
The software reads data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/125.html
safe
void * alloc_bottom(size_t size) { byte * tmp = bottom; bottom += size; if (bottom > top) {new_chunk(); tmp = bottom; bottom += size;} return tmp; }
0
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
vulnerable
TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { auto* data = reinterpret_cast<TfLiteAudioMicrofrontendParams*>(node->user_data); FrontendReset(data->state); const TfLiteTensor* input; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input)); TfLiteTensor* output; TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, kOutputTensor, &output)); if (data->out_float) { GenerateFeatures<float>(data, input, output); } else { GenerateFeatures<int32>(data, input, output); } return kTfLiteOk; }
1
C++
CWE-125
Out-of-bounds Read
The software reads data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/125.html
safe
Network::FilterStatus Context::onUpstreamData(int data_length, bool end_of_stream) { if (!wasm_->onUpstreamData_) { return Network::FilterStatus::Continue; } auto result = wasm_->onUpstreamData_(this, id_, static_cast<uint32_t>(data_length), static_cast<uint32_t>(end_of_stream)); // TODO(PiotrSikora): pull Proxy-WASM's FilterStatus values. return result.u64_ == 0 ? Network::FilterStatus::Continue : Network::FilterStatus::StopIteration; }
0
C++
CWE-476
NULL Pointer Dereference
A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit.
https://cwe.mitre.org/data/definitions/476.html
vulnerable
FBUnserializer<V>::unserializeThing(size_t depth) { if (UNLIKELY(depth > 1024)) { throw UnserializeError("depth > 1024"); } size_t code = nextCode(); switch (code) { case FB_SERIALIZE_BYTE: case FB_SERIALIZE_I16: case FB_SERIALIZE_I32: case FB_SERIALIZE_I64: return V::fromInt64(unserializeInt64()); case FB_SERIALIZE_VARCHAR: case FB_SERIALIZE_STRING: return V::fromString(unserializeString()); case FB_SERIALIZE_STRUCT: return V::fromMap(unserializeMap(depth)); case FB_SERIALIZE_NULL: ++p_; return V::createNull(); case FB_SERIALIZE_DOUBLE: return V::fromDouble(unserializeDouble()); case FB_SERIALIZE_BOOLEAN: return V::fromBool(unserializeBoolean()); case FB_SERIALIZE_VECTOR: return V::fromVector(unserializeVector(depth)); case FB_SERIALIZE_LIST: return V::fromVector(unserializeList(depth)); case FB_SERIALIZE_SET: return V::fromSet(unserializeSet(depth)); default: throw UnserializeError("Invalid code: " + folly::to<std::string>(code) + " at location " + folly::to<std::string>(p_)); } }
1
C++
CWE-674
Uncontrolled Recursion
The product does not properly control the amount of recursion which takes place, consuming excessive resources, such as allocated memory or the program stack.
https://cwe.mitre.org/data/definitions/674.html
safe
ResourceHandle::ResourceHandle(const ResourceHandleProto& proto) { FromProto(proto); }
0
C++
CWE-617
Reachable Assertion
The product contains an assert() or similar statement that can be triggered by an attacker, which leads to an application exit or other behavior that is more severe than necessary.
https://cwe.mitre.org/data/definitions/617.html
vulnerable
bool ContentSettingsObserver::AllowScript(bool enabled_per_settings) { if (!enabled_per_settings) return false; if (IsScriptDisabledForPreview(render_frame())) return false; if (is_interstitial_page_) return true; blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); const auto it = cached_script_permissions_.find(frame); if (it != cached_script_permissions_.end()) return it->second; // Evaluate the content setting rules before // IsWhitelistedForContentSettings(); if there is only the default rule // allowing all scripts, it's quicker this way. bool allow = true; if (content_settings_manager_->content_settings()) { allow = content_settings_manager_->GetSetting( ContentSettingsManager::GetOriginOrURL(render_frame()->GetWebFrame()), url::Origin(frame->GetDocument().GetSecurityOrigin()).GetURL(), "javascript", allow) != CONTENT_SETTING_BLOCK; } allow = allow || IsWhitelistedForContentSettings(); cached_script_permissions_[frame] = allow; return allow; }
1
C++
CWE-20
Improper Input Validation
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.
https://cwe.mitre.org/data/definitions/20.html
safe
static bool couldRecur(const Variant& v, const Array& arr) { return v.isReferenced() || arr.get()->kind() == ArrayData::kGlobalsKind || arr.get()->kind() == ArrayData::kProxyKind; }
0
C++
NVD-CWE-Other
Other
NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
https://nvd.nist.gov/vuln/categories
vulnerable
R_API ut64 r_bin_java_element_pair_calc_size(RBinJavaElementValuePair *evp) { ut64 sz = 0; if (evp == NULL) { return sz; } // evp->element_name_idx = r_bin_java_read_short(bin, bin->b->cur); sz += 2; // evp->value = r_bin_java_element_value_new (bin, offset+2); if (evp->value) { sz += r_bin_java_element_value_calc_size (evp->value); } return sz; }
0
C++
CWE-119
Improper Restriction of Operations within the Bounds of a Memory Buffer
The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.
https://cwe.mitre.org/data/definitions/119.html
vulnerable
TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { const CTCBeamSearchDecoderParams* option = reinterpret_cast<CTCBeamSearchDecoderParams*>(node->user_data); const int top_paths = option->top_paths; TF_LITE_ENSURE(context, option->beam_width >= top_paths); TF_LITE_ENSURE_EQ(context, NumInputs(node), 2); // The outputs should be top_paths * 3 + 1. TF_LITE_ENSURE_EQ(context, NumOutputs(node), 3 * top_paths + 1); const TfLiteTensor* inputs = GetInput(context, node, kInputsTensor); TF_LITE_ENSURE_EQ(context, NumDimensions(inputs), 3); // TensorFlow only supports float. TF_LITE_ENSURE_EQ(context, inputs->type, kTfLiteFloat32); const int batch_size = SizeOfDimension(inputs, 1); const TfLiteTensor* sequence_length = GetInput(context, node, kSequenceLengthTensor); TF_LITE_ENSURE_EQ(context, NumDimensions(sequence_length), 1); TF_LITE_ENSURE_EQ(context, NumElements(sequence_length), batch_size); // TensorFlow only supports int32. TF_LITE_ENSURE_EQ(context, sequence_length->type, kTfLiteInt32); // Resize decoded outputs. // Do not resize indices & values cause we don't know the values yet. for (int i = 0; i < top_paths; ++i) { TfLiteTensor* indices = GetOutput(context, node, i); SetTensorToDynamic(indices); TfLiteTensor* values = GetOutput(context, node, i + top_paths); SetTensorToDynamic(values); TfLiteTensor* output_shape = GetOutput(context, node, i + 2 * top_paths); SetTensorToDynamic(output_shape); } // Resize log probability outputs. TfLiteTensor* log_probability_output = GetOutput(context, node, top_paths * 3); TfLiteIntArray* log_probability_output_shape_array = TfLiteIntArrayCreate(2); log_probability_output_shape_array->data[0] = batch_size; log_probability_output_shape_array->data[1] = top_paths; return context->ResizeTensor(context, log_probability_output, log_probability_output_shape_array); }
0
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
vulnerable
R_API RBinJavaAnnotation *r_bin_java_annotation_new(ut8 *buffer, ut64 sz, ut64 buf_offset) { ut32 i = 0; RBinJavaElementValuePair *evps = NULL; ut64 offset = 0; if (sz < 8) { return NULL; } RBinJavaAnnotation *annotation = R_NEW0 (RBinJavaAnnotation); if (!annotation) { return NULL; } // (ut16) read and set annotation_value.type_idx; annotation->type_idx = R_BIN_JAVA_USHORT (buffer, offset); offset += 2; // (ut16) read and set annotation_value.num_element_value_pairs; annotation->num_element_value_pairs = R_BIN_JAVA_USHORT (buffer, offset); offset += 2; annotation->element_value_pairs = r_list_newf (r_bin_java_element_pair_free); // read annotation_value.num_element_value_pairs, and append to annotation_value.element_value_pairs for (i = 0; i < annotation->num_element_value_pairs; i++) { if (offset > sz) { break; } evps = r_bin_java_element_pair_new (buffer + offset, sz - offset, buf_offset + offset); if (evps) { offset += evps->size; r_list_append (annotation->element_value_pairs, (void *) evps); } } annotation->size = offset; return annotation; }
1
C++
CWE-788
Access of Memory Location After End of Buffer
The software reads or writes to a buffer using an index or pointer that references a memory location after the end of the buffer.
https://cwe.mitre.org/data/definitions/788.html
safe
TEST_F(HeaderTableTests, varyCapacity) { HPACKHeader accept("accept-encoding", "gzip"); uint32_t max = 6; uint32_t capacity = accept.bytes() * max; HeaderTable table(capacity); // Fill the table (extra) and make sure we haven't violated our // size (bytes) limits (expected one entry to be evicted) for (size_t i = 0; i <= table.length(); ++i) { EXPECT_EQ(table.add(accept), true); } EXPECT_EQ(table.size(), max); // Size down the table and verify we are still honoring our size (bytes) // limits resizeAndFillTable(table, accept, 4, 5); // Size up the table (in between previous max and min within test) and verify // we are still horing our size (bytes) limits resizeAndFillTable(table, accept, 5, 6); // Finally reize up one last timestamps resizeAndFillTable(table, accept, 8, 9); }
1
C++
CWE-416
Use After Free
Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.
https://cwe.mitre.org/data/definitions/416.html
safe
static Variant HHVM_FUNCTION(bcsqrt, const String& operand, int64_t scale /* = -1 */) { scale = adjust_scale(scale); bc_num result; bc_init_num(&result); SCOPE_EXIT { bc_free_num(&result); }; php_str2num(&result, (char*)operand.data()); Variant ret; if (bc_sqrt(&result, scale) != 0) { if (result->n_scale > scale) { result->n_scale = scale; } ret = String(bc_num2str(result), AttachString); } else { raise_warning("Square root of negative number"); } return ret; }
1
C++
CWE-190
Integer Overflow or Wraparound
The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.
https://cwe.mitre.org/data/definitions/190.html
safe
int crypto_scrypt(const uint8_t* password, size_t pwlen, const uint8_t* salt, size_t saltlen, uint64_t N, uint32_t r, uint32_t p, uint8_t* buf, size_t buflen) { return crypto_pwhash_scryptsalsa208sha256_ll(password, pwlen, salt, saltlen, N, r, p, buf, buflen); }
1
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
safe
static ssize_t _hostfs_readv( oe_fd_t* desc, const struct oe_iovec* iov, int iovcnt) { ssize_t ret = -1; file_t* file = _cast_file(desc); void* buf = NULL; size_t buf_size = 0; if (!file || (!iov && iovcnt) || iovcnt < 0 || iovcnt > OE_IOV_MAX) OE_RAISE_ERRNO(OE_EINVAL); /* Flatten the IO vector into contiguous heap memory. */ if (oe_iov_pack(iov, iovcnt, &buf, &buf_size) != 0) OE_RAISE_ERRNO(OE_ENOMEM); /* Call the host. */ if (oe_syscall_readv_ocall(&ret, file->host_fd, buf, iovcnt, buf_size) != OE_OK) { OE_RAISE_ERRNO(OE_EINVAL); } /* Synchronize data read with IO vector. */ if (ret > 0) { if (oe_iov_sync(iov, iovcnt, buf, buf_size) != 0) OE_RAISE_ERRNO(OE_EINVAL); } done: if (buf) oe_free(buf); return ret; }
0
C++
NVD-CWE-Other
Other
NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
https://nvd.nist.gov/vuln/categories
vulnerable
static String HHVM_FUNCTION(bcsub, const String& left, const String& right, int64_t scale /* = -1 */) { if (scale < 0) scale = BCG(bc_precision); bc_num first, second, result; bc_init_num(&first); bc_init_num(&second); bc_init_num(&result); php_str2num(&first, (char*)left.data()); php_str2num(&second, (char*)right.data()); bc_sub(first, second, &result, scale); if (result->n_scale > scale) { result->n_scale = scale; } String ret(bc_num2str(result), AttachString); bc_free_num(&first); bc_free_num(&second); bc_free_num(&result); return ret; }
0
C++
CWE-190
Integer Overflow or Wraparound
The software performs a calculation that can produce an integer overflow or wraparound, when the logic assumes that the resulting value will always be larger than the original value. This can introduce other weaknesses when the calculation is used for resource management or execution control.
https://cwe.mitre.org/data/definitions/190.html
vulnerable
int ZlibInStream::pos() { return offset + ptr - start; }
0
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
vulnerable
TfLiteStatus PrepareHashtableFind(TfLiteContext* context, TfLiteNode* node) { TF_LITE_ENSURE_EQ(context, NumInputs(node), 3); TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1); const TfLiteTensor* input_resource_id_tensor = GetInput(context, node, kInputResourceIdTensor); TF_LITE_ENSURE_EQ(context, input_resource_id_tensor->type, kTfLiteInt32); TF_LITE_ENSURE_EQ(context, NumDimensions(input_resource_id_tensor), 1); TF_LITE_ENSURE_EQ(context, SizeOfDimension(input_resource_id_tensor, 0), 1); const TfLiteTensor* default_value_tensor = GetInput(context, node, kDefaultValueTensor); const TfLiteTensor* key_tensor = GetInput(context, node, kKeyTensor); TfLiteTensor* output_tensor = GetOutput(context, node, kOutputTensor); TF_LITE_ENSURE_EQ(context, default_value_tensor->type, output_tensor->type); TF_LITE_ENSURE(context, (key_tensor->type == kTfLiteInt64 && output_tensor->type == kTfLiteString) || (key_tensor->type == kTfLiteString && output_tensor->type == kTfLiteInt64)); return context->ResizeTensor(context, output_tensor, TfLiteIntArrayCopy(key_tensor->dims)); }
0
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
vulnerable
inline int64_t StringData::size() const { return m_len; }
1
C++
CWE-125
Out-of-bounds Read
The software reads data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/125.html
safe
TfLiteStatus AverageEval(TfLiteContext* context, TfLiteNode* node) { auto* params = reinterpret_cast<TfLitePoolParams*>(node->builtin_data); OpData* data = reinterpret_cast<OpData*>(node->user_data); TfLiteTensor* output; TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &output)); const TfLiteTensor* input; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &input)); switch (input->type) { // Already know in/out types are same. case kTfLiteFloat32: return AverageEvalFloat<kernel_type>(context, node, params, data, input, output); case kTfLiteUInt8: return AverageEvalQuantizedUint8<kernel_type>(context, node, params, data, input, output); case kTfLiteInt8: return AverageEvalQuantizedInt8<kernel_type>(context, node, params, data, input, output); case kTfLiteInt16: return AverageEvalQuantizedInt16<kernel_type>(context, node, params, data, input, output); default: TF_LITE_KERNEL_LOG(context, "Type %s not currently supported.", TfLiteTypeGetName(input->type)); return kTfLiteError; } return kTfLiteOk; }
1
C++
CWE-835
Loop with Unreachable Exit Condition ('Infinite Loop')
The program contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.
https://cwe.mitre.org/data/definitions/835.html
safe
mptctl_eventquery (unsigned long arg) { struct mpt_ioctl_eventquery __user *uarg = (void __user *) arg; struct mpt_ioctl_eventquery karg; MPT_ADAPTER *ioc; int iocnum; if (copy_from_user(&karg, uarg, sizeof(struct mpt_ioctl_eventquery))) { printk(KERN_ERR MYNAM "%s@%d::mptctl_eventquery - " "Unable to read in mpt_ioctl_eventquery struct @ %p\n", __FILE__, __LINE__, uarg); return -EFAULT; } if (((iocnum = mpt_verify_adapter(karg.hdr.iocnum, &ioc)) < 0) || (ioc == NULL)) { printk(KERN_DEBUG MYNAM "%s::mptctl_eventquery() @%d - ioc%d not found!\n", __FILE__, __LINE__, iocnum); return -ENODEV; } dctlprintk(ioc, printk(MYIOC_s_DEBUG_FMT "mptctl_eventquery called.\n", ioc->name)); karg.eventEntries = MPTCTL_EVENT_LOG_SIZE; karg.eventTypes = ioc->eventTypes; /* Copy the data from kernel memory to user memory */ if (copy_to_user((char __user *)arg, &karg, sizeof(struct mpt_ioctl_eventquery))) { printk(MYIOC_s_ERR_FMT "%s@%d::mptctl_eventquery - " "Unable to write out mpt_ioctl_eventquery struct @ %p\n", ioc->name, __FILE__, __LINE__, uarg); return -EFAULT; } return 0; }
0
C++
CWE-362
Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')
The program contains a code sequence that can run concurrently with other code, and the code sequence requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence that is operating concurrently.
https://cwe.mitre.org/data/definitions/362.html
vulnerable
void Compute(OpKernelContext* c) override { const Tensor& tag = c->input(0); OP_REQUIRES(c, TensorShapeUtils::IsScalar(tag.shape()), errors::InvalidArgument("tag must be scalar")); const Tensor& tensor = c->input(1); const Tensor& serialized_summary_metadata_tensor = c->input(2); OP_REQUIRES( c, TensorShapeUtils::IsScalar(serialized_summary_metadata_tensor.shape()), errors::InvalidArgument("serialized_summary_metadata must be scalar")); Summary s; Summary::Value* v = s.add_value(); v->set_tag(string(tag.scalar<tstring>()())); // NOLINT if (tensor.dtype() == DT_STRING) { // tensor_util.makeNdarray doesn't work for strings in tensor_content tensor.AsProtoField(v->mutable_tensor()); } else { tensor.AsProtoTensorContent(v->mutable_tensor()); } ParseFromTString(serialized_summary_metadata_tensor.scalar<tstring>()(), v->mutable_metadata()); Tensor* summary_tensor = nullptr; OP_REQUIRES_OK(c, c->allocate_output(0, TensorShape({}), &summary_tensor)); CHECK(SerializeToTString(s, &summary_tensor->scalar<tstring>()())); }
1
C++
CWE-20
Improper Input Validation
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.
https://cwe.mitre.org/data/definitions/20.html
safe
TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { const TfLiteTensor* input = GetInput(context, node, kInputTensor); TfLiteTensor* output = GetOutput(context, node, kOutputTensor); if (input->type != kTfLiteFloat32) { TF_LITE_UNSUPPORTED_TYPE(context, input->type, "Ceil"); } optimized_ops::Ceil(GetTensorShape(input), GetTensorData<float>(input), GetTensorShape(output), GetTensorData<float>(output)); return kTfLiteOk; }
0
C++
CWE-125
Out-of-bounds Read
The software reads data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/125.html
vulnerable
TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { const TfLiteTensor* output = GetOutput(context, node, kOutputTensor); if (output->type == kTfLiteFloat32) { EvalAddN<float>(context, node); } else if (output->type == kTfLiteInt32) { EvalAddN<int32_t>(context, node); } else { context->ReportError(context, "AddN only supports FLOAT32|INT32 now, got %s.", TfLiteTypeGetName(output->type)); return kTfLiteError; } return kTfLiteOk; }
0
C++
CWE-125
Out-of-bounds Read
The software reads data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/125.html
vulnerable
TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { TF_LITE_ENSURE_EQ(context, NumInputs(node), 3); TF_LITE_ENSURE_EQ(context, NumOutputs(node), 2); const TfLiteTensor* lookup = GetInput(context, node, 0); TF_LITE_ENSURE_EQ(context, NumDimensions(lookup), 1); TF_LITE_ENSURE_EQ(context, lookup->type, kTfLiteInt32); const TfLiteTensor* key = GetInput(context, node, 1); TF_LITE_ENSURE_EQ(context, NumDimensions(key), 1); TF_LITE_ENSURE_EQ(context, key->type, kTfLiteInt32); const TfLiteTensor* value = GetInput(context, node, 2); TF_LITE_ENSURE(context, NumDimensions(value) >= 1); TF_LITE_ENSURE_EQ(context, SizeOfDimension(key, 0), SizeOfDimension(value, 0)); if (value->type == kTfLiteString) { TF_LITE_ENSURE_EQ(context, NumDimensions(value), 1); } TfLiteTensor* hits = GetOutput(context, node, 1); TF_LITE_ENSURE_EQ(context, hits->type, kTfLiteUInt8); TfLiteIntArray* hitSize = TfLiteIntArrayCreate(1); hitSize->data[0] = SizeOfDimension(lookup, 0); TfLiteTensor* output = GetOutput(context, node, 0); TF_LITE_ENSURE_EQ(context, value->type, output->type); TfLiteStatus status = kTfLiteOk; if (output->type != kTfLiteString) { TfLiteIntArray* outputSize = TfLiteIntArrayCreate(NumDimensions(value)); outputSize->data[0] = SizeOfDimension(lookup, 0); for (int i = 1; i < NumDimensions(value); i++) { outputSize->data[i] = SizeOfDimension(value, i); } status = context->ResizeTensor(context, output, outputSize); } if (context->ResizeTensor(context, hits, hitSize) != kTfLiteOk) { status = kTfLiteError; } return status; }
0
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
vulnerable
static int load_state_from_tss16(struct x86_emulate_ctxt *ctxt, struct tss_segment_16 *tss) { int ret; u8 cpl; ctxt->_eip = tss->ip; ctxt->eflags = tss->flag | 2; *reg_write(ctxt, VCPU_REGS_RAX) = tss->ax; *reg_write(ctxt, VCPU_REGS_RCX) = tss->cx; *reg_write(ctxt, VCPU_REGS_RDX) = tss->dx; *reg_write(ctxt, VCPU_REGS_RBX) = tss->bx; *reg_write(ctxt, VCPU_REGS_RSP) = tss->sp; *reg_write(ctxt, VCPU_REGS_RBP) = tss->bp; *reg_write(ctxt, VCPU_REGS_RSI) = tss->si; *reg_write(ctxt, VCPU_REGS_RDI) = tss->di; /* * SDM says that segment selectors are loaded before segment * descriptors */ set_segment_selector(ctxt, tss->ldt, VCPU_SREG_LDTR); set_segment_selector(ctxt, tss->es, VCPU_SREG_ES); set_segment_selector(ctxt, tss->cs, VCPU_SREG_CS); set_segment_selector(ctxt, tss->ss, VCPU_SREG_SS); set_segment_selector(ctxt, tss->ds, VCPU_SREG_DS); cpl = tss->cs & 3; /* * Now load segment descriptors. If fault happens at this stage * it is handled in a context of new task */ ret = __load_segment_descriptor(ctxt, tss->ldt, VCPU_SREG_LDTR, cpl, true); if (ret != X86EMUL_CONTINUE) return ret; ret = __load_segment_descriptor(ctxt, tss->es, VCPU_SREG_ES, cpl, true); if (ret != X86EMUL_CONTINUE) return ret; ret = __load_segment_descriptor(ctxt, tss->cs, VCPU_SREG_CS, cpl, true); if (ret != X86EMUL_CONTINUE) return ret; ret = __load_segment_descriptor(ctxt, tss->ss, VCPU_SREG_SS, cpl, true); if (ret != X86EMUL_CONTINUE) return ret; ret = __load_segment_descriptor(ctxt, tss->ds, VCPU_SREG_DS, cpl, true); if (ret != X86EMUL_CONTINUE) return ret; return X86EMUL_CONTINUE; }
0
C++
NVD-CWE-noinfo
null
null
null
vulnerable
TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { TF_LITE_ENSURE_EQ(context, NumInputs(node), 1); TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1); const TfLiteTensor* input; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input)); TfLiteTensor* output; TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, kOutputTensor, &output)); auto* params = reinterpret_cast<TfLiteShapeParams*>(node->builtin_data); switch (params->out_type) { case kTfLiteInt32: output->type = kTfLiteInt32; break; case kTfLiteInt64: output->type = kTfLiteInt64; break; default: context->ReportError(context, "Unknown shape output data type: %d", params->out_type); return kTfLiteError; } // By design, the input shape is always known at the time of Prepare, even // if the preceding op that generates |input| is dynamic. Thus, we can // always compute the shape immediately, without waiting for Eval. SetTensorToPersistentRo(output); // Shape always produces a 1-dimensional output tensor, where each output // element is the length of the corresponding input tensor's dimension. TfLiteIntArray* output_size = TfLiteIntArrayCreate(1); output_size->data[0] = NumDimensions(input); TF_LITE_ENSURE_STATUS(context->ResizeTensor(context, output, output_size)); TFLITE_DCHECK_EQ(NumDimensions(output), 1); TFLITE_DCHECK_EQ(SizeOfDimension(output, 0), NumDimensions(input)); // Immediately propagate the known shape to the output tensor. This allows // downstream ops that rely on the value to use it during prepare. switch (output->type) { case kTfLiteInt32: ExtractShape(input, GetTensorData<int32_t>(output)); break; case kTfLiteInt64: ExtractShape(input, GetTensorData<int64_t>(output)); break; default: return kTfLiteError; } return kTfLiteOk; }
1
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
safe
static ssize_t _hostfs_pwrite( oe_fd_t* desc, const void* buf, size_t count, oe_off_t offset) { ssize_t ret = -1; file_t* file = _cast_file(desc); if (!file) OE_RAISE_ERRNO(OE_EINVAL); if (oe_syscall_pwrite_ocall(&ret, file->host_fd, buf, count, offset) != OE_OK) OE_RAISE_ERRNO(OE_EINVAL); done: return ret; }
0
C++
NVD-CWE-Other
Other
NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
https://nvd.nist.gov/vuln/categories
vulnerable
TfLiteStatus Relu6Eval(TfLiteContext* context, TfLiteNode* node) { const TfLiteTensor* input; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &input)); TfLiteTensor* output; TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &output)); ReluOpData* data = reinterpret_cast<ReluOpData*>(node->user_data); switch (input->type) { case kTfLiteFloat32: { size_t elements = input->bytes / sizeof(float); const float* in = GetTensorData<float>(input); const float* in_end = in + elements; float* out = GetTensorData<float>(output); for (; in < in_end; in++, out++) *out = std::min(std::max(0.f, *in), 6.f); return kTfLiteOk; } break; case kTfLiteUInt8: QuantizedReluX<uint8_t>(0.0f, 6.0f, input, output, data); return kTfLiteOk; case kTfLiteInt8: { QuantizedReluX<int8_t>(0.0f, 6.0f, input, output, data); return kTfLiteOk; } break; default: TF_LITE_KERNEL_LOG( context, "Only float32, uint8 and int8 are supported currently, got %s.", TfLiteTypeGetName(input->type)); return kTfLiteError; } }
1
C++
CWE-125
Out-of-bounds Read
The software reads data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/125.html
safe
lazy_entry const* dict_find(std::string const& name) const { return const_cast<lazy_entry*>(this)->dict_find(name); }
1
C++
CWE-119
Improper Restriction of Operations within the Bounds of a Memory Buffer
The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.
https://cwe.mitre.org/data/definitions/119.html
safe
int64_t MemFile::readImpl(char *buffer, int64_t length) { assertx(m_len != -1); assertx(length > 0); int64_t remaining = m_len - m_cursor; if (remaining < length) length = remaining; if (length > 0) { memcpy(buffer, (const void *)(m_data + m_cursor), length); } m_cursor += length; return length; }
0
C++
CWE-125
Out-of-bounds Read
The software reads data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/125.html
vulnerable
void writeStats(Array& /*ret*/) override { fprintf(stderr, "writeStats start\n"); // RetSame: the return value is the same instance every time // HasThis: call has a this argument // AllSame: all returns were the same data even though args are different // MemberCount: number of different arg sets (including this) fprintf(stderr, "Count Function MinSerLen MaxSerLen RetSame HasThis " "AllSame MemberCount\n"); for (auto& me : m_memos) { if (me.second.m_ignore) continue; if (me.second.m_count == 1) continue; int min_ser_len = 999999999; int max_ser_len = 0; int count = 0; int member_count = 0; bool all_same = true; if (me.second.m_has_this) { bool any_multiple = false; auto& fr = me.second.m_member_memos.begin()->second.m_return_value; member_count = me.second.m_member_memos.size(); for (auto& mme : me.second.m_member_memos) { if (mme.second.m_return_value != fr) all_same = false; count += mme.second.m_count; auto ser_len = mme.second.m_return_value.length(); min_ser_len = std::min<int64_t>(min_ser_len, ser_len); max_ser_len = std::max<int64_t>(max_ser_len, ser_len); if (mme.second.m_count > 1) any_multiple = true; } if (!any_multiple && !all_same) continue; } else { min_ser_len = max_ser_len = me.second.m_return_value.length(); count = me.second.m_count; all_same = me.second.m_ret_tv_same; } fprintf(stderr, "%d %s %d %d %s %s %s %d\n", count, me.first.data(), min_ser_len, max_ser_len, me.second.m_ret_tv_same ? " true" : "false", me.second.m_has_this ? " true" : "false", all_same ? " true" : "false", member_count ); } fprintf(stderr, "writeStats end\n"); }
1
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
safe
void FontData::Bound(int32_t offset, int32_t length) { // Inputs should not be negative. CHECK(offset >= 0); CHECK(length >= 0); // Check to make sure |bound_offset_| will not overflow. CHECK(bound_offset_ <= std::numeric_limits<int32_t>::max() - offset); const int32_t new_offset = bound_offset_ + offset; if (length == GROWABLE_SIZE) { // When |length| has the special value of GROWABLE_SIZE, it means the size // should not have any artificial limits, thus it is just the underlying // |array_|'s size. Just make sure |new_offset| is still within bounds. CHECK(new_offset <= array_->Size()); } else { // When |length| has any other value, |new_offset| + |length| points to the // end of the array. Make sure that is within bounds, but use subtraction to // avoid an integer overflow. CHECK(new_offset <= array_->Size() - length); } bound_offset_ = new_offset; bound_length_ = length; }
1
C++
CWE-189
Numeric Errors
Weaknesses in this category are related to improper calculation or conversion of numbers.
https://cwe.mitre.org/data/definitions/189.html
safe
BOOL nego_process_negotiation_failure(rdpNego* nego, wStream* s) { BYTE flags; UINT16 length; UINT32 failureCode; WLog_DBG(TAG, "RDP_NEG_FAILURE"); if (Stream_GetRemainingLength(s) < 7) return FALSE; Stream_Read_UINT8(s, flags); Stream_Read_UINT16(s, length); Stream_Read_UINT32(s, failureCode); switch (failureCode) { case SSL_REQUIRED_BY_SERVER: WLog_WARN(TAG, "Error: SSL_REQUIRED_BY_SERVER"); break; case SSL_NOT_ALLOWED_BY_SERVER: WLog_WARN(TAG, "Error: SSL_NOT_ALLOWED_BY_SERVER"); nego->sendNegoData = TRUE; break; case SSL_CERT_NOT_ON_SERVER: WLog_ERR(TAG, "Error: SSL_CERT_NOT_ON_SERVER"); nego->sendNegoData = TRUE; break; case INCONSISTENT_FLAGS: WLog_ERR(TAG, "Error: INCONSISTENT_FLAGS"); break; case HYBRID_REQUIRED_BY_SERVER: WLog_WARN(TAG, "Error: HYBRID_REQUIRED_BY_SERVER"); break; default: WLog_ERR(TAG, "Error: Unknown protocol security error %" PRIu32 "", failureCode); break; } nego->state = NEGO_STATE_FAIL; return TRUE; }
1
C++
CWE-125
Out-of-bounds Read
The software reads data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/125.html
safe
const String& setSize(int len) { assertx(m_str); m_str->setSize(len); return *this; }
0
C++
CWE-125
Out-of-bounds Read
The software reads data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/125.html
vulnerable
bool AdminRequestHandler::handleDumpStaticStringsRequest(folly::File& file) { auto const& list = lookupDefinedStaticStrings(); for (auto item : list) { auto const line = formatStaticString(item); folly::writeFull(file.fd(), line.data(), line.size()); if (RuntimeOption::EvalPerfDataMap) { auto const len = std::min<size_t>(item->size(), 255); std::string str(item->data(), len); // Only print the first line (up to 255 characters). Since we want '\0' in // the list of characters to avoid, we need to use the version of // `find_first_of()' with explicit length. auto cutOffPos = str.find_first_of("\r\n", 0, 3); if (cutOffPos != std::string::npos) str.erase(cutOffPos); Debug::DebugInfo::recordDataMap(item->mutableData(), item->mutableData() + item->size(), "Str-" + str); } } return true; }
1
C++
CWE-22
Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
The software uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the software does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
https://cwe.mitre.org/data/definitions/22.html
safe
TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { // Just copy input to output. const TfLiteTensor* input; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInput, &input)); TfLiteTensor* output; TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &output)); const TfLiteTensor* axis; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kAxis, &axis)); if (IsDynamicTensor(output)) { int axis_value; TF_LITE_ENSURE_OK(context, GetAxisValueFromTensor(context, *axis, &axis_value)); TF_LITE_ENSURE_OK(context, ExpandTensorDim(context, *input, axis_value, output)); } if (output->type == kTfLiteString) { TfLiteTensorRealloc(input->bytes, output); } memcpy(output->data.raw, input->data.raw, input->bytes); return kTfLiteOk; }
1
C++
CWE-125
Out-of-bounds Read
The software reads data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/125.html
safe
bool IsFullyConnectedOpSupported(const TfLiteRegistration* registration, const TfLiteNode* node, TfLiteContext* context) { if (node->builtin_data == nullptr) return false; const auto* fc_params = reinterpret_cast<const TfLiteFullyConnectedParams*>(node->builtin_data); const int kInput = 0; const int kWeights = 1; const int kBias = 2; if (fc_params->weights_format != kTfLiteFullyConnectedWeightsFormatDefault) { return false; } const TfLiteTensor* input; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInput, &input)); const TfLiteTensor* weights; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kWeights, &weights)); if (!IsFloatType(input->type)) { return false; } if (!IsFloatType(weights->type) || !IsConstantTensor(weights)) { return false; } // Core ML 2 only supports single-batch fully connected layer, thus dimensions // except the last one should be 1. if (input->dims->data[input->dims->size - 1] != NumElements(input)) { return false; } if (node->inputs->size > 2) { const TfLiteTensor* bias; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kBias, &bias)); if (!IsFloatType(bias->type) || !IsConstantTensor(bias)) { return false; } } TfLiteFusedActivation activation = fc_params->activation; if (activation == kTfLiteActSignBit) { return false; } return true; }
1
C++
CWE-125
Out-of-bounds Read
The software reads data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/125.html
safe
int Read(void* pDestBuffer, int nSize) { if ( m_nPos + nSize >= m_nLen ) nSize = m_nLen - m_nPos - 1; memcpy( pDestBuffer, (m_sFile + m_nPos), nSize ); m_nPos += nSize; return nSize; }
0
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
vulnerable
void send( char* str ) { fprintf(outfile, "%s",str); }
1
C++
NVD-CWE-noinfo
null
null
null
safe
bool jas_image_cmpt_domains_same(jas_image_t *image) { int cmptno; jas_image_cmpt_t *cmpt; jas_image_cmpt_t *cmpt0; cmpt0 = image->cmpts_[0]; for (cmptno = 1; cmptno < image->numcmpts_; ++cmptno) { cmpt = image->cmpts_[cmptno]; if (cmpt->tlx_ != cmpt0->tlx_ || cmpt->tly_ != cmpt0->tly_ || cmpt->hstep_ != cmpt0->hstep_ || cmpt->vstep_ != cmpt0->vstep_ || cmpt->width_ != cmpt0->width_ || cmpt->height_ != cmpt0->height_) { return 0; } } return 1; }
1
C++
NVD-CWE-Other
Other
NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
https://nvd.nist.gov/vuln/categories
safe
inline int check(int itemSize, int nItems=1, bool wait=true) { if (ptr + itemSize * nItems > end) { if (ptr + itemSize > end) return overrun(itemSize, nItems, wait); nItems = (end - ptr) / itemSize; } return nItems; }
0
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
vulnerable
TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { TF_LITE_ENSURE_EQ(context, NumInputs(node), 2); // TODO(b/137042749): TFLite infrastructure (converter, delegate) doesn't // fully support 0-output ops yet. Currently it works if we manually crfat // a TFLite graph that contains variable ops. Note: // * The TFLite Converter need to be changed to be able to produce an op // with 0 output. // * The delegation code need to be changed to handle 0 output ops. However // everything still works fine when variable ops aren't used. TF_LITE_ENSURE_EQ(context, NumOutputs(node), 0); const TfLiteTensor* input_resource_id_tensor; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputVariableId, &input_resource_id_tensor)); TF_LITE_ENSURE_EQ(context, input_resource_id_tensor->type, kTfLiteInt32); TF_LITE_ENSURE_EQ(context, NumElements(input_resource_id_tensor), 1); return kTfLiteOk; }
1
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
safe
TfLiteRegistration OkOpRegistration() { TfLiteRegistration reg = {nullptr, nullptr, nullptr, nullptr}; // Set output size to the input size in OkOp::Prepare(). Code exists to have // a framework in Prepare. The input and output tensors are not used. reg.prepare = [](TfLiteContext* context, TfLiteNode* node) { const TfLiteTensor* in_tensor; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &in_tensor)); TfLiteTensor* out_tensor; TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &out_tensor)); TfLiteIntArray* new_size = TfLiteIntArrayCopy(in_tensor->dims); return context->ResizeTensor(context, out_tensor, new_size); }; reg.invoke = [](TfLiteContext* context, TfLiteNode* node) { return kTfLiteOk; }; return reg; }
1
C++
CWE-125
Out-of-bounds Read
The software reads data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/125.html
safe
std::string RestAuthHandler::generateJwt(std::string const& username, std::string const& password) { AuthenticationFeature* af = AuthenticationFeature::instance(); TRI_ASSERT(af != nullptr); return fuerte::jwt::generateUserToken(af->tokenCache().jwtSecret(), username, _validFor); }
0
C++
CWE-613
Insufficient Session Expiration
According to WASC, "Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization."
https://cwe.mitre.org/data/definitions/613.html
vulnerable
void AcceptRoutingHandler<Pipeline, R>::onRoutingData( uint64_t connId, typename RoutingDataHandler<R>::RoutingData& routingData) { // Get the routing pipeline corresponding to this connection auto routingPipelineIter = routingPipelines_.find(connId); if (routingPipelineIter == routingPipelines_.end()) { VLOG(2) << "Connection has already been closed, " "or routed to a worker thread."; return; } auto routingPipeline = std::move(routingPipelineIter->second); routingPipelines_.erase(routingPipelineIter); // Fetch the socket from the pipeline and pause reading from the // socket auto socket = std::dynamic_pointer_cast<folly::AsyncSocket>( routingPipeline->getTransport()); routingPipeline->transportInactive(); socket->detachEventBase(); // Hash based on routing data to pick a new acceptor uint64_t hash = std::hash<R>()(routingData.routingData); auto acceptor = acceptors_[hash % acceptors_.size()]; // Switch to the new acceptor's thread acceptor->getEventBase()->runInEventBaseThread( [ =, routingData = std::move(routingData) ]() mutable { socket->attachEventBase(acceptor->getEventBase()); auto routingHandler = routingPipeline->template getHandler<RoutingDataHandler<R>>(); DCHECK(routingHandler); auto transportInfo = routingPipeline->getTransportInfo(); auto pipeline = childPipelineFactory_->newPipeline( socket, routingData.routingData, routingHandler, transportInfo); auto connection = new typename ServerAcceptor<Pipeline>::ServerConnection(pipeline); acceptor->addConnection(connection); pipeline->transportActive(); // Pass in the buffered bytes to the pipeline pipeline->read(routingData.bufQueue); }); }
0
C++
CWE-19
Data Processing Errors
Weaknesses in this category are typically found in functionality that processes data. Data processing is the manipulation of input to retrieve or save information.
https://cwe.mitre.org/data/definitions/19.html
vulnerable
bool ArcMemory::Seek(int64 Offset,int Method) { if (!Loaded) return false; if (Method==SEEK_SET) SeekPos=Min(Offset,ArcData.Size()); else if (Method==SEEK_CUR || Method==SEEK_END) { if (Method==SEEK_END) SeekPos=ArcData.Size(); SeekPos+=(uint64)Offset; if (SeekPos>ArcData.Size()) SeekPos=Offset<0 ? 0 : ArcData.Size(); } return true; }
1
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
safe
inline bool loadModule(const char* filename, IR::Module& outModule) { // Read the specified file into an array. std::vector<U8> fileBytes; if(!loadFile(filename, fileBytes)) { return false; } // If the file starts with the WASM binary magic number, load it as a binary irModule. if(*(U32*)fileBytes.data() == 0x6d736100) { return loadBinaryModule(fileBytes.data(), fileBytes.size(), outModule); } else { // Make sure the WAST file is null terminated. fileBytes.push_back(0); // Load it as a text irModule. std::vector<WAST::Error> parseErrors; if(!WAST::parseModule( (const char*)fileBytes.data(), fileBytes.size(), outModule, parseErrors)) { Log::printf(Log::error, "Error parsing WebAssembly text file:\n"); reportParseErrors(filename, parseErrors); return false; } return true; } }
0
C++
CWE-125
Out-of-bounds Read
The software reads data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/125.html
vulnerable
void operator()(OpKernelContext* ctx, const TensorShape& segment_ids_shape, typename TTypes<Index>::ConstFlat segment_ids, typename TTypes<T, 2>::ConstTensor data, typename TTypes<T, 2>::Tensor output) { if (output.size() == 0) { return; } // Set 'output' to initial value. GPUDevice d = ctx->template eigen_device<GPUDevice>(); GpuLaunchConfig config = GetGpuLaunchConfig(output.size(), d); TF_CHECK_OK(GpuLaunchKernel( SetToValue<T>, config.block_count, config.thread_per_block, 0, d.stream(), output.size(), output.data(), InitialValueF()())); const int64 data_size = data.size(); if (data_size == 0 || segment_ids_shape.num_elements() == 0) { return; } // Launch kernel to compute unsorted segment reduction. // Notes: // *) 'data_size' is the total number of elements to process. // *) 'segment_ids.shape' is a prefix of data's shape. // *) 'input_outer_dim_size' is the total number of segments to process. const int64 input_outer_dim_size = segment_ids.dimension(0); const int64 input_inner_dim_size = data.dimension(1); const int64 output_outer_dim_size = output.dimension(0); config = GetGpuLaunchConfig(data_size, d); TF_CHECK_OK(GpuLaunchKernel( UnsortedSegmentCustomKernel<T, Index, ReductionF>, config.block_count, config.thread_per_block, 0, d.stream(), input_outer_dim_size, input_inner_dim_size, output_outer_dim_size, segment_ids.data(), data.data(), output.data())); }
1
C++
CWE-681
Incorrect Conversion between Numeric Types
When converting from one data type to another, such as long to integer, data can be omitted or translated in a way that produces unexpected values. If the resulting values are used in a sensitive context, then dangerous behaviors may occur.
https://cwe.mitre.org/data/definitions/681.html
safe
TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { auto* params = reinterpret_cast<TfLiteSpaceToDepthParams*>(node->builtin_data); TF_LITE_ENSURE_EQ(context, NumInputs(node), 1); TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1); const TfLiteTensor* input; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input)); TfLiteTensor* output; TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, kOutputTensor, &output)); TF_LITE_ENSURE_EQ(context, NumDimensions(input), 4); auto data_type = output->type; TF_LITE_ENSURE(context, data_type == kTfLiteFloat32 || data_type == kTfLiteUInt8 || data_type == kTfLiteInt8 || data_type == kTfLiteInt32 || data_type == kTfLiteInt64); TF_LITE_ENSURE_TYPES_EQ(context, input->type, output->type); const int block_size = params->block_size; TF_LITE_ENSURE(context, block_size > 0); const int input_height = input->dims->data[1]; const int input_width = input->dims->data[2]; int output_height = input_height / block_size; int output_width = input_width / block_size; TF_LITE_ENSURE_EQ(context, input_height, output_height * block_size); TF_LITE_ENSURE_EQ(context, input_width, output_width * block_size); TfLiteIntArray* output_size = TfLiteIntArrayCreate(4); output_size->data[0] = input->dims->data[0]; output_size->data[1] = output_height; output_size->data[2] = output_width; output_size->data[3] = input->dims->data[3] * block_size * block_size; return context->ResizeTensor(context, output, output_size); }
1
C++
CWE-369
Divide By Zero
The product divides a value by zero.
https://cwe.mitre.org/data/definitions/369.html
safe
static void nodeDestruct(struct SaveNode* node) { if (node->v == &node->sorted) { tr_free(node->sorted.val.l.vals); } }
0
C++
CWE-416
Use After Free
Referencing memory after it has been freed can cause a program to crash, use unexpected values, or execute code.
https://cwe.mitre.org/data/definitions/416.html
vulnerable
CAMLprim value caml_bitvect_test(value bv, value n) { intnat pos = Long_val(n); return Val_int(Byte_u(bv, pos >> 3) & (1 << (pos & 7))); }
1
C++
CWE-119
Improper Restriction of Operations within the Bounds of a Memory Buffer
The software performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.
https://cwe.mitre.org/data/definitions/119.html
safe
TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { TF_LITE_ENSURE_EQ(context, NumInputs(node), 1); TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1); const TfLiteTensor* input; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input)); TfLiteIntArray* input_dims = input->dims; int input_dims_size = input_dims->size; TF_LITE_ENSURE(context, input_dims_size >= 1); TfLiteTensor* output; TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, kOutputTensor, &output)); // Resize the output tensor. TfLiteIntArray* output_shape = TfLiteIntArrayCreate(input_dims_size + 1); for (int i = 0; i < input_dims_size; i++) { output_shape->data[i] = input_dims->data[i]; } // Last dimension in the output is the same as the last dimension in the // input. output_shape->data[input_dims_size] = input_dims->data[input_dims_size - 1]; output->type = input->type; TF_LITE_ENSURE_OK(context, context->ResizeTensor(context, output, output_shape)); return kTfLiteOk; }
1
C++
CWE-125
Out-of-bounds Read
The software reads data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/125.html
safe
FastCGIServer::FastCGIServer(const std::string &address, int port, int workers, bool useFileSocket) : Server(address, port), m_worker(&m_eventBaseManager), m_dispatcher(workers, workers, RuntimeOption::ServerThreadDropCacheTimeoutSeconds, RuntimeOption::ServerThreadDropStack, this, RuntimeOption::ServerThreadJobLIFOSwitchThreshold, RuntimeOption::ServerThreadJobMaxQueuingMilliSeconds, RequestPriority::k_numPriorities) { folly::SocketAddress sock_addr; if (useFileSocket) { sock_addr.setFromPath(address); } else if (address.empty()) { sock_addr.setFromHostPort("localhost", port); assert(sock_addr.isLoopbackAddress()); } else { sock_addr.setFromHostPort(address, port); } m_socketConfig.bindAddress = sock_addr; m_socketConfig.acceptBacklog = RuntimeOption::ServerBacklog; std::chrono::seconds timeout; if (RuntimeOption::ConnectionTimeoutSeconds >= 0) { timeout = std::chrono::seconds(RuntimeOption::ConnectionTimeoutSeconds); } else { // default to 2 minutes timeout = std::chrono::seconds(120); } m_socketConfig.connectionIdleTimeout = timeout; }
1
C++
CWE-668
Exposure of Resource to Wrong Sphere
The product exposes a resource to the wrong control sphere, providing unintended actors with inappropriate access to the resource.
https://cwe.mitre.org/data/definitions/668.html
safe
static int StreamTcpTest10 (void) { Packet *p = SCMalloc(SIZE_OF_PACKET); FAIL_IF(unlikely(p == NULL)); Flow f; ThreadVars tv; StreamTcpThread stt; TCPHdr tcph; uint8_t payload[4]; memset(p, 0, SIZE_OF_PACKET); PacketQueue pq; memset(&pq,0,sizeof(PacketQueue)); memset (&f, 0, sizeof(Flow)); memset(&tv, 0, sizeof (ThreadVars)); memset(&stt, 0, sizeof (StreamTcpThread)); memset(&tcph, 0, sizeof (TCPHdr)); FLOW_INITIALIZE(&f); p->flow = &f; StreamTcpUTInit(&stt.ra_ctx); stream_config.async_oneside = TRUE; tcph.th_win = htons(5480); tcph.th_seq = htonl(10); tcph.th_ack = 0; tcph.th_flags = TH_SYN; p->tcph = &tcph; FAIL_IF(StreamTcpPacket(&tv, p, &stt, &pq) == -1); p->tcph->th_seq = htonl(11); p->tcph->th_ack = htonl(11); p->tcph->th_flags = TH_ACK; p->flowflags = FLOW_PKT_TOSERVER; FAIL_IF(StreamTcpPacket(&tv, p, &stt, &pq) == -1); p->tcph->th_seq = htonl(11); p->tcph->th_ack = htonl(11); p->tcph->th_flags = TH_ACK|TH_PUSH; p->flowflags = FLOW_PKT_TOSERVER; StreamTcpCreateTestPacket(payload, 0x42, 3, 4); /*BBB*/ p->payload = payload; p->payload_len = 3; FAIL_IF(StreamTcpPacket(&tv, p, &stt, &pq) == -1); p->tcph->th_seq = htonl(6); p->tcph->th_ack = htonl(11); p->tcph->th_flags = TH_ACK|TH_PUSH; p->flowflags = FLOW_PKT_TOSERVER; StreamTcpCreateTestPacket(payload, 0x42, 3, 4); /*BBB*/ p->payload = payload; p->payload_len = 3; FAIL_IF(StreamTcpPacket(&tv, p, &stt, &pq) == -1); FAIL_IF(((TcpSession *)(p->flow->protoctx))->state != TCP_ESTABLISHED); FAIL_IF(! (((TcpSession *)(p->flow->protoctx))->flags & STREAMTCP_FLAG_ASYNC)); FAIL_IF(((TcpSession *)(p->flow->protoctx))->client.last_ack != 6 && ((TcpSession *)(p->flow->protoctx))->server.next_seq != 11); StreamTcpSessionClear(p->flow->protoctx); SCFree(p); FLOW_DESTROY(&f); StreamTcpUTDeinit(stt.ra_ctx); PASS; }
1
C++
CWE-436
Interpretation Conflict
Product A handles inputs or steps differently than Product B, which causes A to perform incorrect actions based on its perception of B's state.
https://cwe.mitre.org/data/definitions/436.html
safe
TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { const TfLiteTensor* input = GetInput(context, node, kInputTensor); const TfLiteTensor* fft_length = GetInput(context, node, kFftLengthTensor); const int32_t* fft_length_data = GetTensorData<int32_t>(fft_length); TfLiteTensor* output = GetOutput(context, node, kOutputTensor); if (output->type != kTfLiteComplex64) { context->ReportError(context, "Type '%s' for output is not supported by rfft2d.", TfLiteTypeGetName(output->type)); return kTfLiteError; } // Resize the output tensor if the fft_length tensor is not constant. // Otherwise, check if the output shape is correct. if (!IsConstantTensor(fft_length)) { TF_LITE_ENSURE_STATUS(ResizeOutputandTemporaryTensors(context, node)); } else { int num_dims_output = NumDimensions(output); const RuntimeShape output_shape = GetTensorShape(output); TF_LITE_ENSURE_EQ(context, num_dims_output, NumDimensions(input)); TF_LITE_ENSURE(context, num_dims_output >= 2); TF_LITE_ENSURE_EQ(context, output_shape.Dims(num_dims_output - 2), fft_length_data[0]); TF_LITE_ENSURE_EQ(context, output_shape.Dims(num_dims_output - 1), fft_length_data[1] / 2 + 1); } return Rfft2dHelper(context, node); }
0
C++
CWE-787
Out-of-bounds Write
The software writes data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/787.html
vulnerable
DeletionConfirmationDlg(QWidget *parent, const int &size, const QString &name, bool defaultDeleteFiles): QDialog(parent) { setupUi(this); if (size == 1) label->setText(tr("Are you sure you want to delete '%1' from the transfer list?", "Are you sure you want to delete 'ubuntu-linux-iso' from the transfer list?").arg(Utils::String::toHtmlEscaped(name))); else label->setText(tr("Are you sure you want to delete these %1 torrents from the transfer list?", "Are you sure you want to delete these 5 torrents from the transfer list?").arg(QString::number(size))); // Icons lbl_warn->setPixmap(GuiIconProvider::instance()->getIcon("dialog-warning").pixmap(lbl_warn->height())); lbl_warn->setFixedWidth(lbl_warn->height()); rememberBtn->setIcon(GuiIconProvider::instance()->getIcon("object-locked")); move(Utils::Misc::screenCenter(this)); checkPermDelete->setChecked(defaultDeleteFiles || Preferences::instance()->deleteTorrentFilesAsDefault()); connect(checkPermDelete, SIGNAL(clicked()), this, SLOT(updateRememberButtonState())); buttonBox->button(QDialogButtonBox::Cancel)->setFocus(); }
1
C++
CWE-79
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
https://cwe.mitre.org/data/definitions/79.html
safe
inline TfLiteIntArray* GetOutputShapeFromTensor(TfLiteContext* context, TfLiteNode* node) { const TfLiteTensor* shape = GetInput(context, node, kShapeTensor); if (shape == nullptr) return nullptr; TfLiteIntArray* output_shape = TfLiteIntArrayCreate(shape->dims->data[0]); for (int i = 0; i < output_shape->size; ++i) { output_shape->data[i] = shape->data.i32[i]; } return output_shape; }
1
C++
CWE-125
Out-of-bounds Read
The software reads data past the end, or before the beginning, of the intended buffer.
https://cwe.mitre.org/data/definitions/125.html
safe
void SetColor(double c, double m, double y, double k,int par) { if ( par == STROKING ) { outpos += sprintf(outpos," %12.3f %12.3f %12.3f %12.3f K",c,m,y,k); } else { outpos += sprintf(outpos," %12.3f %12.3f %12.3f %12.3f k",c,m,y,k); } }
0
C++
NVD-CWE-noinfo
null
null
null
vulnerable
void TensorSliceReader::LoadShard(int shard) const { CHECK_LT(shard, sss_.size()); if (sss_[shard] || !status_.ok()) { return; // Already loaded, or invalid. } string value; SavedTensorSlices sts; const string fname = fnames_[shard]; VLOG(1) << "Reading meta data from file " << fname << "..."; Table* table; Status s = open_function_(fname, &table); if (!s.ok()) { status_ = errors::DataLoss("Unable to open table file ", fname, ": ", s.ToString()); return; } sss_[shard].reset(table); if (!(table->Get(kSavedTensorSlicesKey, &value) && ParseProtoUnlimited(&sts, value))) { status_ = errors::Internal( "Failed to find the saved tensor slices at the beginning of the " "checkpoint file: ", fname); return; } status_ = CheckVersions(sts.meta().versions(), TF_CHECKPOINT_VERSION, TF_CHECKPOINT_VERSION_MIN_PRODUCER, "Checkpoint", "checkpoint"); if (!status_.ok()) return; for (const SavedSliceMeta& ssm : sts.meta().tensor()) { TensorShape ssm_shape(ssm.shape()); for (const TensorSliceProto& tsp : ssm.slice()) { TensorSlice ss_slice(tsp); status_ = RegisterTensorSlice(ssm.name(), ssm_shape, ssm.type(), fname, ss_slice, &tensors_); if (!status_.ok()) return; } } }
0
C++
CWE-345
Insufficient Verification of Data Authenticity
The software does not sufficiently verify the origin or authenticity of data, in a way that causes it to accept invalid data.
https://cwe.mitre.org/data/definitions/345.html
vulnerable