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 Compute(OpKernelContext* ctx) override { const auto splits = ctx->input(0).flat<int64>(); const auto values = ctx->input(1).flat<Tidx>(); const Tensor& size_t = ctx->input(2); const auto weights = ctx->input(3).flat<T>(); const int64 weights_size = weights.size(); Tidx size = size_t.scalar<Tidx>()(); OP_REQUIRES( ctx, size >= 0, errors::InvalidArgument("size (", size, ") must be non-negative")); int num_rows = splits.size() - 1; int num_values = values.size(); int batch_idx = 0; OP_REQUIRES(ctx, splits(0) == 0, errors::InvalidArgument("Splits must start with 0, not with ", splits(0))); OP_REQUIRES(ctx, splits(num_rows) == num_values, errors::InvalidArgument( "Splits must end with the number of values, got ", splits(num_rows), " instead of ", num_values)); Tensor* out_t; OP_REQUIRES_OK( ctx, ctx->allocate_output(0, TensorShape({num_rows, size}), &out_t)); functor::SetZeroFunctor<Device, T> fill; fill(ctx->eigen_device<Device>(), out_t->flat<T>()); const auto out = out_t->matrix<T>(); for (int idx = 0; idx < num_values; ++idx) { while (idx >= splits(batch_idx)) { batch_idx++; } Tidx bin = values(idx); OP_REQUIRES(ctx, bin >= 0, errors::InvalidArgument("Input must be non-negative")); if (bin < size) { if (binary_output_) { out(batch_idx - 1, bin) = T(1); } else { T value = (weights_size > 0) ? weights(idx) : T(1); out(batch_idx - 1, bin) += value; } } } }
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
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-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
void ecall_sample(uint8_t *input_rows, size_t input_rows_length, uint8_t **output_rows, size_t *output_rows_length) { // Guard against operating on arbitrary enclave memory assert(sgx_is_outside_enclave(input_rows, input_rows_length) == 1); sgx_lfence(); try { sample(input_rows, input_rows_length, output_rows, output_rows_length); } catch (const std::runtime_error &e) { ocall_throw(e.what()); } }
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
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
R_API RBinJavaAttrInfo *r_bin_java_source_code_file_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) { if (!sz) { return NULL; } ut64 offset = 0; RBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset); offset += 6; if (!attr) { return NULL; } attr->type = R_BIN_JAVA_ATTR_TYPE_SOURCE_FILE_ATTR; // if (buffer + offset > buffer + sz) return NULL; 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; }
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
bool MemFile::seek(int64_t offset, int whence /* = SEEK_SET */) { assertx(m_len != -1); if (whence == SEEK_CUR) { if (offset >= 0 && offset < bufferedLen()) { setReadPosition(getReadPosition() + offset); setPosition(getPosition() + offset); return true; } offset += getPosition(); whence = SEEK_SET; } // invalidate the current buffer setWritePosition(0); setReadPosition(0); if (whence == SEEK_SET) { if (offset < 0) return false; m_cursor = offset; } else if (whence == SEEK_END) { if (m_len + offset < 0) return false; m_cursor = m_len + offset; } else { return false; } setPosition(m_cursor); 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
static inline long decode_twos_comp(ulong c, int prec) { long result; assert(prec >= 2); jas_eprintf("warning: support for signed data is untested\n"); // NOTE: Is this correct? result = (c & ((1 << (prec - 1)) - 1)) - (c & (1 << (prec - 1))); return result; }
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
TfLiteStatus LeakyReluEval(TfLiteContext* context, TfLiteNode* node) { const TfLiteTensor* input = GetInput(context, node, 0); TfLiteTensor* output = GetOutput(context, node, 0); const auto* params = reinterpret_cast<TfLiteLeakyReluParams*>(node->builtin_data); const LeakyReluOpData* data = reinterpret_cast<LeakyReluOpData*>(node->user_data); LeakyReluParams op_params; switch (input->type) { case kTfLiteFloat32: { op_params.alpha = params->alpha; optimized_ops::LeakyRelu( op_params, GetTensorShape(input), GetTensorData<float>(input), GetTensorShape(output), GetTensorData<float>(output)); return kTfLiteOk; } break; case kTfLiteUInt8: { QuantizeLeakyRelu<uint8_t>(input, output, data); return kTfLiteOk; } break; case kTfLiteInt8: { QuantizeLeakyRelu<int8_t>(input, output, data); return kTfLiteOk; } break; case kTfLiteInt16: { QuantizeLeakyRelu<int16_t>(input, output, data); return kTfLiteOk; } break; default: TF_LITE_KERNEL_LOG( context, "Only float32, int8, int16 and uint8 is supported currently, got %s.", TfLiteTypeGetName(input->type)); return kTfLiteError; } }
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 NonMaxSuppressionMultiClass(TfLiteContext* context, TfLiteNode* node, OpData* op_data) { // Get the input tensors const TfLiteTensor* input_box_encodings; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensorBoxEncodings, &input_box_encodings)); const TfLiteTensor* input_class_predictions; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensorClassPredictions, &input_class_predictions)); const int num_boxes = input_box_encodings->dims->data[1]; const int num_classes = op_data->num_classes; TF_LITE_ENSURE_EQ(context, input_class_predictions->dims->data[0], kBatchSize); TF_LITE_ENSURE_EQ(context, input_class_predictions->dims->data[1], num_boxes); const int num_classes_with_background = input_class_predictions->dims->data[2]; TF_LITE_ENSURE(context, (num_classes_with_background - num_classes <= 1)); TF_LITE_ENSURE(context, (num_classes_with_background >= num_classes)); const TfLiteTensor* scores; switch (input_class_predictions->type) { case kTfLiteUInt8: { TfLiteTensor* temporary_scores = &context->tensors[op_data->scores_index]; DequantizeClassPredictions(input_class_predictions, num_boxes, num_classes_with_background, temporary_scores); scores = temporary_scores; } break; case kTfLiteFloat32: scores = input_class_predictions; break; default: // Unsupported type. return kTfLiteError; } if (op_data->use_regular_non_max_suppression) TF_LITE_ENSURE_STATUS(NonMaxSuppressionMultiClassRegularHelper( context, node, op_data, GetTensorData<float>(scores))); else TF_LITE_ENSURE_STATUS(NonMaxSuppressionMultiClassFastHelper( context, node, op_data, GetTensorData<float>(scores))); 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
static gboolean cosine_read(wtap *wth, int *err, gchar **err_info, gint64 *data_offset) { gint64 offset; char line[COSINE_LINE_LENGTH]; /* Find the next packet */ offset = cosine_seek_next_packet(wth, err, err_info, line); if (offset < 0) return FALSE; *data_offset = offset; /* Parse the header and convert the ASCII hex dump to binary data */ return parse_cosine_packet(wth->fh, &wth->phdr, wth->frame_buffer, line, err, err_info); }
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), 2); TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1); // Reinterprete the opaque data provided by user. OpData* data = reinterpret_cast<OpData*>(node->user_data); const TfLiteTensor* input1; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor1, &input1)); const TfLiteTensor* input2; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor2, &input2)); TfLiteTensor* output; TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, kOutputTensor, &output)); TF_LITE_ENSURE_TYPES_EQ(context, input1->type, input2->type); const TfLiteType type = input1->type; if (type != kTfLiteBool) { context->ReportError(context, "Logical ops only support bool type."); return kTfLiteError; } output->type = type; data->requires_broadcast = !HaveSameShapes(input1, input2); TfLiteIntArray* output_size = nullptr; if (data->requires_broadcast) { TF_LITE_ENSURE_OK(context, CalculateShapeForBroadcast( context, input1, input2, &output_size)); } else { output_size = TfLiteIntArrayCopy(input1->dims); } return context->ResizeTensor(context, output, output_size); }
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
static const char* ConvertScalar(PyObject* v, Eigen::half* out) { return ConvertOneFloat<Eigen::half>(v, out); }
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
void HeaderTable::setCapacity(uint32_t capacity) { auto oldCapacity = capacity_; capacity_ = capacity; if (capacity_ <= oldCapacity) { evict(0); } else { auto oldTail = tail(); auto oldLength = table_.size(); uint32_t newLength = (capacity_ >> 5) + 1; table_.resize(newLength); if (size_ > 0 && oldTail > head_) { // the list wrapped around, need to move oldTail..oldLength to the end of // the now-larger table_ std::copy(table_.begin() + oldTail, table_.begin() + oldLength, table_.begin() + newLength - (oldLength - oldTail)); // Update the names indecies that pointed to the old range for (auto& names_it: names_) { for (auto& idx: names_it.second) { if (idx >= oldTail) { DCHECK_LT(idx + (table_.size() - oldLength), table_.size()); idx += (table_.size() - oldLength); } else { // remaining indecies in the list were smaller than oldTail, so // should be indexed from 0 break; } } } } } }
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
TEST_F(SingleAllowMissingInOrListTest, MissingIssToken) { EXPECT_CALL(mock_cb_, onComplete(Status::Ok)); auto headers = Http::TestRequestHeaderMapImpl{{kExampleHeader, ES256WithoutIssToken}}; context_ = Verifier::createContext(headers, parent_span_, &mock_cb_); verifier_->verify(context_); EXPECT_THAT(headers, JwtOutputFailedOrIgnore(kExampleHeader)); }
0
C++
CWE-303
Incorrect Implementation of Authentication Algorithm
The requirements for the software dictate the use of an established authentication algorithm, but the implementation of the algorithm is incorrect.
https://cwe.mitre.org/data/definitions/303.html
vulnerable
static int em_ret_near_imm(struct x86_emulate_ctxt *ctxt) { int rc; unsigned long eip; rc = emulate_pop(ctxt, &eip, ctxt->op_bytes); if (rc != X86EMUL_CONTINUE) return rc; rc = assign_eip_near(ctxt, eip); if (rc != X86EMUL_CONTINUE) return rc; rsp_increment(ctxt, ctxt->src.val); return X86EMUL_CONTINUE; }
1
C++
NVD-CWE-noinfo
null
null
null
safe
ArcMemory::ArcMemory() { Loaded=false; SeekPos=0; }
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 pointZZ_pAdd(PointZZ_p * rop, const PointZZ_p * op1, const PointZZ_p * op2, const CurveZZ_p * curve) { mpz_t xdiff, ydiff, lambda; mpz_inits(xdiff, ydiff, lambda, NULL); // calculate lambda mpz_sub(ydiff, op2->y, op1->y); mpz_sub(xdiff, op2->x, op1->x); mpz_invert(xdiff, xdiff, curve->p); // TODO check status mpz_mul(lambda, ydiff, xdiff); mpz_mod(lambda, lambda, curve->p); // calculate resulting x coord mpz_mul(rop->x, lambda, lambda); mpz_sub(rop->x, rop->x, op1->x); mpz_sub(rop->x, rop->x, op2->x); mpz_mod(rop->x, rop->x, curve->p); //calculate resulting y coord mpz_sub(rop->y, op1->x, rop->x); mpz_mul(rop->y, lambda, rop->y); mpz_sub(rop->y, rop->y, op1->y); mpz_mod(rop->y, rop->y, curve->p); mpz_clears(xdiff, ydiff, lambda, NULL); }
0
C++
CWE-347
Improper Verification of Cryptographic Signature
The software does not verify, or incorrectly verifies, the cryptographic signature for data.
https://cwe.mitre.org/data/definitions/347.html
vulnerable
TfLiteStatus Gather(TfLiteContext* context, const TfLiteGatherParams& params, const TfLiteTensor* input, const TfLiteTensor* positions, TfLiteTensor* output) { const PositionsT* indexes = GetTensorData<PositionsT>(positions); bool indices_has_only_positive_elements = true; const size_t num_indices = positions->bytes / sizeof(PositionsT); for (size_t i = 0; i < num_indices; i++) { if (indexes[i] < 0) { indices_has_only_positive_elements = false; break; } } TF_LITE_ENSURE(context, indices_has_only_positive_elements); tflite::GatherParams op_params; op_params.axis = params.axis; op_params.batch_dims = params.batch_dims; optimized_ops::Gather(op_params, GetTensorShape(input), GetTensorData<InputT>(input), GetTensorShape(positions), GetTensorData<PositionsT>(positions), GetTensorShape(output), GetTensorData<InputT>(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
TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { const TfLiteTensor* input; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &input)); switch (input->type) { case kTfLiteFloat32: return EvalImpl<kernel_type, kTfLiteFloat32>(context, node); case kTfLiteUInt8: return EvalImpl<kernel_type, kTfLiteUInt8>(context, node); case kTfLiteInt8: return EvalImpl<kernel_type, kTfLiteInt8>(context, node); case kTfLiteInt16: return EvalImpl<kernel_type, kTfLiteInt16>(context, node); default: TF_LITE_KERNEL_LOG(context, "Type %s not currently supported.", TfLiteTypeGetName(input->type)); return kTfLiteError; } }
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
TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { TfLiteTensor* output; TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, kOutputTensor, &output)); const TfLiteTensor* input; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor, &input)); const TfLiteTensor* diag; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kDiagonalTensor, &diag)); FillDiagHelper(input, diag, output); 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
TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { 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)); const int num_elements = NumElements(input); TF_LITE_ENSURE_EQ(context, num_elements, NumElements(output)); switch (input->type) { case kTfLiteInt64: return copyToTensor(context, input->data.i64, output, num_elements); case kTfLiteInt32: return copyToTensor(context, input->data.i32, output, num_elements); case kTfLiteUInt8: return copyToTensor(context, input->data.uint8, output, num_elements); case kTfLiteFloat32: return copyToTensor(context, GetTensorData<float>(input), output, num_elements); case kTfLiteBool: return copyToTensor(context, input->data.b, output, num_elements); case kTfLiteComplex64: return copyToTensor( context, reinterpret_cast<std::complex<float>*>(input->data.c64), output, num_elements); default: // Unsupported type. TF_LITE_UNSUPPORTED_TYPE(context, input->type, "Cast"); } 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
inline size_t codepoint_length(const char *s8, size_t l) { if (l) { auto b = static_cast<uint8_t>(s8[0]); if ((b & 0x80) == 0) { return 1; } else if ((b & 0xE0) == 0xC0) { return 2; } else if ((b & 0xF0) == 0xE0) { return 3; } else if ((b & 0xF8) == 0xF0) { return 4; } } return 0; }
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
static CPINLINE zend_class_entry* swoole_try_get_ce(zend_string *class_name) { //user class , do not support incomplete class now zend_class_entry *ce = zend_lookup_class(class_name); if (ce) { return ce; } // try call unserialize callback and retry lookup zval user_func, args[1], retval; /* Check for unserialize callback */ if ((PG(unserialize_callback_func) == NULL) || (PG(unserialize_callback_func)[0] == '\0')) { zend_throw_exception_ex(NULL, 0, "can not find class %s", class_name->val TSRMLS_CC); return NULL; } zend_string *fname = swoole_string_init(ZEND_STRL(PG(unserialize_callback_func))); Z_STR(user_func) = fname; Z_TYPE_INFO(user_func) = IS_STRING_EX; ZVAL_STR(&args[0], class_name); call_user_function_ex(CG(function_table), NULL, &user_func, &retval, 1, args, 0, NULL); swoole_string_release(fname); //user class , do not support incomplete class now ce = zend_lookup_class(class_name); if (!ce) { zend_throw_exception_ex(NULL, 0, "can not find class %s", class_name->val TSRMLS_CC); return NULL; } else { return ce; } }
0
C++
CWE-502
Deserialization of Untrusted Data
The application deserializes untrusted data without sufficiently verifying that the resulting data will be valid.
https://cwe.mitre.org/data/definitions/502.html
vulnerable
TfLiteStatus GetInputSafe(const TfLiteContext* context, const TfLiteNode* node, int index, const TfLiteTensor** tensor) { return GetMutableInputSafe(context, node, index, tensor); }
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 PCRECache::dump(const std::string& filename) { std::ofstream out(filename.c_str()); switch (m_kind) { case CacheKind::Static: for (auto& it : *m_staticCache) { out << it.first->data() << "\n"; } break; case CacheKind::Lru: case CacheKind::Scalable: { std::vector<LRUCacheKey> keys; if (m_kind == CacheKind::Lru) { m_lruCache->snapshotKeys(keys); } else { m_scalableCache->snapshotKeys(keys); } for (auto& key: keys) { out << key.c_str() << "\n"; } } break; } out.close(); }
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) { const TfLiteTensor* lookup; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &lookup)); const TfLiteTensor* value; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 1, &value)); TfLiteTensor* output; TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 0, &output)); switch (value->type) { case kTfLiteFloat32: return EvalSimple(context, node, lookup, value, output); case kTfLiteUInt8: case kTfLiteInt8: if (output->type == kTfLiteFloat32) { return EvalHybrid(context, node, lookup, value, output); } else { return EvalSimple(context, node, lookup, value, output); } default: context->ReportError(context, "Type not currently supported."); 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
static int burl_normalize_2F_to_slash_fix (buffer *b, int qs, int i) { char * const s = b->ptr; const int blen = (int)buffer_string_length(b); const int used = qs < 0 ? blen : qs; int j = i; for (; i < used; ++i, ++j) { s[j] = s[i]; if (s[i] == '%' && s[i+1] == '2' && s[i+2] == 'F') { s[j] = '/'; i+=2; } } if (qs >= 0) { memmove(s+j, s+qs, blen - qs); j += blen - qs; } buffer_string_set_length(b, j); return qs; }
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 Eval(TfLiteContext* context, TfLiteNode* node) { const TfLiteTensor* input; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, 0, &input)); TfLiteTensor* output_index_tensor; TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, 1, &output_index_tensor)); TF_LITE_ENSURE_EQ(context, NumElements(output_index_tensor), NumElements(input)); switch (input->type) { case kTfLiteInt8: TF_LITE_ENSURE_STATUS(EvalImpl<int8_t>(context, input, node)); break; case kTfLiteInt16: TF_LITE_ENSURE_STATUS(EvalImpl<int16_t>(context, input, node)); break; case kTfLiteInt32: TF_LITE_ENSURE_STATUS(EvalImpl<int32_t>(context, input, node)); break; case kTfLiteInt64: TF_LITE_ENSURE_STATUS(EvalImpl<int64_t>(context, input, node)); break; case kTfLiteFloat32: TF_LITE_ENSURE_STATUS(EvalImpl<float>(context, input, node)); break; case kTfLiteUInt8: TF_LITE_ENSURE_STATUS(EvalImpl<uint8_t>(context, input, node)); break; default: context->ReportError(context, "Currently Unique doesn't support type: %s", TfLiteTypeGetName(input->type)); 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
ECDSA_PrivateKey::create_signature_op(RandomNumberGenerator& rng, const std::string& params, const std::string& provider) const { #if defined(BOTAN_HAS_BEARSSL) if(provider == "bearssl" || provider.empty()) { try { return make_bearssl_ecdsa_sig_op(*this, params); } catch(Lookup_Error& e) { if(provider == "bearssl") throw; } } #endif #if defined(BOTAN_HAS_OPENSSL) if(provider == "openssl" || provider.empty()) { try { return make_openssl_ecdsa_sig_op(*this, params); } catch(Lookup_Error& e) { if(provider == "openssl") throw; } } #endif if(provider == "base" || provider.empty()) return std::unique_ptr<PK_Ops::Signature>(new ECDSA_Signature_Operation(*this, params, rng)); throw Provider_Not_Found(algo_name(), provider); }
1
C++
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
safe
TfLiteStatus CalculateOpData(TfLiteContext* context, TfLiteNode* node, const TfLiteConvParams* params, int width, int height, int filter_width, int filter_height, int out_width, int out_height, const TfLiteType data_type, OpData* data) { bool has_bias = node->inputs->size == 3; // Check number of inputs/outputs TF_LITE_ENSURE(context, has_bias || node->inputs->size == 2); TF_LITE_ENSURE_EQ(context, node->outputs->size, 1); // Matching GetWindowedOutputSize in TensorFlow. auto padding = params->padding; data->padding = ComputePaddingHeightWidth( params->stride_height, params->stride_width, params->dilation_height_factor, params->dilation_width_factor, height, width, filter_height, filter_width, padding, &out_height, &out_width); // Note that quantized inference requires that all tensors have their // parameters set. This is usually done during quantized training. if (data_type != kTfLiteFloat32) { const TfLiteTensor* input = GetInput(context, node, kInputTensor); TF_LITE_ENSURE(context, input != nullptr); const TfLiteTensor* filter = GetInput(context, node, kFilterTensor); TF_LITE_ENSURE(context, filter != nullptr); const TfLiteTensor* bias = GetOptionalInputTensor(context, node, kBiasTensor); TfLiteTensor* output = GetOutput(context, node, kOutputTensor); TF_LITE_ENSURE(context, output != nullptr); int output_channels = filter->dims->data[kConvQuantizedDimension]; TF_LITE_ENSURE_STATUS(tflite::PopulateConvolutionQuantizationParams( context, input, filter, bias, output, params->activation, &data->output_multiplier, &data->output_shift, &data->output_activation_min, &data->output_activation_max, data->per_channel_output_multiplier, reinterpret_cast<int*>(data->per_channel_output_shift), output_channels)); } 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
TfLiteStatus GenericPrepare(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, 0); TF_LITE_ENSURE(context, input != nullptr); TfLiteTensor* output = GetOutput(context, node, 0); TF_LITE_ENSURE(context, output != nullptr); TF_LITE_ENSURE_TYPES_EQ(context, input->type, output->type); if (!IsSupportedType(input->type)) { TF_LITE_KERNEL_LOG(context, "Input data type %s (%d) is not supported.", TfLiteTypeGetName(input->type), input->type); return kTfLiteError; } 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
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 = input->type; return context->ResizeTensor(context, output, TfLiteIntArrayCopy(input->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
TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { 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, NumInputs(node), 1); TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1); TF_LITE_ENSURE_TYPES_EQ(context, input->type, kTfLiteFloat32); output->type = input->type; TfLiteIntArray* output_size = TfLiteIntArrayCopy(input->dims); return context->ResizeTensor(context, output, output_size); }
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 status() const { return status_; }
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
TfLiteStatus Relu1Eval(TfLiteContext* context, TfLiteNode* node) { const TfLiteTensor* input = GetInput(context, node, 0); TfLiteTensor* output = GetOutput(context, node, 0); const ReluOpData* data = reinterpret_cast<ReluOpData*>(node->user_data); switch (input->type) { case kTfLiteFloat32: { optimized_ops::Relu1(GetTensorShape(input), GetTensorData<float>(input), GetTensorShape(output), GetTensorData<float>(output)); return kTfLiteOk; } break; case kTfLiteUInt8: { QuantizedReluX<uint8_t>(-1.0f, 1.0f, input, output, data); return kTfLiteOk; } break; case kTfLiteInt8: { QuantizedReluX<int8_t>(-1, 1, input, output, data); return kTfLiteOk; } break; default: TF_LITE_KERNEL_LOG(context, "Only float32, uint8, int8 supported " "currently, got %s.", TfLiteTypeGetName(input->type)); return kTfLiteError; } }
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 main() { gdImagePtr im; FILE *fp; fp = gdTestFileOpen2("gd2", "too_few_image_data.gd2"); gdTestAssert(fp != NULL); im = gdImageCreateFromGd2(fp); gdTestAssert(im == NULL); fclose(fp); return gdNumFailures(); }
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 int base64decode_block(unsigned char *target, const char *data, size_t data_size) { int w1,w2,w3,w4; int i; size_t n; if (!data || (data_size <= 0)) { return 0; } n = 0; i = 0; while (n < data_size-3) { w1 = base64_table[(int)data[n]]; w2 = base64_table[(int)data[n+1]]; w3 = base64_table[(int)data[n+2]]; w4 = base64_table[(int)data[n+3]]; if (w2 >= 0) { target[i++] = (char)((w1*4 + (w2 >> 4)) & 255); } if (w3 >= 0) { target[i++] = (char)((w2*16 + (w3 >> 2)) & 255); } if (w4 >= 0) { target[i++] = (char)((w3*64 + w4) & 255); } n+=4; } return i; }
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
static Variant HHVM_FUNCTION(bcpowmod, const String& left, const String& right, const String& modulus, int64_t scale /* = -1 */) { scale = adjust_scale(scale); bc_num first, second, mod, result; bc_init_num(&first); bc_init_num(&second); bc_init_num(&mod); bc_init_num(&result); SCOPE_EXIT { bc_free_num(&first); bc_free_num(&second); bc_free_num(&mod); bc_free_num(&result); }; php_str2num(&first, (char*)left.data()); php_str2num(&second, (char*)right.data()); php_str2num(&mod, (char*)modulus.data()); if (bc_raisemod(first, second, mod, &result, scale) == -1) { return false; } if (result->n_scale > scale) { result->n_scale = scale; } String ret(bc_num2str(result), AttachString); 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
void gen_SEK() { vector<char> errMsg(1024, 0); int err_status = 0; vector <uint8_t> encrypted_SEK(1024, 0); uint32_t enc_len = 0; SAFE_CHAR_BUF(SEK, 65); spdlog::info("Generating backup key. Will be stored in backup_key.txt ... "); sgx_status_t status = trustedGenerateSEK(eid, &err_status, errMsg.data(), encrypted_SEK.data(), &enc_len, SEK); HANDLE_TRUSTED_FUNCTION_ERROR(status, err_status, errMsg.data()); if (strnlen(SEK, 33) != 32) { throw SGXException(-1, "strnlen(SEK,33) != 32"); } vector<char> hexEncrKey(2 * enc_len + 1, 0); carray2Hex(encrypted_SEK.data(), enc_len, hexEncrKey.data(), 2 * enc_len + 1); spdlog::info(string("Encrypted storage encryption key:") + hexEncrKey.data()); ofstream sek_file(BACKUP_PATH); sek_file.clear(); sek_file << SEK; cout << "ATTENTION! YOUR BACKUP KEY HAS BEEN WRITTEN INTO sgx_data/backup_key.txt \n" << "PLEASE COPY IT TO THE SAFE PLACE AND THEN DELETE THE FILE MANUALLY BY RUNNING THE FOLLOWING COMMAND:\n" << "apt-get install secure-delete && srm -vz sgx_data/backup_key.txt" << endl; if (!autoconfirm) { string confirm_str = "I confirm"; string buffer; do { cout << " DO YOU CONFIRM THAT YOU COPIED THE KEY? (if you confirm type - I confirm)" << endl; getline(cin, buffer); } while (case_insensitive_match(confirm_str, buffer)); } LevelDB::getLevelDb()->writeDataUnique("SEK", hexEncrKey.data()); create_test_key(); validate_SEK(); shared_ptr <string> encrypted_SEK_ptr = LevelDB::getLevelDb()->readString("SEK"); setSEK(encrypted_SEK_ptr); validate_SEK(); }
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
bool Archive::IsOpened() { #ifdef USE_ARCMEM if (ArcMem.IsLoaded()) return true; #endif return File::IsOpened(); };
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
explicit UnravelIndexOp(OpKernelConstruction* ctx) : OpKernel(ctx), dtidx_(DataTypeToEnum<Tidx>::v()) {}
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
const char *string_of_NPPVariable(int variable) { const char *str; switch (variable) { #define _(VAL) case VAL: str = #VAL; break; _(NPPVpluginNameString); _(NPPVpluginDescriptionString); _(NPPVpluginWindowBool); _(NPPVpluginTransparentBool); _(NPPVjavaClass); _(NPPVpluginWindowSize); _(NPPVpluginTimerInterval); _(NPPVpluginScriptableInstance); _(NPPVpluginScriptableIID); _(NPPVjavascriptPushCallerBool); _(NPPVpluginKeepLibraryInMemory); _(NPPVpluginNeedsXEmbed); _(NPPVpluginScriptableNPObject); _(NPPVformValue); _(NPPVpluginUrlRequestsDisplayedBool); _(NPPVpluginWantsAllNetworkStreams); _(NPPVpluginNativeAccessibleAtkPlugId); _(NPPVpluginCancelSrcStream); _(NPPVSupportsAdvancedKeyHandling); #undef _ default: switch (variable & 0xff) { #define _(VAL, VAR) case VAL: str = #VAR; break _(10, NPPVpluginScriptableInstance); #undef _ default: str = "<unknown variable>"; break; } break; } return str; }
1
C++
CWE-264
Permissions, Privileges, and Access Controls
Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.
https://cwe.mitre.org/data/definitions/264.html
safe
TEST_P(SslSocketTest, FailedClientAuthSanVerificationNoClientCert) { const std::string client_ctx_yaml = R"EOF( common_tls_context: )EOF"; const std::string server_ctx_yaml = R"EOF( common_tls_context: tls_certificates: certificate_chain: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/unittest_cert.pem" private_key: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/unittest_key.pem" validation_context: trusted_ca: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/ca_cert.pem" match_subject_alt_names: exact: "example.com" )EOF"; TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, false, GetParam()); testUtil(test_options.setExpectedServerStats("ssl.fail_verify_no_cert")); }
0
C++
CWE-295
Improper Certificate Validation
The software does not validate, or incorrectly validates, a certificate.
https://cwe.mitre.org/data/definitions/295.html
vulnerable
CSecurityTLS::CSecurityTLS(bool _anon) : session(0), anon_cred(0), anon(_anon), fis(0), fos(0) { cafile = X509CA.getData(); crlfile = X509CRL.getData(); if (gnutls_global_init() != GNUTLS_E_SUCCESS) throw AuthFailureException("gnutls_global_init failed"); }
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
QInt32() : value(0) {}
1
C++
CWE-908
Use of Uninitialized Resource
The software uses or accesses a resource that has not been initialized.
https://cwe.mitre.org/data/definitions/908.html
safe
TEST(BasicInterpreter, AllocateTwice) { Interpreter interpreter; ASSERT_EQ(interpreter.AddTensors(2), kTfLiteOk); ASSERT_EQ(interpreter.SetInputs({0}), kTfLiteOk); ASSERT_EQ(interpreter.SetOutputs({1}), kTfLiteOk); TfLiteQuantizationParams quantized; ASSERT_EQ(interpreter.SetTensorParametersReadWrite(0, kTfLiteFloat32, "", {3}, quantized), kTfLiteOk); ASSERT_EQ(interpreter.SetTensorParametersReadWrite(1, kTfLiteFloat32, "", {3}, quantized), kTfLiteOk); TfLiteRegistration reg = {nullptr, nullptr, nullptr, nullptr}; reg.prepare = [](TfLiteContext* context, TfLiteNode* node) { const TfLiteTensor* tensor0 = GetInput(context, node, 0); TfLiteTensor* tensor1 = GetOutput(context, node, 0); TfLiteIntArray* newSize = TfLiteIntArrayCopy(tensor0->dims); return context->ResizeTensor(context, tensor1, newSize); }; reg.invoke = [](TfLiteContext* context, TfLiteNode* node) { const TfLiteTensor* a0 = GetInput(context, node, 0); TfLiteTensor* a1 = GetOutput(context, node, 0); int num = a0->dims->data[0]; for (int i = 0; i < num; i++) { a1->data.f[i] = a0->data.f[i]; } return kTfLiteOk; }; ASSERT_EQ( interpreter.AddNodeWithParameters({0}, {1}, nullptr, 0, nullptr, &reg), kTfLiteOk); ASSERT_EQ(interpreter.ResizeInputTensor(0, {3}), kTfLiteOk); ASSERT_EQ(interpreter.AllocateTensors(), kTfLiteOk); ASSERT_EQ(interpreter.Invoke(), kTfLiteOk); char* old_tensor0_ptr = interpreter.tensor(0)->data.raw; char* old_tensor1_ptr = interpreter.tensor(1)->data.raw; ASSERT_EQ(interpreter.AllocateTensors(), kTfLiteOk); ASSERT_EQ(interpreter.Invoke(), kTfLiteOk); ASSERT_EQ(old_tensor0_ptr, interpreter.tensor(0)->data.raw); ASSERT_EQ(old_tensor1_ptr, interpreter.tensor(1)->data.raw); }
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 EvalHashtableSize(TfLiteContext* context, TfLiteNode* node) { const TfLiteTensor* input_resource_id_tensor = GetInput(context, node, kInputResourceIdTensor); int resource_id = input_resource_id_tensor->data.i32[0]; TfLiteTensor* output_tensor = GetOutput(context, node, kOutputTensor); auto* output_data = GetTensorData<std::int64_t>(output_tensor); Subgraph* subgraph = reinterpret_cast<Subgraph*>(context->impl_); auto& resources = subgraph->resources(); auto* lookup = resource::GetHashtableResource(&resources, resource_id); TF_LITE_ENSURE(context, lookup != nullptr); output_data[0] = lookup->Size(); 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
void writeSuccess() noexcept override {}
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 HeaderMapImpl::appendToHeader(HeaderString& header, absl::string_view data) { if (data.empty()) { return; } if (!header.empty()) { header.append(",", 1); } header.append(data.data(), data.size()); }
0
C++
CWE-400
Uncontrolled Resource Consumption
The software does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
https://cwe.mitre.org/data/definitions/400.html
vulnerable
TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { OpData* data = reinterpret_cast<OpData*>(node->user_data); TF_LITE_ENSURE_EQ(context, NumInputs(node), 2); TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1); const TfLiteTensor* input1; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor1, &input1)); const TfLiteTensor* input2; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor2, &input2)); TfLiteTensor* output; TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, kOutputTensor, &output)); TF_LITE_ENSURE_TYPES_EQ(context, input1->type, input2->type); output->type = input2->type; data->requires_broadcast = !HaveSameShapes(input1, input2); TfLiteIntArray* output_size = nullptr; if (data->requires_broadcast) { TF_LITE_ENSURE_OK(context, CalculateShapeForBroadcast( context, input1, input2, &output_size)); } else { output_size = TfLiteIntArrayCopy(input1->dims); } return context->ResizeTensor(context, output, output_size); }
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 CleanupOutput(char *str) { char *s, *t; int period = 0; s = t = str; while ( *s && *s != '}' ) { if ( *s == '\n' ) *s = ' '; if ( ( *s == ' ' || *s == '\n' ) && ( s[1] == ' ' || s[1] == '\n' ) ) s++; else *t++ = *s++; } while ( *s ) *t++ = *s++; *t = 0; s = t = str; while ( *s ) { if ( *s == '.' ) { period = 1; *t++ = *s++; } else if ( *s == '-' && s[1] == '0' && s[2] == ' ' ) { s++; } else if ( *s <= '9' && *s >= '0' ) { *t++ = *s++; } else if ( *s == '\n' && ( t > str && t[-1] == '\n' ) ) { s++; } else if ( period ) { while ( t > str && t[-1] == '0' ) t--; if ( t > str && t[-1] == '.' ) t--; while ( *s == ' ' && s[1] == ' ' ) s++; period = 0; *t++ = *s++; } else if ( *s == ' ' && s[1] == ' ' ) s++; else { period = 0; *t++ = *s++; } } *t = 0; s = t = str; while ( *s ) { if ( *s == '-' && s[1] == '0' && s[2] == ' ' ) { s++; } else *t++ = *s++; } *t = 0; }
0
C++
NVD-CWE-noinfo
null
null
null
vulnerable
static inline char *parse_ip_address_ex(const char *str, size_t str_len, int *portno, int get_err, zend_string **err) { char *colon; char *host = NULL; #ifdef HAVE_IPV6 if (*(str) == '[' && str_len > 1) { /* IPV6 notation to specify raw address with port (i.e. [fe80::1]:80) */ char *p = memchr(str + 1, ']', str_len - 2), *e = NULL; if (!p || *(p + 1) != ':') { if (get_err) { *err = strpprintf(0, "Failed to parse IPv6 address \"%s\"", str); } return NULL; } *portno = strtol(p + 2, &e, 10); if (e && *e) { if (get_err) { *err = strpprintf(0, "Failed to parse address \"%s\"", str); } return NULL; } return estrndup(str + 1, p - str - 1); } #endif if (str_len) { colon = memchr(str, ':', str_len - 1); } else { colon = NULL; } if (colon) { char *e = NULL; *portno = strtol(colon + 1, &e, 10); if (!e || !*e) { return estrndup(str, colon - str); } } if (get_err) { *err = strpprintf(0, "Failed to parse address \"%s\"", str); } return NULL; }
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
Pl_ASCII85Decoder::flush() { if (this->pos == 0) { QTC::TC("libtests", "Pl_ASCII85Decoder no-op flush"); return; } unsigned long lval = 0; for (int i = 0; i < 5; ++i) { lval *= 85; lval += (this->inbuf[i] - 33U); } unsigned char outbuf[4]; memset(outbuf, 0, 4); for (int i = 3; i >= 0; --i) { outbuf[i] = lval & 0xff; lval >>= 8; } QTC::TC("libtests", "Pl_ASCII85Decoder partial flush", (this->pos == 5) ? 0 : 1); getNext()->write(outbuf, this->pos - 1); this->pos = 0; memset(this->inbuf, 117, 5); }
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 Variant HHVM_FUNCTION(simplexml_import_dom, const Object& node, const String& class_name /* = "SimpleXMLElement" */) { auto domnode = Native::data<DOMNode>(node); xmlNodePtr nodep = domnode->nodep(); if (nodep) { if (nodep->doc == nullptr) { raise_warning("Imported Node must have associated Document"); return init_null(); } if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) { nodep = xmlDocGetRootElement((xmlDocPtr) nodep); } } if (nodep && nodep->type == XML_ELEMENT_NODE) { auto cls = class_from_name(class_name, "simplexml_import_dom"); if (!cls) { return init_null(); } Object obj = create_object(cls->nameStr(), Array(), false); auto sxe = Native::data<SimpleXMLElement>(obj.get()); sxe->node = libxml_register_node(nodep); return obj; } else { raise_warning("Invalid Nodetype to import"); return init_null(); } return false; }
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
void test_base64_lengths(void) { const char *in = "FuseMuse"; char out1[32]; char out2[32]; size_t enclen; int declen; /* Encoding a zero-length string should fail */ enclen = mutt_b64_encode(out1, in, 0, 32); if (!TEST_CHECK(enclen == 0)) { TEST_MSG("Expected: %zu", 0); TEST_MSG("Actual : %zu", enclen); } /* Decoding a zero-length string should fail, too */ out1[0] = '\0'; declen = mutt_b64_decode(out2, out1); if (!TEST_CHECK(declen == -1)) { TEST_MSG("Expected: %zu", -1); TEST_MSG("Actual : %zu", declen); } /* Encode one to eight bytes, check the lengths of the returned string */ for (size_t i = 1; i <= 8; ++i) { enclen = mutt_b64_encode(out1, in, i, 32); size_t exp = ((i + 2) / 3) << 2; if (!TEST_CHECK(enclen == exp)) { TEST_MSG("Expected: %zu", exp); TEST_MSG("Actual : %zu", enclen); } declen = mutt_b64_decode(out2, out1); if (!TEST_CHECK(declen == i)) { TEST_MSG("Expected: %zu", i); TEST_MSG("Actual : %zu", declen); } out2[declen] = '\0'; if (!TEST_CHECK(strncmp(out2, in, i) == 0)) { TEST_MSG("Expected: %s", in); TEST_MSG("Actual : %s", out2); } } }
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
TfLiteStatus ReverseSequenceImpl(TfLiteContext* context, TfLiteNode* node) { const TfLiteTensor* input = GetInput(context, node, kInputTensor); const TfLiteTensor* seq_lengths_tensor = GetInput(context, node, kSeqLengthsTensor); const TS* seq_lengths = GetTensorData<TS>(seq_lengths_tensor); auto* params = reinterpret_cast<TfLiteReverseSequenceParams*>(node->builtin_data); int seq_dim = params->seq_dim; int batch_dim = params->batch_dim; TF_LITE_ENSURE(context, seq_dim >= 0); TF_LITE_ENSURE(context, batch_dim >= 0); TF_LITE_ENSURE(context, seq_dim != batch_dim); TF_LITE_ENSURE(context, seq_dim < NumDimensions(input)); TF_LITE_ENSURE(context, batch_dim < NumDimensions(input)); TF_LITE_ENSURE_EQ(context, SizeOfDimension(seq_lengths_tensor, 0), SizeOfDimension(input, batch_dim)); for (int i = 0; i < NumDimensions(seq_lengths_tensor); ++i) { TF_LITE_ENSURE(context, seq_lengths[i] <= SizeOfDimension(input, seq_dim)); } TfLiteTensor* output = GetOutput(context, node, kOutputTensor); reference_ops::ReverseSequence<T, TS>( seq_lengths, seq_dim, batch_dim, GetTensorShape(input), GetTensorData<T>(input), GetTensorShape(output), GetTensorData<T>(output)); 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
SilenceMessage(const std::string& mask, const std::string& flags) : ClientProtocol::Message("SILENCE") { PushParam(mask); PushParam(flags); }
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
void Ogg::XiphComment::parse(const ByteVector &data) { // The first thing in the comment data is the vendor ID length, followed by a // UTF8 string with the vendor ID. int pos = 0; int vendorLength = data.mid(0, 4).toUInt(false); pos += 4; d->vendorID = String(data.mid(pos, vendorLength), String::UTF8); pos += vendorLength; // Next the number of fields in the comment vector. uint commentFields = data.mid(pos, 4).toUInt(false); pos += 4; if(commentFields > (data.size() - 8) / 4) { return; } for(uint i = 0; i < commentFields; i++) { // Each comment field is in the format "KEY=value" in a UTF8 string and has // 4 bytes before the text starts that gives the length. uint commentLength = data.mid(pos, 4).toUInt(false); pos += 4; String comment = String(data.mid(pos, commentLength), String::UTF8); pos += commentLength; if(pos > data.size()) { break; } int commentSeparatorPosition = comment.find("="); if(commentSeparatorPosition == -1) { break; } String key = comment.substr(0, commentSeparatorPosition); String value = comment.substr(commentSeparatorPosition + 1); addField(key, value, false); } }
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) { auto* params = reinterpret_cast<TfLiteMulParams*>(node->builtin_data); OpData* data = reinterpret_cast<OpData*>(node->user_data); const TfLiteTensor* input1; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor1, &input1)); const TfLiteTensor* input2; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kInputTensor2, &input2)); TfLiteTensor* output; TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, kOutputTensor, &output)); if (output->type == kTfLiteFloat32 || output->type == kTfLiteInt32) { EvalMul<kernel_type>(context, node, params, data, input1, input2, output); } else if (output->type == kTfLiteUInt8 || output->type == kTfLiteInt8 || output->type == kTfLiteInt16) { TF_LITE_ENSURE_OK( context, EvalQuantized<kernel_type>(context, node, params, data, input1, input2, output)); } else { context->ReportError(context, "Mul only supports FLOAT32, INT32 and quantized UINT8," " INT8 and INT16 now, got %d.", output->type); return kTfLiteError; } 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
SetRunner( ReferenceHandle& that, Local<Value> key_handle, Local<Value> val_handle, MaybeLocal<Object> maybe_options ) : key{ExternalCopy::CopyIfPrimitive(key_handle)}, val{TransferOut(val_handle, TransferOptions{maybe_options})}, context{that.context}, reference{that.reference} { that.CheckDisposed(); if (!key) { throw RuntimeTypeError("Invalid `key`"); } }
0
C++
CWE-913
Improper Control of Dynamically-Managed Code Resources
The software does not properly restrict reading from or writing to dynamically-managed code resources such as variables, objects, classes, attributes, functions, or executable instructions or statements.
https://cwe.mitre.org/data/definitions/913.html
vulnerable
CdsIntegrationTest() : HttpIntegrationTest(Http::CodecType::HTTP2, ipVersion(), ConfigHelper::discoveredClustersBootstrap( sotwOrDelta() == Grpc::SotwOrDelta::Sotw || sotwOrDelta() == Grpc::SotwOrDelta::UnifiedSotw ? "GRPC" : "DELTA_GRPC")) { if (sotwOrDelta() == Grpc::SotwOrDelta::UnifiedSotw || sotwOrDelta() == Grpc::SotwOrDelta::UnifiedDelta) { config_helper_.addRuntimeOverride("envoy.reloadable_features.unified_mux", "true"); } use_lds_ = false; sotw_or_delta_ = sotwOrDelta(); }
0
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
vulnerable
bool chopOff(string &domain) { if(domain.empty()) return false; bool escaped = false; const string::size_type domainLen = domain.length(); for (size_t fdot = 0; fdot < domainLen; fdot++) { if (domain[fdot] == '.' && !escaped) { string::size_type remain = domainLen - (fdot + 1); char tmp[remain]; memcpy(tmp, domain.c_str()+fdot+1, remain); domain.assign(tmp, remain); // don't dare to do this w/o tmp holder :-) return true; } else if (domain[fdot] == '\\' && !escaped) { escaped = true; } else { escaped = false; } } domain = ""; return true; }
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
int64_t MemFile::readImpl(char *buffer, int64_t length) { assertx(m_len != -1); assertx(length > 0); assertx(m_cursor >= 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; } return 0; }
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
TfLiteStatus PrepareSimple(TfLiteContext* context, TfLiteNode* node) { TF_LITE_ENSURE_EQ(context, NumInputs(node), 2); TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1); OpContext op_context(context, node); TF_LITE_ENSURE_TYPES_EQ(context, op_context.axis->type, kTfLiteInt32); TF_LITE_ENSURE_OK(context, InitializeTemporaries(context, node, &op_context)); TfLiteTensor* resolved_axis; TF_LITE_ENSURE_OK( context, GetTemporarySafe(context, node, /*index=*/1, &resolved_axis)); // Leaves work to Eval if axis is not constant; else resizes output. if (!IsConstantTensor(op_context.axis)) { SetTensorToDynamic(op_context.output); SetTensorToDynamic(resolved_axis); return kTfLiteOk; } resolved_axis->allocation_type = kTfLiteArenaRw; TF_LITE_ENSURE_OK(context, ResizeTempAxis(context, &op_context, resolved_axis)); TF_LITE_ENSURE_OK(context, ResizeOutputTensor(context, &op_context)); 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 virtualHostDirective(MaState *state, cchar *key, cchar *value) { state = maPushState(state); if (state->enabled) { /* Inherit the current default route configuration (only) Other routes are not inherited due to the reset routes below */ state->route = httpCreateInheritedRoute(httpGetHostDefaultRoute(state->host)); state->route->ssl = 0; state->auth = state->route->auth; state->host = httpCloneHost(state->host); httpResetRoutes(state->host); httpSetRouteHost(state->route, state->host); httpSetHostDefaultRoute(state->host, state->route); /* Set a default host and route name */ if (value) { httpSetHostName(state->host, stok(sclone(value), " \t,", NULL)); httpSetRouteName(state->route, sfmt("default-%s", state->host->name)); /* Save the endpoints until the close of the VirtualHost to closeVirtualHostDirective can add the virtual host to the specified endpoints. */ state->endpoints = sclone(value); } } return 0; }
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 PropertiesWidget::loadTorrentInfos(BitTorrent::TorrentHandle *const torrent) { clear(); m_torrent = torrent; downloaded_pieces->setTorrent(m_torrent); pieces_availability->setTorrent(m_torrent); if (!m_torrent) return; // Save path updateSavePath(m_torrent); // Hash hash_lbl->setText(m_torrent->hash()); PropListModel->model()->clear(); if (m_torrent->hasMetadata()) { // Creation date lbl_creationDate->setText(m_torrent->creationDate().toString(Qt::DefaultLocaleShortDate)); label_total_size_val->setText(Utils::Misc::friendlyUnit(m_torrent->totalSize())); // Comment comment_text->setText(Utils::Misc::parseHtmlLinks(m_torrent->comment())); // URL seeds loadUrlSeeds(); label_created_by_val->setText(m_torrent->creator()); // List files in torrent PropListModel->model()->setupModelData(m_torrent->info()); filesList->setExpanded(PropListModel->index(0, 0), true); // Load file priorities PropListModel->model()->updateFilesPriorities(m_torrent->filePriorities()); } // Load dynamic data loadDynamicData(); }
0
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
vulnerable
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 = GetInput(context, node, 0); TfLiteTensor* out_tensor = GetOutput(context, node, 0); 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; }
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* value; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kValueTensor, &value)); TfLiteTensor* output; TF_LITE_ENSURE_OK(context, GetOutputSafe(context, node, kOutputTensor, &output)); if (IsDynamicTensor(output)) { const TfLiteTensor* dims; TF_LITE_ENSURE_OK(context, GetInputSafe(context, node, kDimsTensor, &dims)); TF_LITE_ENSURE_OK(context, ResizeOutput(context, dims, output)); } #define TF_LITE_FILL(data_type) \ reference_ops::Fill(GetTensorShape(value), GetTensorData<data_type>(value), \ GetTensorShape(output), \ GetTensorData<data_type>(output)) switch (output->type) { case kTfLiteInt32: TF_LITE_FILL(int32_t); break; case kTfLiteInt64: TF_LITE_FILL(int64_t); break; case kTfLiteFloat32: TF_LITE_FILL(float); break; case kTfLiteBool: TF_LITE_FILL(bool); break; case kTfLiteString: FillString(value, output); break; default: context->ReportError( context, "Fill only currently supports int32, int64, float32, bool, string " "for input 1, got %d.", value->type); return kTfLiteError; } #undef TF_LITE_FILL 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
generatePreview (const char inFileName[], float exposure, int previewWidth, int &previewHeight, Array2D <PreviewRgba> &previewPixels) { // // Read the input file // RgbaInputFile in (inFileName); Box2i dw = in.dataWindow(); float a = in.pixelAspectRatio(); int w = dw.max.x - dw.min.x + 1; int h = dw.max.y - dw.min.y + 1; Array2D <Rgba> pixels (h, w); in.setFrameBuffer (ComputeBasePointer (&pixels[0][0], dw), 1, w); in.readPixels (dw.min.y, dw.max.y); // // Make a preview image // previewHeight = max (int (h / (w * a) * previewWidth + .5f), 1); previewPixels.resizeErase (previewHeight, previewWidth); float fx = (previewWidth > 0)? (float (w - 1) / (previewWidth - 1)): 1; float fy = (previewHeight > 0)? (float (h - 1) / (previewHeight - 1)): 1; float m = Math<float>::pow (2.f, IMATH_NAMESPACE::clamp (exposure + 2.47393f, -20.f, 20.f)); for (int y = 0; y < previewHeight; ++y) { for (int x = 0; x < previewWidth; ++x) { PreviewRgba &preview = previewPixels[y][x]; const Rgba &pixel = pixels[int (y * fy + .5f)][int (x * fx + .5f)]; preview.r = gamma (pixel.r, m); preview.g = gamma (pixel.g, m); preview.b = gamma (pixel.b, m); preview.a = int (IMATH_NAMESPACE::clamp (pixel.a * 255.f, 0.f, 255.f) + .5f); } } }
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
TfLiteStatus LeakyReluPrepare(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, 0); TfLiteTensor* output = GetOutput(context, node, 0); TF_LITE_ENSURE_TYPES_EQ(context, input->type, output->type); LeakyReluOpData* data = reinterpret_cast<LeakyReluOpData*>(node->user_data); if (output->type == kTfLiteUInt8 || output->type == kTfLiteInt8 || output->type == kTfLiteInt16) { const auto* params = reinterpret_cast<TfLiteLeakyReluParams*>(node->builtin_data); double alpha_multiplier = input->params.scale * params->alpha / output->params.scale; QuantizeMultiplier(alpha_multiplier, &data->output_multiplier_alpha, &data->output_shift_alpha); double identity_multiplier = input->params.scale / output->params.scale; QuantizeMultiplier(identity_multiplier, &data->output_multiplier_identity, &data->output_shift_identity); } return context->ResizeTensor(context, output, TfLiteIntArrayCopy(input->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
TEST(DefaultCertValidatorTest, TestMatchSubjectAltNameDNSMatched) { bssl::UniquePtr<X509> cert = readCertFromFile(TestEnvironment::substitute( "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/san_dns_cert.pem")); envoy::type::matcher::v3::StringMatcher matcher; matcher.MergeFrom(TestUtility::createRegexMatcher(".*.example.com")); std::vector<Matchers::StringMatcherImpl<envoy::type::matcher::v3::StringMatcher>> subject_alt_name_matchers; subject_alt_name_matchers.push_back(Matchers::StringMatcherImpl(matcher)); EXPECT_TRUE(DefaultCertValidator::matchSubjectAltName(cert.get(), subject_alt_name_matchers)); }
0
C++
CWE-295
Improper Certificate Validation
The software does not validate, or incorrectly validates, a certificate.
https://cwe.mitre.org/data/definitions/295.html
vulnerable
Status QuantizeV2Shape(InferenceContext* c) { int axis = -1; Status s = c->GetAttr("axis", &axis); if (!s.ok() && s.code() != error::NOT_FOUND) { return s; } if (axis < -1) { return errors::InvalidArgument("axis should be at least -1, got ", axis); } const int minmax_rank = (axis == -1) ? 0 : 1; TF_RETURN_IF_ERROR(shape_inference::UnchangedShape(c)); ShapeHandle minmax; TF_RETURN_IF_ERROR(c->WithRank(c->input(1), minmax_rank, &minmax)); TF_RETURN_IF_ERROR(c->WithRank(c->input(2), minmax_rank, &minmax)); if (axis != -1) { ShapeHandle input; TF_RETURN_IF_ERROR(c->WithRankAtLeast(c->input(0), axis + 1, &input)); DimensionHandle depth; TF_RETURN_IF_ERROR( c->Merge(c->Dim(minmax, 0), c->Dim(input, axis), &depth)); } c->set_output(1, minmax); c->set_output(2, minmax); return Status::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
QInt16() : value(0) {}
1
C++
CWE-908
Use of Uninitialized Resource
The software uses or accesses a resource that has not been initialized.
https://cwe.mitre.org/data/definitions/908.html
safe
static int bmp_dec_parseopts(char *optstr, bmp_dec_importopts_t *opts) { jas_tvparser_t *tvp; opts->max_samples = 128 * JAS_MEBI; if (!(tvp = jas_tvparser_create(optstr ? optstr : ""))) { return -1; } while (!jas_tvparser_next(tvp)) { switch (jas_taginfo_nonull(jas_taginfos_lookup(decopts, jas_tvparser_gettag(tvp)))->id) { case OPT_MAXSIZE: opts->max_samples = atoi(jas_tvparser_getval(tvp)); break; default: jas_eprintf("warning: ignoring invalid option %s\n", jas_tvparser_gettag(tvp)); break; } } jas_tvparser_destroy(tvp); return 0; }
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
TEST_F(GroupVerifierTest, TestRequiresAnyWithAllowMissingButOk) { TestUtility::loadFromYaml(RequiresAnyConfig, proto_config_); proto_config_.mutable_rules(0) ->mutable_requires() ->mutable_requires_any() ->add_requirements() ->mutable_allow_missing(); createAsyncMockAuthsAndVerifier(std::vector<std::string>{"example_provider", "other_provider"}); EXPECT_CALL(mock_cb_, onComplete(Status::Ok)); auto headers = Http::TestRequestHeaderMapImpl{}; context_ = Verifier::createContext(headers, parent_span_, &mock_cb_); verifier_->verify(context_); callbacks_["example_provider"](Status::JwtMissed); callbacks_["other_provider"](Status::JwtUnknownIssuer); }
0
C++
CWE-287
Improper Authentication
When an actor claims to have a given identity, the software does not prove or insufficiently proves that the claim is correct.
https://cwe.mitre.org/data/definitions/287.html
vulnerable
virtual size_t Read(void *buffer, size_t size, size_t count) { if (!m_fp) return 0; return fread(buffer, size, count, m_fp); }
0
C++
CWE-770
Allocation of Resources Without Limits or Throttling
The software allocates a reusable resource or group of resources on behalf of an actor without imposing any restrictions on the size or number of resources that can be allocated, in violation of the intended security policy for that actor.
https://cwe.mitre.org/data/definitions/770.html
vulnerable
DSA_Verification_Operation(const DSA_PublicKey& dsa, const std::string& emsa) : PK_Ops::Verification_with_EMSA(emsa), m_group(dsa.get_group()), m_y(dsa.get_y()), m_mod_q(dsa.group_q()) { }
1
C++
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
safe
static int closeVirtualHostDirective(MaState *state, cchar *key, cchar *value) { HttpEndpoint *endpoint; char *address, *ip, *addresses, *tok; int port; if (state->enabled) { if (state->endpoints && *state->endpoints) { for (addresses = sclone(state->endpoints); (address = stok(addresses, " \t,", &tok)) != 0 ; addresses = tok) { mprParseSocketAddress(address, &ip, &port, NULL, -1); if ((endpoint = httpLookupEndpoint(ip, port)) == 0) { mprLog("error appweb config", 0, "Cannot find listen directive for virtual host %s", address); return MPR_ERR_BAD_SYNTAX; } else { httpAddHostToEndpoint(endpoint, state->host); } } } else { httpAddHostToEndpoints(state->host); } } closeDirective(state, key, value); 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
optional<ARN> ARN::parse(const string& s, bool wildcards) { static const char str_wild[] = "arn:([^:]*):([^:]*):([^:]*):([^:]*):([^:]*)"; static const regex rx_wild(str_wild, sizeof(str_wild) - 1, ECMAScript | optimize); static const char str_no_wild[] = "arn:([^:*]*):([^:*]*):([^:*]*):([^:*]*):([^:*]*)"; static const regex rx_no_wild(str_no_wild, sizeof(str_no_wild) - 1, ECMAScript | optimize); smatch match; if ((s == "*") && wildcards) { return ARN(Partition::wildcard, Service::wildcard, "*", "*", "*"); } else if (regex_match(s, match, wildcards ? rx_wild : rx_no_wild)) { ceph_assert(match.size() == 6); ARN a; { auto p = to_partition(match[1], wildcards); if (!p) return none; a.partition = *p; } { auto s = to_service(match[2], wildcards); if (!s) { return none; } a.service = *s; } a.region = match[3]; a.account = match[4]; a.resource = match[5]; return a; } return none; }
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
const TfLiteTensor* GetOptionalInputTensor(const TfLiteContext* context, const TfLiteNode* node, int index) { return GetInput(context, node, index); }
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
bool DNP3_Base::ParseAppLayer(Endpoint* endp) { bool orig = (endp == &orig_state); binpac::DNP3::DNP3_Flow* flow = orig ? interp->upflow() : interp->downflow(); u_char* data = endp->buffer + PSEUDO_TRANSPORT_INDEX; // The transport layer byte counts as app-layer it seems. int len = endp->pkt_length - 5; // DNP3 Packet : DNP3 Pseudo Link Layer | DNP3 Pseudo Transport Layer | DNP3 Pseudo Application Layer // DNP3 Serial Transport Layer data is always 1 byte. // Get FIN FIR seq field in transport header. // FIR indicate whether the following DNP3 Serial Application Layer is first chunk of bytes or not. // FIN indicate whether the following DNP3 Serial Application Layer is last chunk of bytes or not. int is_first = (endp->tpflags & 0x40) >> 6; // Initial chunk of data in this packet. int is_last = (endp->tpflags & 0x80) >> 7; // Last chunk of data in this packet. int transport = PSEUDO_TRANSPORT_LEN; int i = 0; while ( len > 0 ) { int n = min(len, 16); // Make sure chunk has a correct checksum. if ( ! CheckCRC(n, data, data + n, "app_chunk") ) return false; if ( data + n >= endp->buffer + endp->buffer_len ) { reporter->AnalyzerError(analyzer, "dnp3 app layer parsing overflow %d - %d", endp->buffer_len, n); return false; } // Pass on to BinPAC. flow->flow_buffer()->BufferData(data + transport, data + n); transport = 0; data += n + 2; len -= n; } if ( is_first ) endp->encountered_first_chunk = true; if ( ! is_first && ! endp->encountered_first_chunk ) { // We lost the first chunk. analyzer->Weird("dnp3_first_application_layer_chunk_missing"); return false; } if ( is_last ) { flow->flow_buffer()->FinishBuffer(); flow->FlowEOF(); ClearEndpointState(orig); } return true; }
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
RemoteDevicePropertiesWidget::RemoteDevicePropertiesWidget(QWidget *parent) : QWidget(parent) , modified(false) , saveable(false) { setupUi(this); if (qobject_cast<QTabWidget *>(parent)) { verticalLayout->setMargin(4); } type->addItem(tr("Samba Share"), (int)Type_Samba); type->addItem(tr("Samba Share (Auto-discover host and port)"), (int)Type_SambaAvahi); type->addItem(tr("Secure Shell (sshfs)"), (int)Type_SshFs); type->addItem(tr("Locally Mounted Folder"), (int)Type_File); }
0
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
vulnerable
void test_base64_decode(void) { char buffer[16]; int len = mutt_b64_decode(buffer, encoded, sizeof(buffer)); if (!TEST_CHECK(len == sizeof(clear) - 1)) { TEST_MSG("Expected: %zu", sizeof(clear) - 1); TEST_MSG("Actual : %zu", len); } buffer[len] = '\0'; if (!TEST_CHECK(strcmp(buffer, clear) == 0)) { TEST_MSG("Expected: %s", clear); TEST_MSG("Actual : %s", buffer); } }
1
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
safe
CloseNotifyConnector(EventBase* evb, const SocketAddress& addr) { evb_ = evb; ssl_ = AsyncSSLSocket::newSocket(std::make_shared<SSLContext>(), evb_); ssl_->connect(this, addr); }
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<TfLiteLocalResponseNormParams*>(node->builtin_data); 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 (output->type == kTfLiteFloat32) { #define TF_LITE_LOCAL_RESPONSE_NORM(type) \ tflite::LocalResponseNormalizationParams op_params; \ op_params.range = params->radius; \ op_params.bias = params->bias; \ op_params.alpha = params->alpha; \ op_params.beta = params->beta; \ type::LocalResponseNormalization( \ op_params, GetTensorShape(input), GetTensorData<float>(input), \ GetTensorShape(output), GetTensorData<float>(output)) if (kernel_type == kReference) { TF_LITE_LOCAL_RESPONSE_NORM(reference_ops); } if (kernel_type == kGenericOptimized) { TF_LITE_LOCAL_RESPONSE_NORM(optimized_ops); } #undef TF_LITE_LOCAL_RESPONSE_NORM } else { context->ReportError(context, "Output type is %d, requires float.", output->type); return kTfLiteError; } 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
TfLiteStatus ComputeDepthMultiplier(TfLiteContext* context, const TfLiteTensor* input, const TfLiteTensor* filter, int16* depth_multiplier) { int num_filter_channels = SizeOfDimension(filter, 3); int num_input_channels = SizeOfDimension(input, 3); TF_LITE_ENSURE(context, num_input_channels != 0); TF_LITE_ENSURE_EQ(context, num_filter_channels % num_input_channels, 0); *depth_multiplier = num_filter_channels / num_input_channels; return kTfLiteOk; }
1
C++
CWE-369
Divide By Zero
The product divides a value by zero.
https://cwe.mitre.org/data/definitions/369.html
safe
StatusOr<FullTypeDef> SpecializeType(const AttrSlice& attrs, const OpDef& op_def) { FullTypeDef ft; ft.set_type_id(TFT_PRODUCT); for (int i = 0; i < op_def.output_arg_size(); i++) { auto* t = ft.add_args(); *t = op_def.output_arg(i).experimental_full_type(); // Resolve dependent types. The convention for op registrations is to use // attributes as type variables. // See https://www.tensorflow.org/guide/create_op#type_polymorphism. // Once the op signature can be defined entirely in FullType, this // convention can be deprecated. // // Note: While this code performs some basic verifications, it generally // assumes consistent op defs and attributes. If more complete // verifications are needed, they should be done by separately, and in a // way that can be reused for type inference. for (int j = 0; j < t->args_size(); j++) { auto* arg = t->mutable_args(j); if (arg->type_id() == TFT_VAR) { const auto* attr = attrs.Find(arg->s()); if (attr == nullptr) { return Status( error::INVALID_ARGUMENT, absl::StrCat("Could not find an attribute for key ", arg->s())); } if (attr->value_case() == AttrValue::kList) { const auto& attr_list = attr->list(); arg->set_type_id(TFT_PRODUCT); for (int i = 0; i < attr_list.type_size(); i++) { map_dtype_to_tensor(attr_list.type(i), arg->add_args()); } } else if (attr->value_case() == AttrValue::kType) { map_dtype_to_tensor(attr->type(), arg); } else { return Status(error::UNIMPLEMENTED, absl::StrCat("unknown attribute type", attrs.DebugString(), " key=", arg->s())); } arg->clear_s(); } } } return ft; }
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
RequestHandler::RequestHandler( std::shared_ptr<CheckWorkflow> check_workflow, std::shared_ptr<context::ServiceContext> service_context, std::unique_ptr<Request> request_data) : context_(new context::RequestContext(service_context, std::move(request_data))), check_workflow_(check_workflow) { // Remove x-endponts-api-userinfo from downstream client. // It should be set by the last Endpoint proxy to prevent users spoofing. std::string buffer; if (context_->request()->FindHeader( google::api_manager::auth::kEndpointApiUserInfo, &buffer)) { context_->request()->AddHeaderToBackend( google::api_manager::auth::kEndpointApiUserInfo, ""); } }
0
C++
CWE-290
Authentication Bypass by Spoofing
This attack-focused weakness is caused by improperly implemented authentication schemes that are subject to spoofing attacks.
https://cwe.mitre.org/data/definitions/290.html
vulnerable
Status OpLevelCostEstimator::PredictAvgPoolGrad(const OpContext& op_context, NodeCosts* node_costs) const { bool found_unknown_shapes = false; const auto& op_info = op_context.op_info; // x's shape: op_info.inputs(0) // y_grad: op_info.inputs(1) // Extract x_shape from op_info.inputs(0).value() or op_info.outputs(0). bool shape_found = false; TensorShapeProto x_shape; if (op_info.inputs_size() >= 1 && op_info.inputs(0).has_value()) { const TensorProto& value = op_info.inputs(0).value(); shape_found = GetTensorShapeProtoFromTensorProto(value, &x_shape); } if (!shape_found && op_info.outputs_size() > 0) { x_shape = op_info.outputs(0).shape(); shape_found = true; } if (!shape_found) { // Set the minimum shape that's feasible. x_shape.Clear(); for (int i = 0; i < 4; ++i) { x_shape.add_dim()->set_size(1); } found_unknown_shapes = true; } ConvolutionDimensions dims = OpDimensionsFromInputs(x_shape, op_info, &found_unknown_shapes); int64_t ops = 0; if (dims.kx <= dims.sx && dims.ky <= dims.sy) { // Non-overlapping window. ops = dims.batch * dims.iz * (dims.ix * dims.iy + dims.ox * dims.oy); } else { // Overlapping window. ops = dims.batch * dims.iz * (dims.ix * dims.iy + dims.ox * dims.oy * (dims.kx * dims.ky + 1)); } auto s = PredictDefaultNodeCosts(ops, op_context, &found_unknown_shapes, node_costs); node_costs->max_memory = node_costs->num_total_output_bytes(); return s; }
0
C++
CWE-369
Divide By Zero
The product divides a value by zero.
https://cwe.mitre.org/data/definitions/369.html
vulnerable
TfLiteStatus LessEval(TfLiteContext* context, TfLiteNode* node) { const TfLiteTensor* input1 = GetInput(context, node, kInputTensor1); const TfLiteTensor* input2 = GetInput(context, node, kInputTensor2); TfLiteTensor* output = GetOutput(context, node, kOutputTensor); bool requires_broadcast = !HaveSameShapes(input1, input2); switch (input1->type) { case kTfLiteFloat32: Comparison<float, reference_ops::LessFn>(input1, input2, output, requires_broadcast); break; case kTfLiteInt32: Comparison<int32_t, reference_ops::LessFn>(input1, input2, output, requires_broadcast); break; case kTfLiteInt64: Comparison<int64_t, reference_ops::LessFn>(input1, input2, output, requires_broadcast); break; case kTfLiteUInt8: ComparisonQuantized<uint8_t, reference_ops::LessFn>( input1, input2, output, requires_broadcast); break; case kTfLiteInt8: ComparisonQuantized<int8_t, reference_ops::LessFn>(input1, input2, output, requires_broadcast); break; default: context->ReportError(context, "Does not support type %d, requires float|int|uint8", input1->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
bool DNP3_Base::AddToBuffer(Endpoint* endp, int target_len, const u_char** data, int* len) { if ( ! target_len ) return true; int to_copy = min(*len, target_len - endp->buffer_len); memcpy(endp->buffer + endp->buffer_len, *data, to_copy); *data += to_copy; *len -= to_copy; endp->buffer_len += to_copy; return endp->buffer_len == target_len; }
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
Jsi_RC jsi_evalcode(jsi_Pstate *ps, Jsi_Func *func, Jsi_OpCodes *opcodes, jsi_ScopeChain *scope, Jsi_Value *fargs, Jsi_Value *_this, Jsi_Value **vret) { Jsi_Interp *interp = ps->interp; if (interp->exited) return JSI_ERROR; Jsi_RC rc; jsi_Frame frame = *interp->framePtr; frame.parent = interp->framePtr; interp->framePtr = &frame; frame.parent->child = interp->framePtr = &frame; frame.ps = ps; frame.ingsc = scope; frame.incsc = fargs; frame.inthis = _this; frame.opcodes = opcodes; frame.fileName = ((func && func->script)?func->script:interp->curFile); frame.funcName = interp->curFunction; frame.dirName = interp->curDir; if (frame.fileName && frame.fileName == frame.parent->fileName) frame.logflag = frame.parent->logflag; else frame.logflag = 0; frame.level = frame.parent->level+1; frame.evalFuncPtr = func; frame.arguments = NULL; // if (func && func->strict) // frame.strict = 1; if (interp->curIp) frame.parent->line = interp->curIp->Line; frame.ip = interp->curIp; interp->refCount++; interp->level++; Jsi_IncrRefCount(interp, fargs); rc = jsi_evalcode_sub(ps, opcodes, scope, fargs, _this, *vret); Jsi_DecrRefCount(interp, fargs); if (interp->didReturn == 0 && !interp->exited) { if ((interp->evalFlags&JSI_EVAL_RETURN)==0) Jsi_ValueMakeUndef(interp, vret); /*if (interp->framePtr->Sp != oldSp) //TODO: at some point after memory refs??? Jsi_LogBug("Stack not balance after execute script");*/ } if (frame.arguments) Jsi_DecrRefCount(interp, frame.arguments); interp->didReturn = 0; interp->refCount--; interp->level--; interp->framePtr = frame.parent; interp->framePtr->child = NULL; interp->curIp = frame.ip; if (interp->exited) rc = JSI_ERROR; return rc; }
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
inline bool operator ==(const MaskedIP& l, const MaskedIP& r) { auto shift = std::max((l.v6 ? 128 : 32) - l.prefix, (r.v6 ? 128 : 32) - r.prefix); ceph_assert(shift > 0); return (l.addr >> shift) == (r.addr >> shift); }
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
AP4_AvccAtom::InspectFields(AP4_AtomInspector& inspector) { inspector.AddField("Configuration Version", m_ConfigurationVersion); const char* profile_name = GetProfileName(m_Profile); if (profile_name) { inspector.AddField("Profile", profile_name); } else { inspector.AddField("Profile", m_Profile); } inspector.AddField("Profile Compatibility", m_ProfileCompatibility, AP4_AtomInspector::HINT_HEX); inspector.AddField("Level", m_Level); inspector.AddField("NALU Length Size", m_NaluLengthSize); for (unsigned int i=0; i<m_SequenceParameters.ItemCount(); i++) { inspector.AddField("Sequence Parameter", m_SequenceParameters[i].GetData(), m_SequenceParameters[i].GetDataSize()); } for (unsigned int i=0; i<m_PictureParameters.ItemCount(); i++) { inspector.AddField("Picture Parameter", m_PictureParameters[i].GetData(), m_PictureParameters[i].GetDataSize()); } return AP4_SUCCESS; }
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
TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { const TfLiteTensor* input = GetInput(context, node, kInputTensor); TfLiteTensor* output = GetOutput(context, node, kOutputTensor); TF_LITE_ENSURE_EQ(context, NumInputs(node), 1); TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1); TF_LITE_ENSURE_TYPES_EQ(context, input->type, kTfLiteFloat32); output->type = input->type; TfLiteIntArray* output_size = TfLiteIntArrayCopy(input->dims); return context->ResizeTensor(context, output, output_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
bool MemFile::seek(int64_t offset, int whence /* = SEEK_SET */) { assertx(m_len != -1); if (whence == SEEK_CUR) { if (offset >= 0 && offset < bufferedLen()) { setReadPosition(getReadPosition() + offset); setPosition(getPosition() + offset); return true; } offset += getPosition(); whence = SEEK_SET; } // invalidate the current buffer setWritePosition(0); setReadPosition(0); if (whence == SEEK_SET) { if (offset < 0) return false; m_cursor = offset; } else if (whence == SEEK_END) { if (m_len + offset < 0) return false; m_cursor = m_len + offset; } else { return false; } setPosition(m_cursor); 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
hphp_libxml_input_buffer_noload(const char *URI, xmlCharEncoding enc) { return nullptr; }
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 copyBytes(InStream* is, int length) { while (length > 0) { int n = check(1, length); is->readBytes(ptr, n); ptr += n; length -= n; } }
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_segment_descriptor(struct x86_emulate_ctxt *ctxt, u16 selector, int seg) { u8 cpl = ctxt->ops->cpl(ctxt); return __load_segment_descriptor(ctxt, selector, seg, cpl, false); }
0
C++
NVD-CWE-noinfo
null
null
null
vulnerable
void setPrivate(bool p) { is_private = p; }
1
C++
CWE-200
Exposure of Sensitive Information to an Unauthorized Actor
The product exposes sensitive information to an actor that is not explicitly authorized to have access to that information.
https://cwe.mitre.org/data/definitions/200.html
safe