project
string
commit_id
string
target
int64
func
string
cwe
string
big_vul_idx
string
idx
int64
hash
string
size
float64
message
string
dataset
string
tensorflow
240655511cd3e701155f944a972db71b6c0b1bb6
0
Status ConstantFolding::MaterializeConstantValuedNode( NodeDef* node, const GraphProperties& properties) { if (disable_compressed_tensor_optimization_) { return Status::OK(); } // Nodes that generate constant-valued outputs can be represented compactly in // compressed format, regardless of their shape. const std::vector<OpInfo::TensorProperties>& output_props = properties.GetOutputProperties(node->name()); if (output_props.size() != 1) return Status::OK(); const auto& output_shape = output_props[0].shape(); if (!PartialTensorShape(output_shape).IsFullyDefined()) { return Status::OK(); } if (IsFill(*node)) { const auto output_dtype = output_props[0].dtype(); NodeDef* input_node = nullptr; for (int i = 0; i < 2; ++i) { input_node = node_map_->GetNode(NodeName(node->input(i))); if (input_node == nullptr || !IsReallyConstant(*input_node)) { return Status::OK(); } } TF_RETURN_IF_ERROR(CheckAttrExists(*input_node, "value")); // Copy the input tensor to the fill node, set the output shape and data // type, and change the node type to Const. TensorProto* tensor = (*node->mutable_attr())["value"].mutable_tensor(); const TensorProto& input_tensor = input_node->attr().at("value").tensor(); if (!input_tensor.tensor_content().empty()) { // Convert the value to repeated field format, so we can use the // decompression mechanism to store only a single value in the constant // node, even if the shape specified in the original Fill is large. Tensor t; if (!t.FromProto(input_tensor)) { return errors::InvalidArgument( "Could not construct Tensor form TensorProto in node: ", input_node->name()); } tensor->clear_tensor_content(); t.AsProtoField(tensor); } else { *tensor = input_tensor; } *(tensor->mutable_tensor_shape()) = output_shape; (*node->mutable_attr())["dtype"].set_type(output_dtype); node->mutable_attr()->erase("T"); node->mutable_attr()->erase("index_type"); node->set_op("Const"); for (int i = 0; i < 2; i++) { // Change inputs to a control inputs. const string ctrl_dep = AsControlDependency(node->input(i)); node_map_->UpdateInput(node->name(), node->input(i), ctrl_dep); node->set_input(i, ctrl_dep); } graph_modified_ = true; } else { double value = (IsZerosLike(*node) ? 0.0 : (IsOnesLike(*node) ? 1.0 : -1.0)); if (value >= 0) { TF_RETURN_IF_ERROR(ReplaceOperationWithConstant( value, properties, output_shape, node, graph_)); } } return Status::OK(); }
null
null
219,024
63325446667799358575021930230689922056
66
Eliminate `CHECK`-fails from `IsSimplifiableReshape` via `MakeShape(<invalid shape>)` PiperOrigin-RevId: 409166738 Change-Id: I7f0a3590b8acae3f3e3e2fe636e1f5ef285693cf
other
tensorflow
240655511cd3e701155f944a972db71b6c0b1bb6
0
float QuantizedTypeMinAsFloat(DataType data_type) { switch (data_type) { case DT_QINT8: return Eigen::NumTraits<qint8>::lowest(); case DT_QUINT8: return Eigen::NumTraits<quint8>::lowest(); case DT_QINT16: return Eigen::NumTraits<qint16>::lowest(); case DT_QUINT16: return Eigen::NumTraits<quint16>::lowest(); case DT_QINT32: return Eigen::NumTraits<qint32>::lowest(); default: return 0.0f; } }
null
null
219,025
21380022143099259719264847413252334155
16
Eliminate `CHECK`-fails from `IsSimplifiableReshape` via `MakeShape(<invalid shape>)` PiperOrigin-RevId: 409166738 Change-Id: I7f0a3590b8acae3f3e3e2fe636e1f5ef285693cf
other
tensorflow
240655511cd3e701155f944a972db71b6c0b1bb6
0
bool ConstantFolding::MaybeFoldable(const NodeDef& node, const GraphProperties* properties) const { // Skip constants, they're already folded if (IsConstant(node)) { return false; } // Don't fold stateful ops such as TruncatedNormal. if (!IsFreeOfSideEffect(node)) { return false; } // Skips nodes that must be preserved except allowlisted nodes. if (nodes_to_preserve_.find(node.name()) != nodes_to_preserve_.end() && nodes_allowlist_.find(node.name()) == nodes_allowlist_.end()) { return false; } // Skip control flow nodes, they can't be folded. if (ModifiesFrameInfo(node)) { return false; } // Skips ops that don't benefit from folding. if (IsPlaceholder(node)) { return false; } // `FakeParam` op is used as a placeholder in If branch function. It doesn't // have a valid output when executed. if (IsFakeParam(node)) { return false; } if (node.op() == "AccumulateNV2") { return false; } // Removing LoopCond nodes can screw up the partitioner. if (node.op() == "LoopCond") { return false; } if (!fold_quantization_emulation_ && IsQuantizationEmulation(node)) { return false; } const string& op = node.op(); if (op.find("Save") != string::npos || op.find("Restore") != string::npos || op.find("Reader") != string::npos) { return false; } if (op.find("Quantized") != string::npos || absl::StartsWith(op, "Sparse")) { return false; } // Don't fold nodes that contain TPU attributes. // TODO(rmlarsen): We should be able to fold many of these nodes as long as we // properly forward custom attributes, b/119051778. if (HasTPUAttributes(node)) { return false; } const OpDef* op_def = nullptr; Status status = OpRegistry::Global()->LookUpOpDef(node.op(), &op_def); if (!status.ok()) { return false; } // Don't fold ops without outputs. if (op_def->output_arg_size() == 0) { return false; } // Don't fold DT_VARIANT outputs as this can cause problems with XLA compile. // TODO(rmlarsen): Only do this for XLA_* devices. for (const OpDef::ArgDef& output_arg : op_def->output_arg()) { if (output_arg.type() == DT_VARIANT) { return false; } } // Don't fold nodes that have no outgoing edges except allowlisted nodes. // Such nodes could be introduced by an earlier constant folding pass and are // preserved in case users want to fetch their values; re-processing them // would lead to an error of adding a duplicated node to graph. const auto& outputs = node_map_->GetOutputs(node.name()); if (outputs.empty() && nodes_allowlist_.find(node.name()) == nodes_allowlist_.end()) { return false; } return true; }
null
null
219,026
31907344994230389968019754277653415879
88
Eliminate `CHECK`-fails from `IsSimplifiableReshape` via `MakeShape(<invalid shape>)` PiperOrigin-RevId: 409166738 Change-Id: I7f0a3590b8acae3f3e3e2fe636e1f5ef285693cf
other
tensorflow
240655511cd3e701155f944a972db71b6c0b1bb6
0
Status ConstantFolding::ReplaceOperationWithConstantTensor(DataType dtype, TensorProto* value, NodeDef* node, GraphDef* graph) { if (dtype == DT_VARIANT) return Status::OK(); node->set_op("Const"); EraseRegularNodeAttributes(node); (*node->mutable_attr())["dtype"].set_type(dtype); (*node->mutable_attr())["value"].mutable_tensor()->Swap(value); // Convert all inputs to control dependencies. for (int i = 0; i < node->input_size(); ++i) { if (IsControlInput(node->input(i))) { break; } const string ctrl_dep = AddControlDependency(node->input(i), graph, node_map_.get()); node_map_->UpdateInput(node->name(), node->input(i), ctrl_dep); node->set_input(i, ctrl_dep); } DedupControlInputs(node); graph_modified_ = true; return Status::OK(); }
null
null
219,027
85221051528175061978971833920580128621
23
Eliminate `CHECK`-fails from `IsSimplifiableReshape` via `MakeShape(<invalid shape>)` PiperOrigin-RevId: 409166738 Change-Id: I7f0a3590b8acae3f3e3e2fe636e1f5ef285693cf
other
tensorflow
240655511cd3e701155f944a972db71b6c0b1bb6
0
Status ConstantFolding::MaterializeBroadcastGradientArgs( const NodeDef& node, const GraphProperties& properties) { const NodeDef* shape_node1 = node_map_->GetNode(node.input(0)); const NodeDef* shape_node2 = node_map_->GetNode(node.input(1)); if (shape_node1 == nullptr || (shape_node1->op() != "Shape" && !IsReallyConstant(*shape_node1)) || shape_node2 == nullptr || (shape_node2->op() != "Shape" && !IsReallyConstant(*shape_node2))) { return Status::OK(); } // Don't optimize this again if it was already optimized and folded. if (OptimizedNodeExists(node, "-folded-1") || OptimizedNodeExists(node, "-folded-2")) { return Status::OK(); } int64_t min_id = 0; BCast::Vec shape1; if (!ExtractShape(*shape_node1, properties, &shape1, &min_id)) { return Status::OK(); } BCast::Vec shape2; if (!ExtractShape(*shape_node2, properties, &shape2, &min_id)) { return Status::OK(); } // A value of -1 means we don't known anything about the dimension. Replace // the -1 values with unique dimension ids since we don't want two '-1' // dimensions to be considered equal. for (auto& id : shape1) { if (id == -1) { id = --min_id; } } for (auto& id : shape2) { if (id == -1) { id = --min_id; } } // Beware: the reduction dimensions computed by the BCast class are valid iff // we assume that two distinct symbolic dimensions can't be equal and a // symbolic dimension can't be equal to 1. This is often but not always true, // so to make this optimization safe we filter out these cases. const int common_dims = std::min(shape1.size(), shape2.size()); for (int i = 0; i < common_dims; ++i) { if (shape1[i] >= 0 && shape2[i] >= 0) { continue; } if (shape1[i] != shape2[i]) { // We're either dealing with 2 different symbolic dimensions or a symbolic // and a know dimensions. We can't be sure whether both are equal or not, // so we can't be sure whether we'll be broadcasting or not. return Status::OK(); } } // These extra dims could be equal to 1, in which case there is no // broadcasting. It could also be greater than 1, in which case there would // be broadcasting. Since we don't know, we'll just punt. for (int i = common_dims, end = shape1.size(); i < end; ++i) { if (shape1[i] < 0) { return Status::OK(); } } for (int i = common_dims, end = shape2.size(); i < end; ++i) { if (shape2[i] < 0) { return Status::OK(); } } BCast bcast(shape1, shape2); if (!bcast.IsValid()) { return Status::OK(); } BCast::Vec reduce_dims[2]; reduce_dims[0] = bcast.grad_x_reduce_idx(); reduce_dims[1] = bcast.grad_y_reduce_idx(); TF_RETURN_IF_ERROR(CheckAttrExists(node, "T")); const DataType type = node.attr().at("T").type(); NodeDef* out[2]; for (int j = 0; j < 2; ++j) { int reduction_indices = reduce_dims[j].size(); Tensor value(type, TensorShape({reduction_indices})); for (int i = 0; i < reduction_indices; ++i) { if (type == DT_INT32) { value.vec<int32>()(i) = reduce_dims[j][i]; } else { value.vec<int64_t>()(i) = reduce_dims[j][i]; } } string const_name = OptimizedNodeName(node, strings::StrCat("-bcastargs-", j)); out[j] = node_map_->GetNode(const_name); if (out[j] == nullptr) { out[j] = graph_->add_node(); TF_RETURN_IF_ERROR( CreateNodeDef(const_name, TensorValue(&value), out[j])); out[j]->set_device(node.device()); node_map_->AddNode(const_name, out[j]); string ctrl_dep = AddControlDependency(node.name(), graph_, node_map_.get()); *out[j]->add_input() = ctrl_dep; node_map_->AddOutput(NodeName(ctrl_dep), const_name); } } // We make a copy here since we might mutate the set. const auto outputs = node_map_->GetOutputs(node.name()); for (NodeDef* output : outputs) { for (int k = 0; k < output->input_size(); ++k) { int port; string node_name = ParseNodeName(output->input(k), &port); if (node_name == node.name() && port >= 0 && port < 2 && out[port]) { *output->mutable_input(k) = out[port]->name(); node_map_->UpdateInput(output->name(), node_name, out[port]->name()); } } } return Status::OK(); }
null
null
219,028
178508258287488618512385888764736972104
122
Eliminate `CHECK`-fails from `IsSimplifiableReshape` via `MakeShape(<invalid shape>)` PiperOrigin-RevId: 409166738 Change-Id: I7f0a3590b8acae3f3e3e2fe636e1f5ef285693cf
other
tensorflow
240655511cd3e701155f944a972db71b6c0b1bb6
0
bool ConstantFolding::ReduceDivToReciprocalMul(GraphDef* optimized_graph, NodeDef* node) { // Strength reduce floating point division by a constant Div(x, const) to // multiplication by the reciprocal Mul(x, Reciprocal(const)). This in turn // will be constant folded to Mul(x, 1.0/const). if (node->input_size() >= 2 && (IsDiv(*node) || IsRealDiv(*node) || IsXdivy(*node))) { const string& const_input = node->input(1); const NodeDef* denom = node_map_->GetNode(const_input); CHECK(denom != nullptr); if (!IsReallyConstant(*denom)) { return false; } if (node->attr().count("T") == 0) { return false; } DataType type = node->attr().at("T").type(); // Skip integer division. if (IsDiv(*node) && !(DataTypeIsFloating(type) || DataTypeIsComplex(type))) { return false; } // Insert new reciprocal op and change node from Div to Mul. NodeDef* reciprocal_node = optimized_graph->add_node(); reciprocal_node->set_name(OptimizedNodeName(*node, "_recip")); reciprocal_node->set_op("Reciprocal"); reciprocal_node->set_device(node->device()); reciprocal_node->add_input(const_input); (*reciprocal_node->mutable_attr())["T"].set_type(type); // Re-wire inputs and outputs. if (IsXdivy(*node)) { node->set_op("MulNoNan"); node->set_input(1, node->input(0)); node->set_input(0, reciprocal_node->name()); } else { node->set_op("Mul"); node->set_input(1, reciprocal_node->name()); } node_map_->AddNode(reciprocal_node->name(), reciprocal_node); node_map_->UpdateOutput(node->name(), const_input, reciprocal_node->name()); return true; } return false; }
null
null
219,029
137305277613182812682368723353388796995
47
Eliminate `CHECK`-fails from `IsSimplifiableReshape` via `MakeShape(<invalid shape>)` PiperOrigin-RevId: 409166738 Change-Id: I7f0a3590b8acae3f3e3e2fe636e1f5ef285693cf
other
tensorflow
240655511cd3e701155f944a972db71b6c0b1bb6
0
Status ConstantFolding::SimplifyTile(const GraphProperties& properties, bool use_shape_info, GraphDef* optimized_graph, NodeDef* node) { Tensor multiplies; if (use_shape_info && IsTile(*node) && GetTensorFromConstNode(node->input(1), &multiplies)) { // The node is replaceable iff all values in multiplies are 1. bool replaceable = true; if (multiplies.dtype() == DT_INT32) { for (int j = 0; replaceable && j < multiplies.vec<int>().size(); ++j) { replaceable &= multiplies.vec<int>()(j) == 1; } } else { for (int j = 0; replaceable && j < multiplies.vec<int64_t>().size(); ++j) { replaceable &= multiplies.vec<int64_t>()(j) == 1; } } if (replaceable) { ReplaceOperationWithIdentity(0, properties, node, optimized_graph); } } return Status::OK(); }
null
null
219,030
218353677476359788000904815005829513367
24
Eliminate `CHECK`-fails from `IsSimplifiableReshape` via `MakeShape(<invalid shape>)` PiperOrigin-RevId: 409166738 Change-Id: I7f0a3590b8acae3f3e3e2fe636e1f5ef285693cf
other
tensorflow
240655511cd3e701155f944a972db71b6c0b1bb6
0
string ConstantFolding::OptimizedNodeName(const NodeDef& node, StringPiece suffix) const { return AddPrefixToNodeName(strings::StrCat(node.name(), suffix), kConstantFoldingConst); }
null
null
219,031
208629780969475171648053710156722971912
5
Eliminate `CHECK`-fails from `IsSimplifiableReshape` via `MakeShape(<invalid shape>)` PiperOrigin-RevId: 409166738 Change-Id: I7f0a3590b8acae3f3e3e2fe636e1f5ef285693cf
other
tensorflow
240655511cd3e701155f944a972db71b6c0b1bb6
0
Status ConstantFolding::IsSimplifiableReshape( const NodeDef& node, const GraphProperties& properties) const { if (!IsReshape(node)) { return errors::Internal("Node ", node.name(), " is not a Reshape node"); } if (2 > node.input_size()) { return errors::Internal("Node ", node.name(), " must have at most 2 inputs but has ", node.input_size()); } const NodeDef* new_shape = node_map_->GetNode(node.input(1)); if (!IsReallyConstant(*new_shape)) { return errors::Internal("Node ", node.name(), " has shape ", new_shape->DebugString(), " which is not a constant"); } TensorVector outputs; auto outputs_cleanup = gtl::MakeCleanup([&outputs] { for (const auto& output : outputs) { delete output.tensor; } }); Status s = EvaluateNode(*new_shape, TensorVector(), &outputs); if (!s.ok()) { return errors::Internal("Could not evaluate node ", node.name()); } if (outputs.size() != 1) { return errors::Internal("Node ", node.name(), " must have exactly 1 output but has ", outputs.size()); } const std::vector<OpInfo::TensorProperties>& props = properties.GetInputProperties(node.name()); if (props.empty()) { return errors::Internal("Node ", node.name(), " has no properties"); } const OpInfo::TensorProperties& prop = props[0]; if (prop.dtype() == DT_INVALID) { return errors::Internal("Node ", node.name(), " has property ", prop.DebugString(), " with invalid dtype"); } const PartialTensorShape shape(prop.shape()); if (!shape.IsFullyDefined()) { return errors::Internal("Node ", node.name(), " has property ", prop.DebugString(), " with shape ", shape.DebugString(), " which is not fully defined"); } PartialTensorShape new_dims; if (outputs[0]->dtype() == DT_INT32) { std::vector<int32> shp; for (int i = 0; i < outputs[0]->NumElements(); ++i) { int32_t dim = outputs[0]->flat<int32>()(i); shp.push_back(dim); } s = TensorShapeUtils::MakeShape(shp, &new_dims); if (!s.ok()) return s; } else { std::vector<int64_t> shp; for (int i = 0; i < outputs[0]->NumElements(); ++i) { int64_t dim = outputs[0]->flat<int64_t>()(i); shp.push_back(dim); } s = TensorShapeUtils::MakeShape(shp, &new_dims); if (!s.ok()) return s; } if (!shape.IsCompatibleWith(new_dims)) { return errors::Internal("Expected shape ", shape.DebugString(), "to be compatible with ", new_dims.DebugString()); } return Status::OK(); }
null
null
219,032
132577827558394112513412900015246449104
76
Eliminate `CHECK`-fails from `IsSimplifiableReshape` via `MakeShape(<invalid shape>)` PiperOrigin-RevId: 409166738 Change-Id: I7f0a3590b8acae3f3e3e2fe636e1f5ef285693cf
other
tensorflow
240655511cd3e701155f944a972db71b6c0b1bb6
0
ConstantFolding::ConstantFolding(RewriterConfig::Toggle opt_level, DeviceBase* cpu_device, bool disable_compressed_tensor_optimization, bool fold_quantization_emulation) : opt_level_(opt_level), cpu_device_(cpu_device), disable_compressed_tensor_optimization_( disable_compressed_tensor_optimization), fold_quantization_emulation_(fold_quantization_emulation) { resource_mgr_.reset(new ResourceMgr()); }
null
null
219,033
237868382910656164570014182595487574660
11
Eliminate `CHECK`-fails from `IsSimplifiableReshape` via `MakeShape(<invalid shape>)` PiperOrigin-RevId: 409166738 Change-Id: I7f0a3590b8acae3f3e3e2fe636e1f5ef285693cf
other
tensorflow
240655511cd3e701155f944a972db71b6c0b1bb6
0
bool ConstantFolding::SimplifyReduction(GraphDef* optimized_graph, const GraphProperties& properties, NodeDef* node) { bool indices_is_empty = false; if (!IsReductionWithConstantIndices(*node, &indices_is_empty)) { return false; } if (indices_is_empty) { return ReplaceReductionWithIdentity(node); } bool is_single_element_op = false; TensorShapeProto input_tensor_shape, output_tensor_shape; if (!IsReductionCandidateForSimplification( *node, properties, &input_tensor_shape, &output_tensor_shape, &is_single_element_op)) { return false; } // Get the reduction indices. string reduction_indices_input = node->input(1); NodeDef* reduction_indices = node_map_->GetNode(reduction_indices_input); TensorVector reduction_indices_vector; auto outputs_cleanup = gtl::MakeCleanup([&reduction_indices_vector] { for (const auto& out : reduction_indices_vector) { delete out.tensor; } }); if (!EvaluateNode(*reduction_indices, TensorVector(), &reduction_indices_vector) .ok() || reduction_indices_vector.size() != 1) { return false; } bool keep_dims = node->attr().count("keep_dims") > 0 && node->attr().at("keep_dims").b(); bool simplifiable_to_reshape = is_single_element_op && !keep_dims && (node->attr().count("T") > 0); bool simplifiable_to_identity = IsReductionSimplifiableToIdentity( *node, input_tensor_shape, keep_dims, reduction_indices_vector); if (simplifiable_to_reshape) { // Const node to output shape. const int new_num_dimensions = output_tensor_shape.dim_size(); Tensor tensor(DT_INT32, TensorShape({new_num_dimensions})); for (int i = 0; i < new_num_dimensions; i++) { tensor.flat<int>()(i) = 1; } TensorValue shape_value(&tensor); NodeDef* shape_node = optimized_graph->add_node(); if (!CreateNodeDef(OptimizedNodeName(*node, "_shape_const"), shape_value, shape_node) .ok()) { return false; } shape_node->set_device(node->device()); node_map_->AddNode(shape_node->name(), shape_node); // Control dependency to ensure shape_node is in the correct frame. shape_node->add_input(AsControlDependency(reduction_indices_input)); node_map_->AddOutput(NodeName(reduction_indices_input), shape_node->name()); // Optimize node to Reshape. node->set_op("Reshape"); node_map_->UpdateInput(node->name(), node->input(1), shape_node->name()); node->set_input(1, shape_node->name()); node->mutable_attr()->erase("keep_dims"); node->mutable_attr()->erase("Tidx"); AttrValue attr_type_indices; attr_type_indices.set_type(DT_INT32); (*node->mutable_attr())["Tshape"] = attr_type_indices; return true; } else if (simplifiable_to_identity) { return ReplaceReductionWithIdentity(node); } return false; }
null
null
219,034
74455905047720011442439498896081762494
75
Eliminate `CHECK`-fails from `IsSimplifiableReshape` via `MakeShape(<invalid shape>)` PiperOrigin-RevId: 409166738 Change-Id: I7f0a3590b8acae3f3e3e2fe636e1f5ef285693cf
other
tensorflow
240655511cd3e701155f944a972db71b6c0b1bb6
0
bool HasTPUAttributes(const NodeDef& node) { AttrSlice attrs(node); for (const auto& attr : attrs) { if (attr.first.find("_tpu_") != attr.first.npos) { return true; } } return false; }
null
null
219,035
2092122212104213946228504223840833239
9
Eliminate `CHECK`-fails from `IsSimplifiableReshape` via `MakeShape(<invalid shape>)` PiperOrigin-RevId: 409166738 Change-Id: I7f0a3590b8acae3f3e3e2fe636e1f5ef285693cf
other
tensorflow
240655511cd3e701155f944a972db71b6c0b1bb6
0
bool ConstantFolding::PartialAssocOpConstFolding(GraphDef* optimized_graph, GraphProperties* properties, NodeDef* node) { // Partial constant folding for associative operators: // Split AddN/AccumulateNV2 to enable partial // folding of ops when more than one but not all inputs are constant. // For AddN and AccumulateNV2, we may furthermore reorder inputs, since // addition is commutative. if (!IsAggregate(*node) || !IsCommutative(*node)) return false; const int num_non_control_inputs = NumNonControlInputs(*node); if (num_non_control_inputs <= 2) return false; const int num_control_inputs = node->input_size() - num_non_control_inputs; std::vector<int> const_inputs; std::vector<int> nonconst_inputs; for (int i = 0; i < node->input_size(); ++i) { const string& input = node->input(i); const NodeDef* input_node = node_map_->GetNode(NodeName(input)); if (input_node == nullptr) return false; if (!IsControlInput(input) && IsReallyConstant(*input_node)) { const_inputs.push_back(i); } else { // Non-const and control inputs. nonconst_inputs.push_back(i); } } // Promote AccumulateNV2 with all constant inputs to AddN, since it is // a fake node that cannot be constant folded by itself. int const_inputs_size = const_inputs.size(); if (const_inputs_size == num_non_control_inputs && node->op() == "AccumulateNV2") { node->set_op("AddN"); node->mutable_attr()->erase("shape"); return true; } const string new_node_name = OptimizedNodeName( *node, strings::StrCat("_partial_split_", const_inputs_size)); if (const_inputs_size > 1 && const_inputs_size < num_non_control_inputs && !node_map_->NodeExists(new_node_name)) { NodeDef* added_node = optimized_graph->add_node(); *added_node = *node; // Always use AddN for the constant node, since AccumulateNV2 is a fake // node that cannot be constant folded, since it does not have a kernel. added_node->set_op("AddN"); added_node->mutable_attr()->erase("shape"); added_node->set_name(new_node_name); node_map_->AddNode(added_node->name(), added_node); added_node->clear_input(); for (int i : const_inputs) { added_node->add_input(node->input(i)); node_map_->UpdateOutput(NodeName(node->input(i)), node->name(), added_node->name()); } // Overwrite the first const input with the added node. node->set_input(const_inputs[0], added_node->name()); node_map_->AddOutput(added_node->name(), node->name()); nonconst_inputs.push_back(const_inputs[0]); // Compact the remaining inputs to the original node. std::sort(nonconst_inputs.begin(), nonconst_inputs.end()); int idx = 0; for (int i : nonconst_inputs) { if (idx != i) { node->set_input(idx, node->input(i)); } ++idx; } node->mutable_input()->DeleteSubrange(nonconst_inputs.size(), const_inputs.size() - 1); (*node->mutable_attr())["N"].set_i(node->input_size() - num_control_inputs); properties->ClearInputProperties(node->name()); (*added_node->mutable_attr())["N"].set_i(const_inputs.size()); return true; } return false; }
null
null
219,036
140668278640556404810466814023033950850
76
Eliminate `CHECK`-fails from `IsSimplifiableReshape` via `MakeShape(<invalid shape>)` PiperOrigin-RevId: 409166738 Change-Id: I7f0a3590b8acae3f3e3e2fe636e1f5ef285693cf
other
tensorflow
240655511cd3e701155f944a972db71b6c0b1bb6
0
void ConstantFolding::ReplaceOperationWithSnapshot( int input_to_forward, const GraphProperties& properties, NodeDef* node, GraphDef* graph) { // If the graph contains no ops that mutate their inputs, we can // use Identity instead of Snapshot. if (!graph_contains_assign_or_inplace_op_) { ReplaceOperationWithIdentity(input_to_forward, properties, node, graph); return; } const DataType dtype = GetDataTypeFromNodeOrProps(*node, properties); if (dtype == DT_INVALID) return; node->set_op("Snapshot"); EraseRegularNodeAttributes(node); (*node->mutable_attr())["T"].set_type(dtype); // Propagate the designated input through the Snapshot. node->mutable_input()->SwapElements(0, input_to_forward); // Add all other inputs as control dependencies. for (int i = 1; i < node->input_size(); ++i) { if (IsControlInput(node->input(i))) { break; } const string ctrl_dep = AddControlDependency(node->input(i), graph, node_map_.get()); node_map_->UpdateInput(node->name(), node->input(i), ctrl_dep); node->set_input(i, ctrl_dep); } graph_modified_ = true; }
null
null
219,037
66569318465954283488656064296855420538
30
Eliminate `CHECK`-fails from `IsSimplifiableReshape` via `MakeShape(<invalid shape>)` PiperOrigin-RevId: 409166738 Change-Id: I7f0a3590b8acae3f3e3e2fe636e1f5ef285693cf
other
tensorflow
240655511cd3e701155f944a972db71b6c0b1bb6
0
Status ConstantFolding::SimplifyGraph( GraphDef* optimized_graph, GraphProperties* properties, absl::flat_hash_set<string>* nodes_to_not_simplify) { for (int i = 0; i < optimized_graph->node_size(); ++i) { NodeDef* node = optimized_graph->mutable_node(i); // TODO(lyandy): Move nodes to not simplify check into SimplifyNode and // generalize to only restrict certain simplifications. if (nodes_to_not_simplify->find(node->name()) == nodes_to_not_simplify->end()) { if (HasTPUAttributes(*node)) { nodes_to_not_simplify->insert(node->name()); continue; } TF_RETURN_IF_ERROR(SimplifyNode(node, optimized_graph, properties)); } } return Status::OK(); }
null
null
219,038
308782300105091543940003487470964663892
19
Eliminate `CHECK`-fails from `IsSimplifiableReshape` via `MakeShape(<invalid shape>)` PiperOrigin-RevId: 409166738 Change-Id: I7f0a3590b8acae3f3e3e2fe636e1f5ef285693cf
other
tensorflow
240655511cd3e701155f944a972db71b6c0b1bb6
0
bool PackedValuesNotEqual(T a, T b) { return a != b; }
null
null
219,039
333353420618306991731267356495469409252
3
Eliminate `CHECK`-fails from `IsSimplifiableReshape` via `MakeShape(<invalid shape>)` PiperOrigin-RevId: 409166738 Change-Id: I7f0a3590b8acae3f3e3e2fe636e1f5ef285693cf
other
tensorflow
240655511cd3e701155f944a972db71b6c0b1bb6
0
bool ConstantFolding::PrepareConstantPushDown( const NodeDef& parent, const GraphProperties& properties, bool must_have_properties, ConstantPushDownContext* ctx) const { if (ctx == nullptr || !has_fetch_ || NumNonControlInputs(parent) != 2) { return false; } NodeDef* left_child = node_map_->GetNode(parent.input(0)); NodeDef* right_child = node_map_->GetNode(parent.input(1)); // Sanity check for missing children. if (left_child == nullptr || right_child == nullptr) { return false; } ctx->left_child_is_const = IsReallyConstant(*left_child); ctx->right_child_is_const = IsReallyConstant(*right_child); ctx->op_child = ctx->left_child_is_const ? right_child : left_child; ctx->const_child = ctx->left_child_is_const ? left_child : right_child; // Nothing to do unless the parent has a constant child node. if (!ctx->left_child_is_const && !ctx->right_child_is_const) { return false; } // Don't move nodes across devices. if (parent.device() != ctx->op_child->device() || parent.device() != ctx->const_child->device()) { return false; } // Make sure that it is safe to change the value of the child node result. if (ctx->op_child->input_size() < 2 || nodes_to_preserve_.find(ctx->op_child->name()) != nodes_to_preserve_.end() || NumNonControlOutputs(*ctx->op_child, *node_map_) > 1) { return false; } // Don't apply reassociation to floating point types of low precision. // The danger of significant numerical changes is too high. if (!CheckAttrExists(parent, "T").ok()) return false; DataType dtype = parent.attr().at("T").type(); if (dtype == DT_BFLOAT16 || dtype == DT_HALF) { return false; } // Don't rewrite the tree if it might create cycles. // TODO(rmlarsen): Add back handling of control dependency from op to C. const auto& child_output = node_map_->GetOutputs(ctx->op_child->name()); if (child_output.find(ctx->const_child) != child_output.end()) { return false; } // Get leaf nodes. ctx->left_leaf = node_map_->GetNode(ctx->op_child->input(0)); ctx->right_leaf = node_map_->GetNode(ctx->op_child->input(1)); ctx->left_leaf_is_const = IsReallyConstant(*ctx->left_leaf); ctx->right_leaf_is_const = IsReallyConstant(*ctx->right_leaf); if (ctx->left_leaf_is_const && ctx->right_leaf_is_const) { // Child is already foldable, leave it alone. return false; } // Don't move nodes across devices. if (parent.device() != ctx->left_leaf->device() || parent.device() != ctx->right_leaf->device()) { return false; } // Get shape and type information. ctx->parent_input_props = &properties.GetInputProperties(parent.name()); ctx->op_child_input_props = &properties.GetInputProperties(ctx->op_child->name()); if (must_have_properties && (ctx->parent_input_props == nullptr || ctx->parent_input_props->size() < 2 || ctx->op_child_input_props == nullptr || ctx->op_child_input_props->size() < 2)) { return false; } VLOG(1) << "\n++++++++ PushDown for node " << parent.name() << ": " << parent.op() << "(" << left_child->op() << ", " << right_child->op() << ")"; return true; }
null
null
219,040
130618686661240783959990134012123082896
87
Eliminate `CHECK`-fails from `IsSimplifiableReshape` via `MakeShape(<invalid shape>)` PiperOrigin-RevId: 409166738 Change-Id: I7f0a3590b8acae3f3e3e2fe636e1f5ef285693cf
other
tensorflow
240655511cd3e701155f944a972db71b6c0b1bb6
0
DataType GetDataTypeFromNodeOrProps(const NodeDef& node, const GraphProperties& properties) { DataType dtype = DT_INVALID; if (node.attr().count("T") == 1) { dtype = node.attr().at("T").type(); } else if (node.attr().count("dtype") == 1) { dtype = node.attr().at("dtype").type(); } else if (IsLogicalOr(node) || IsLogicalAnd(node)) { dtype = DT_BOOL; } else { auto output_props = properties.GetOutputProperties(node.name()); if (!output_props.empty()) { dtype = output_props[0].dtype(); } } return dtype; }
null
null
219,041
307657578984013781167331573279746178480
17
Eliminate `CHECK`-fails from `IsSimplifiableReshape` via `MakeShape(<invalid shape>)` PiperOrigin-RevId: 409166738 Change-Id: I7f0a3590b8acae3f3e3e2fe636e1f5ef285693cf
other
tensorflow
240655511cd3e701155f944a972db71b6c0b1bb6
0
bool ConstantFolding::PartialConstPropThroughIdentityN(NodeDef* node) { // Partial constant propagation through IdentityN. if (!(IsIdentityN(*node) || IsIdentityNSingleInput(*node)) || !HasRegularInputs(*node)) return false; std::vector<int> inputs_to_forward; for (int input_idx = 0; input_idx < node->input_size(); ++input_idx) { const string& input = node->input(input_idx); if (IsControlInput(input)) { return false; } const NodeDef* input_node = node_map_->GetNode(NodeName(input)); if (input_node == nullptr) { LOG(ERROR) << "Bad input: " << input; return false; } // Forward constant inputs to outputs and add a control dependency on // the IdentityN node. if (IsReallyConstant(*input_node)) { inputs_to_forward.push_back(input_idx); } } return ForwardInputs(node, inputs_to_forward); }
null
null
219,042
312050015123848276718496690996193230284
25
Eliminate `CHECK`-fails from `IsSimplifiableReshape` via `MakeShape(<invalid shape>)` PiperOrigin-RevId: 409166738 Change-Id: I7f0a3590b8acae3f3e3e2fe636e1f5ef285693cf
other
tensorflow
240655511cd3e701155f944a972db71b6c0b1bb6
0
void ConstantFolding::ReplaceOperationWithIdentity( int input_to_forward, const GraphProperties& properties, NodeDef* node, GraphDef* graph) { if (input_to_forward < 0 || input_to_forward >= node->input_size()) return; const DataType dtype = GetDataTypeFromNodeOrProps(*node, properties); if (dtype == DT_INVALID) return; node->set_op("Identity"); EraseRegularNodeAttributes(node); (*node->mutable_attr())["T"].set_type(dtype); // Propagate the designated input through the identity. node->mutable_input()->SwapElements(0, input_to_forward); // Add all other inputs as control dependencies. for (int i = 1; i < node->input_size(); ++i) { if (IsControlInput(node->input(i))) { break; } const string ctrl_dep = AddControlDependency(node->input(i), graph, node_map_.get()); node_map_->UpdateInput(node->name(), node->input(i), ctrl_dep); node->set_input(i, ctrl_dep); } graph_modified_ = true; }
null
null
219,043
328641482668790091856322916266116633532
24
Eliminate `CHECK`-fails from `IsSimplifiableReshape` via `MakeShape(<invalid shape>)` PiperOrigin-RevId: 409166738 Change-Id: I7f0a3590b8acae3f3e3e2fe636e1f5ef285693cf
other
tensorflow
240655511cd3e701155f944a972db71b6c0b1bb6
0
Status ConstantFolding::SimplifyNode(NodeDef* node, GraphDef* optimized_graph, GraphProperties* properties) { bool graph_modified_cached = graph_modified_; graph_modified_ = false; bool use_shape_info = properties->has_properties(); RETURN_IF_MODIFIED(RemoveSplitOrSplitV(*properties, optimized_graph, node)); RETURN_IF_ERROR_OR_MODIFIED(RemoveShuffleOrTranspose( *properties, use_shape_info, optimized_graph, node)); RETURN_IF_MODIFIED( RemoveRandomShuffle(*properties, use_shape_info, optimized_graph, node)); RETURN_IF_ERROR_OR_MODIFIED( RemoveReverse(*properties, use_shape_info, optimized_graph, node)); RETURN_IF_ERROR_OR_MODIFIED( SimplifySlice(*properties, use_shape_info, optimized_graph, node)); RETURN_IF_ERROR_OR_MODIFIED( SimplifyStridedSlice(*properties, use_shape_info, optimized_graph, node)); RETURN_IF_ERROR_OR_MODIFIED( SimplifyTile(*properties, use_shape_info, optimized_graph, node)); RETURN_IF_ERROR_OR_MODIFIED( SimplifyPad(*properties, use_shape_info, optimized_graph, node)); RETURN_IF_MODIFIED( SimplifySqueeze(*properties, use_shape_info, optimized_graph, node)); SET_AND_RETURN_IF_MODIFIED(SimplifyPack(optimized_graph, node)); SET_AND_RETURN_IF_MODIFIED(MoveConstantsPastEnter(optimized_graph, node)); SET_AND_RETURN_IF_MODIFIED(SimplifySwitch(optimized_graph, node)); SET_AND_RETURN_IF_MODIFIED( SimplifyReduction(optimized_graph, *properties, node)); SET_AND_RETURN_IF_MODIFIED( SimplifyReshape(*properties, use_shape_info, node)); RETURN_IF_ERROR_OR_MODIFIED(SimplifyArithmeticOperations( *properties, use_shape_info, optimized_graph, node)); SET_AND_RETURN_IF_MODIFIED(ReduceDivToReciprocalMul(optimized_graph, node)); SET_AND_RETURN_IF_MODIFIED( ConstantPushDown(properties, optimized_graph, node)); SET_AND_RETURN_IF_MODIFIED( MulConvPushDown(optimized_graph, node, *properties)); SET_AND_RETURN_IF_MODIFIED(PartialConstPropThroughIdentityN(node)); SET_AND_RETURN_IF_MODIFIED( PartialAssocOpConstFolding(optimized_graph, properties, node)); SET_AND_RETURN_IF_MODIFIED( MergeConcat(use_shape_info, properties, optimized_graph, node)); SET_AND_RETURN_IF_MODIFIED( PartialConcatConstFolding(optimized_graph, properties, node)); SET_AND_RETURN_IF_MODIFIED( ConstantPushDownBiasAdd(properties, optimized_graph, node)); SET_AND_RETURN_IF_MODIFIED(SimplifyCase(optimized_graph, node)); SET_AND_RETURN_IF_MODIFIED( SimplifySelect(*properties, optimized_graph, node)); RETURN_IF_MODIFIED( RemoveRedundantVariableUpdates(properties, optimized_graph, node)); graph_modified_ = graph_modified_cached; return Status::OK(); }
null
null
219,044
196609964531603458488348774063191233437
55
Eliminate `CHECK`-fails from `IsSimplifiableReshape` via `MakeShape(<invalid shape>)` PiperOrigin-RevId: 409166738 Change-Id: I7f0a3590b8acae3f3e3e2fe636e1f5ef285693cf
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
Bool IsHintTrack(GF_TrackBox *trak) { if (trak->Media->handler->handlerType != GF_ISOM_MEDIA_HINT) return GF_FALSE; //QT doesn't specify any InfoHeader on HintTracks if (trak->Media->information->InfoHeader && (trak->Media->information->InfoHeader->type != GF_ISOM_BOX_TYPE_HMHD) && (trak->Media->information->InfoHeader->type != GF_ISOM_BOX_TYPE_NMHD) ) return GF_FALSE; return GF_TRUE; }
null
null
219,899
271268104021514098185272663245632737443
12
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
GF_Err gf_isom_hint_blank_data(GF_ISOFile *the_file, u32 trackNumber, u8 AtBegin) { GF_TrackBox *trak; GF_HintSampleEntryBox *entry; u32 count; GF_HintPacket *pck; GF_EmptyDTE *dte; GF_Err e; trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !IsHintTrack(trak)) return GF_BAD_PARAM; e = Media_GetSampleDesc(trak->Media, trak->Media->information->sampleTable->currentEntryIndex, (GF_SampleEntryBox **) &entry, &count); if (e) return e; if (!entry->hint_sample) return GF_BAD_PARAM; count = gf_list_count(entry->hint_sample->packetTable); if (!count) return GF_BAD_PARAM; pck = (GF_HintPacket *)gf_list_get(entry->hint_sample->packetTable, count - 1); dte = (GF_EmptyDTE *) NewDTE(0); return gf_isom_hint_pck_add_dte(pck, (GF_GenericDTE *)dte, AtBegin); }
null
null
219,900
220413366207752345590237801636155090732
22
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
GF_Err gf_isom_rtp_packet_begin(GF_ISOFile *the_file, u32 trackNumber, s32 relativeTime, u8 PackingBit, u8 eXtensionBit, u8 MarkerBit, u8 PayloadType, u8 B_frame, u8 IsRepeatedPacket, u16 SequenceNumber) { GF_TrackBox *trak; GF_HintSampleEntryBox *entry; GF_RTPPacket *pck; u32 dataRefIndex; GF_Err e; trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !CheckHintFormat(trak, GF_ISOM_HINT_RTP)) return GF_BAD_PARAM; e = Media_GetSampleDesc(trak->Media, trak->Media->information->sampleTable->currentEntryIndex, (GF_SampleEntryBox **) &entry, &dataRefIndex); if (e) return e; if (!entry->hint_sample) return GF_BAD_PARAM; pck = (GF_RTPPacket *) gf_isom_hint_pck_new(entry->type); pck->P_bit = PackingBit ? 1 : 0; pck->X_bit = eXtensionBit ? 1 : 0; pck->M_bit = MarkerBit ? 1 : 0; pck->payloadType = PayloadType; pck->SequenceNumber = SequenceNumber; pck->B_bit = B_frame ? 1 : 0; pck->R_bit = IsRepeatedPacket ? 1 : 0; pck->relativeTransTime = relativeTime; return gf_list_add(entry->hint_sample->packetTable, pck); }
null
null
219,901
135210532758408519809735309262837501503
35
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
GF_Err gf_isom_sdp_clean_track(GF_ISOFile *the_file, u32 trackNumber) { GF_TrackBox *trak; GF_UserDataMap *map; GF_HintTrackInfoBox *hnti; trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak) return GF_BAD_PARAM; //currently, only RTP hinting supports SDP if (!CheckHintFormat(trak, GF_ISOM_HINT_RTP)) return GF_BAD_PARAM; map = udta_getEntry(trak->udta, GF_ISOM_BOX_TYPE_HNTI, NULL); if (!map) return GF_ISOM_INVALID_FILE; //we should have only one HNTI in the UDTA if (gf_list_count(map->boxes) != 1) return GF_ISOM_INVALID_FILE; hnti = (GF_HintTrackInfoBox *)gf_list_get(map->boxes, 0); if (!hnti->SDP) return GF_OK; //and free the SDP gf_free(((GF_SDPBox *)hnti->SDP)->sdpText); ((GF_SDPBox *)hnti->SDP)->sdpText = NULL; return GF_OK; }
null
null
219,902
300492322541877007871281127299047404766
25
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
GF_Err gf_isom_sdp_add_track_line(GF_ISOFile *the_file, u32 trackNumber, const char *text) { GF_TrackBox *trak; GF_UserDataMap *map; GF_HintTrackInfoBox *hnti; GF_SDPBox *sdp; GF_Err e; char *buf; trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak) return GF_BAD_PARAM; //currently, only RTP hinting supports SDP if (!CheckHintFormat(trak, GF_ISOM_HINT_RTP)) return GF_BAD_PARAM; map = udta_getEntry(trak->udta, GF_ISOM_BOX_TYPE_HNTI, NULL); if (!map) return GF_ISOM_INVALID_FILE; //we should have only one HNTI in the UDTA if (gf_list_count(map->boxes) != 1) return GF_ISOM_INVALID_FILE; hnti = (GF_HintTrackInfoBox *)gf_list_get(map->boxes, 0); if (!hnti->SDP) { e = hnti_on_child_box((GF_Box*)hnti, gf_isom_box_new_parent(&hnti->child_boxes, GF_ISOM_BOX_TYPE_SDP), GF_FALSE); if (e) return e; } sdp = (GF_SDPBox *) hnti->SDP; if (!sdp->sdpText) { sdp->sdpText = (char *)gf_malloc(sizeof(char) * (strlen(text) + 3)); if (!sdp->sdpText) return GF_OUT_OF_MEM; strcpy(sdp->sdpText, text); strcat(sdp->sdpText, "\r\n"); return GF_OK; } buf = (char *)gf_malloc(sizeof(char) * (strlen(sdp->sdpText) + strlen(text) + 3)); if (!buf) return GF_OUT_OF_MEM; strcpy(buf, sdp->sdpText); strcat(buf, text); strcat(buf, "\r\n"); gf_free(sdp->sdpText); ReorderSDP(buf, GF_FALSE); sdp->sdpText = buf; return GF_OK; }
null
null
219,903
127277058262359242891877620290906379075
47
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
GF_Err gf_isom_rtp_packet_set_offset(GF_ISOFile *the_file, u32 trackNumber, s32 timeOffset) { GF_RTPOBox *rtpo; GF_TrackBox *trak; GF_HintSampleEntryBox *entry; GF_RTPPacket *pck; u32 dataRefIndex, i; GF_Err e; trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !CheckHintFormat(trak, GF_ISOM_HINT_RTP)) return GF_BAD_PARAM; e = Media_GetSampleDesc(trak->Media, trak->Media->information->sampleTable->currentEntryIndex, (GF_SampleEntryBox **) &entry, &dataRefIndex); if (e) return e; if (!entry->hint_sample) return GF_BAD_PARAM; pck = (GF_RTPPacket *)gf_list_get(entry->hint_sample->packetTable, gf_list_count(entry->hint_sample->packetTable) - 1); if (!pck) return GF_BAD_PARAM; //look in the TLV i=0; while ((rtpo = (GF_RTPOBox *)gf_list_enum(pck->TLV, &i))) { if (rtpo->type == GF_ISOM_BOX_TYPE_RTPO) { rtpo->timeOffset = timeOffset; return GF_OK; } } //not found, add it rtpo = (GF_RTPOBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_RTPO); if (!rtpo) return GF_OUT_OF_MEM; rtpo->timeOffset = timeOffset; return gf_list_add(pck->TLV, rtpo); }
null
null
219,904
150489092549814489969465252307474596867
34
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
GF_Err gf_isom_new_hint_description(GF_ISOFile *the_file, u32 trackNumber, s32 HintTrackVersion, s32 LastCompatibleVersion, u8 Rely, u32 *HintDescriptionIndex) { GF_Err e; u32 drefIndex; GF_TrackBox *trak; GF_HintSampleEntryBox *hdesc; GF_SampleDescriptionBox *stsd; GF_RelyHintBox *relyA; e = CanAccessMovie(the_file, GF_ISOM_OPEN_WRITE); if (e) return e; trak = gf_isom_get_track_from_file(the_file, trackNumber); *HintDescriptionIndex = 0; if (!trak || !IsHintTrack(trak)) return GF_BAD_PARAM; stsd = trak->Media->information->sampleTable->SampleDescription; //OK, create a new HintSampleDesc hdesc = (GF_HintSampleEntryBox *) gf_isom_box_new_parent(&stsd->child_boxes, GetHintFormat(trak)); if (!hdesc) return GF_OUT_OF_MEM; if (HintTrackVersion > 0) hdesc->HintTrackVersion = HintTrackVersion; if (LastCompatibleVersion > 0) hdesc->LastCompatibleVersion = LastCompatibleVersion; //create a data reference - WE ONLY DEAL WITH SELF-CONTAINED HINT TRACKS e = Media_CreateDataRef(the_file, trak->Media->information->dataInformation->dref, NULL, NULL, &drefIndex); if (e) return e; hdesc->dataReferenceIndex = drefIndex; *HintDescriptionIndex = gf_list_count(stsd->child_boxes); //RTP needs a default timeScale... use the media one. if (CheckHintFormat(trak, GF_ISOM_HINT_RTP)) { e = gf_isom_rtp_set_timescale(the_file, trackNumber, *HintDescriptionIndex, trak->Media->mediaHeader->timeScale); if (e) return e; } if (!Rely) return GF_OK; //we need a rely box (common to all protocols) relyA = (GF_RelyHintBox *) gf_isom_box_new_parent(&hdesc->child_boxes, GF_ISOM_BOX_TYPE_RELY); if (!relyA) return GF_OUT_OF_MEM; if (Rely == 1) { relyA->preferred = 1; } else { relyA->required = 1; } return GF_OK; }
null
null
219,905
75209380054053311945350862910738882693
48
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
GF_Err gf_isom_rtp_set_time_sequence_offset(GF_ISOFile *the_file, u32 trackNumber, u32 HintDescriptionIndex, u32 SequenceNumberOffset) { GF_TrackBox *trak; GF_HintSampleEntryBox *hdesc; u32 i, count; GF_SeqOffHintEntryBox *ent; trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !CheckHintFormat(trak, GF_ISOM_HINT_RTP)) return GF_BAD_PARAM; //OK, create a new HintSampleDesc hdesc = (GF_HintSampleEntryBox *)gf_list_get(trak->Media->information->sampleTable->SampleDescription->child_boxes, HintDescriptionIndex - 1); if (!hdesc) return GF_BAD_PARAM; count = gf_list_count(hdesc->child_boxes); for (i=0; i< count; i++) { ent = (GF_SeqOffHintEntryBox *)gf_list_get(hdesc->child_boxes, i); if (ent->type == GF_ISOM_BOX_TYPE_SNRO) { ent->SeqOffset = SequenceNumberOffset; return GF_OK; } } //we have to create a new entry... ent = (GF_SeqOffHintEntryBox *) gf_isom_box_new_parent(&hdesc->child_boxes, GF_ISOM_BOX_TYPE_SNRO); if (!ent) return GF_OUT_OF_MEM; ent->SeqOffset = SequenceNumberOffset; return GF_OK; }
null
null
219,906
152819496636268020176403806725005719577
28
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
GF_Err gf_isom_hint_sample_data(GF_ISOFile *the_file, u32 trackNumber, GF_ISOTrackID SourceTrackID, u32 SampleNumber, u16 DataLength, u32 offsetInSample, u8 *extra_data, u8 AtBegin) { GF_TrackBox *trak; GF_HintSampleEntryBox *entry; u32 count; u16 refIndex; GF_HintPacket *pck; GF_SampleDTE *dte; GF_Err e; GF_TrackReferenceTypeBox *hint; trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !IsHintTrack(trak)) return GF_BAD_PARAM; e = Media_GetSampleDesc(trak->Media, trak->Media->information->sampleTable->currentEntryIndex, (GF_SampleEntryBox **) &entry, &count); if (e) return e; if (!entry->hint_sample) return GF_BAD_PARAM; count = gf_list_count(entry->hint_sample->packetTable); if (!count) return GF_BAD_PARAM; pck = (GF_HintPacket *)gf_list_get(entry->hint_sample->packetTable, count - 1); dte = (GF_SampleDTE *) NewDTE(2); dte->dataLength = DataLength; dte->sampleNumber = SampleNumber; dte->byteOffset = offsetInSample; //we're getting data from another track if (SourceTrackID != trak->Header->trackID) { //get (or set) the track reference index e = Track_FindRef(trak, GF_ISOM_REF_HINT, &hint); if (e) return e; e = reftype_AddRefTrack(hint, SourceTrackID, &refIndex); if (e) return e; //WARNING: IN QT, MUST BE 0-based !!! dte->trackRefIndex = (u8) (refIndex - 1); } else { //we're in the hint track dte->trackRefIndex = (s8) -1; //basic check... if (SampleNumber > trak->Media->information->sampleTable->SampleSize->sampleCount + 1) { DelDTE((GF_GenericDTE *)dte); return GF_BAD_PARAM; } //are we in the current sample ?? if (!SampleNumber || (SampleNumber == trak->Media->information->sampleTable->SampleSize->sampleCount + 1)) { //we adding some stuff in the current sample ... dte->byteOffset += entry->hint_sample->dataLength; entry->hint_sample->AdditionalData = (char*)gf_realloc(entry->hint_sample->AdditionalData, sizeof(char) * (entry->hint_sample->dataLength + DataLength)); if (AtBegin) { if (entry->hint_sample->dataLength) memmove(entry->hint_sample->AdditionalData + DataLength, entry->hint_sample->AdditionalData, entry->hint_sample->dataLength); memcpy(entry->hint_sample->AdditionalData, extra_data, DataLength); /*offset existing DTE*/ gf_isom_hint_pck_offset(pck, DataLength, SampleNumber); } else { memcpy(entry->hint_sample->AdditionalData + entry->hint_sample->dataLength, extra_data, DataLength); } entry->hint_sample->dataLength += DataLength; //and set the sample number ... dte->sampleNumber = trak->Media->information->sampleTable->SampleSize->sampleCount + 1; } } //OK, add the entry return gf_isom_hint_pck_add_dte(pck, (GF_GenericDTE *)dte, AtBegin); }
null
null
219,907
91117415326680560569109976549015976087
68
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
GF_Err gf_isom_hint_direct_data(GF_ISOFile *the_file, u32 trackNumber, u8 *data, u32 dataLength, u8 AtBegin) { GF_TrackBox *trak; GF_HintSampleEntryBox *entry; u32 count; GF_HintPacket *pck; GF_ImmediateDTE *dte; GF_Err e; u32 offset = 0; if (!dataLength) return GF_OK; trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !IsHintTrack(trak) || (dataLength > 14)) return GF_BAD_PARAM; e = Media_GetSampleDesc(trak->Media, trak->Media->information->sampleTable->currentEntryIndex, (GF_SampleEntryBox **) &entry, &count); if (e) return e; if (!entry->hint_sample) return GF_BAD_PARAM; count = gf_list_count(entry->hint_sample->packetTable); if (!count) return GF_BAD_PARAM; pck = (GF_HintPacket *)gf_list_get(entry->hint_sample->packetTable, count - 1); dte = (GF_ImmediateDTE *) NewDTE(1); memcpy(dte->data, data + offset, dataLength); dte->dataLength = dataLength; return gf_isom_hint_pck_add_dte(pck, (GF_GenericDTE *)dte, AtBegin); }
null
null
219,908
185115103400920195473332236025141586643
26
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
GF_Err AdjustHintInfo(GF_HintSampleEntryBox *entry, u32 HintSampleNumber) { u32 offset, count, i, size; GF_Err e; offset = gf_isom_hint_sample_size(entry->hint_sample) - entry->hint_sample->dataLength; count = gf_list_count(entry->hint_sample->packetTable); for (i=0; i<count; i++) { GF_HintPacket *pck = (GF_HintPacket *)gf_list_get(entry->hint_sample->packetTable, i); if (offset && entry->hint_sample->dataLength) { //adjust any offset in this packet e = gf_isom_hint_pck_offset(pck, offset, HintSampleNumber); if (e) return e; } //adjust the max packet size for this sample entry... size = gf_isom_hint_pck_length(pck); if (entry->MaxPacketSize < size) entry->MaxPacketSize = size; } return GF_OK; }
null
null
219,909
65194287227990007641546770469666732654
21
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
GF_Err gf_isom_sdp_get(GF_ISOFile *movie, const char **sdp, u32 *length) { GF_UserDataMap *map; GF_HintTrackInfoBox *hnti; GF_RTPBox *rtp; *length = 0; *sdp = NULL; if (!movie || !movie->moov) return GF_BAD_PARAM; //check if we have a udta ... if (!movie->moov->udta) return GF_OK; //find a hnti in the udta map = udta_getEntry(movie->moov->udta, GF_ISOM_BOX_TYPE_HNTI, NULL); if (!map) return GF_OK; //there should be one and only one hnti if (gf_list_count(map->boxes) != 1) return GF_ISOM_INVALID_FILE; hnti = (GF_HintTrackInfoBox *)gf_list_get(map->boxes, 0); if (!hnti->SDP) return GF_OK; rtp = (GF_RTPBox *) hnti->SDP; *length = (u32) strlen(rtp->sdpText); *sdp = rtp->sdpText; return GF_OK; }
null
null
219,910
278950694622581546073130431174968971392
26
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
GF_Err gf_isom_rtp_set_time_offset(GF_ISOFile *the_file, u32 trackNumber, u32 HintDescriptionIndex, u32 TimeOffset) { GF_TrackBox *trak; GF_HintSampleEntryBox *hdesc; u32 i, count; GF_TimeOffHintEntryBox *ent; trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !CheckHintFormat(trak, GF_ISOM_HINT_RTP)) return GF_BAD_PARAM; //OK, create a new HintSampleDesc hdesc = (GF_HintSampleEntryBox *) gf_list_get(trak->Media->information->sampleTable->SampleDescription->child_boxes, HintDescriptionIndex - 1); if (!hdesc) return GF_BAD_PARAM; count = gf_list_count(hdesc->child_boxes); for (i=0; i< count; i++) { ent = (GF_TimeOffHintEntryBox *)gf_list_get(hdesc->child_boxes, i); if (ent->type == GF_ISOM_BOX_TYPE_TSRO) { ent->TimeOffset = TimeOffset; return GF_OK; } } //we have to create a new entry... ent = (GF_TimeOffHintEntryBox *) gf_isom_box_new_parent(&hdesc->child_boxes, GF_ISOM_BOX_TYPE_TSRO); if (!ent) return GF_OUT_OF_MEM; ent->TimeOffset = TimeOffset; return GF_OK; }
null
null
219,911
299386598907120483351723843347283773828
29
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
u32 GetHintFormat(GF_TrackBox *trak) { GF_HintMediaHeaderBox *hmhd = (GF_HintMediaHeaderBox *)trak->Media->information->InfoHeader; if (!hmhd || (hmhd->type != GF_ISOM_BOX_TYPE_HMHD)) return 0; if (!hmhd || !hmhd->subType) { GF_Box *a = (GF_Box *)gf_list_get(trak->Media->information->sampleTable->SampleDescription->child_boxes, 0); if (!hmhd) return a ? a->type : 0; if (a) hmhd->subType = a->type; return hmhd->subType; } return hmhd->subType; }
null
null
219,912
237946925746433357630342190571369610530
14
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
GF_Err gf_isom_sdp_add_line(GF_ISOFile *movie, const char *text) { GF_UserDataMap *map; GF_RTPBox *rtp; GF_Err e; GF_HintTrackInfoBox *hnti; char *buf; if (!movie->moov) return GF_BAD_PARAM; //check if we have a udta ... if (!movie->moov->udta) { e = moov_on_child_box((GF_Box*)movie->moov, gf_isom_box_new_parent(&movie->moov->child_boxes, GF_ISOM_BOX_TYPE_UDTA), GF_FALSE); if (e) return e; } //find a hnti in the udta map = udta_getEntry(movie->moov->udta, GF_ISOM_BOX_TYPE_HNTI, NULL); if (!map) { e = udta_on_child_box((GF_Box *)movie->moov->udta, gf_isom_box_new(GF_ISOM_BOX_TYPE_HNTI), GF_FALSE); if (e) return e; map = udta_getEntry(movie->moov->udta, GF_ISOM_BOX_TYPE_HNTI, NULL); } //there should be one and only one hnti if (!gf_list_count(map->boxes) ) { e = udta_on_child_box((GF_Box *)movie->moov->udta, gf_isom_box_new(GF_ISOM_BOX_TYPE_HNTI), GF_FALSE); if (e) return e; } else if (gf_list_count(map->boxes) < 1) return GF_ISOM_INVALID_FILE; hnti = (GF_HintTrackInfoBox *)gf_list_get(map->boxes, 0); if (!hnti->SDP) { GF_Box *a = gf_isom_box_new_ex(GF_ISOM_BOX_TYPE_RTP, GF_ISOM_BOX_TYPE_HNTI, 0, GF_FALSE); if (!a) return GF_OUT_OF_MEM; hnti_on_child_box((GF_Box*)hnti, a, GF_FALSE); if (!hnti->child_boxes) hnti->child_boxes = gf_list_new(); gf_list_add(hnti->child_boxes, a); } rtp = (GF_RTPBox *) hnti->SDP; if (!rtp->sdpText) { rtp->sdpText = (char*)gf_malloc(sizeof(char) * (strlen(text) + 3)); if (!rtp->sdpText) return GF_OUT_OF_MEM; strcpy(rtp->sdpText, text); strcat(rtp->sdpText, "\r\n"); return GF_OK; } buf = (char*)gf_malloc(sizeof(char) * (strlen(rtp->sdpText) + strlen(text) + 3)); if (!buf) return GF_OUT_OF_MEM; strcpy(buf, rtp->sdpText); strcat(buf, text); strcat(buf, "\r\n"); gf_free(rtp->sdpText); ReorderSDP(buf, GF_TRUE); rtp->sdpText = buf; return GF_OK; }
null
null
219,913
254175740184986403141734791030911558921
60
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
GF_Err gf_isom_sdp_clean(GF_ISOFile *movie) { GF_UserDataMap *map; GF_HintTrackInfoBox *hnti; //check if we have a udta ... if (!movie->moov || !movie->moov->udta) return GF_OK; //find a hnti in the udta map = udta_getEntry(movie->moov->udta, GF_ISOM_BOX_TYPE_HNTI, NULL); if (!map) return GF_OK; //there should be one and only one hnti if (gf_list_count(map->boxes) != 1) return GF_ISOM_INVALID_FILE; hnti = (GF_HintTrackInfoBox *)gf_list_get(map->boxes, 0); //remove and destroy the entry gf_list_rem(map->boxes, 0); gf_isom_box_del((GF_Box *)hnti); return GF_OK; }
null
null
219,914
18663410246315132013826381540931260154
21
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
u32 gf_isom_get_payt_count(GF_ISOFile *the_file, u32 trackNumber) { u32 i, count; GF_TrackBox *trak; GF_UserDataMap *map; GF_HintInfoBox *hinf; GF_PAYTBox *payt; trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak) return 0; if (!CheckHintFormat(trak, GF_ISOM_HINT_RTP)) return 0; map = udta_getEntry(trak->udta, GF_ISOM_BOX_TYPE_HINF, NULL); if (!map) return 0; if (gf_list_count(map->boxes) != 1) return 0; hinf = (GF_HintInfoBox *)gf_list_get(map->boxes, 0); count = 0; i = 0; while ((payt = (GF_PAYTBox*)gf_list_enum(hinf->child_boxes, &i))) { if (payt->type == GF_ISOM_BOX_TYPE_PAYT) count++; } return count; }
null
null
219,915
211348651656250043928377034183105578703
24
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
GF_Err gf_isom_setup_hint_track(GF_ISOFile *movie, u32 trackNumber, GF_ISOHintFormat HintType) { GF_Err e; GF_TrackBox *trak; GF_TrackReferenceBox *tref; GF_TrackReferenceTypeBox *dpnd; GF_HintMediaHeaderBox *hmhd; //UDTA related ... GF_UserDataBox *udta; //what do we support switch (HintType) { case GF_ISOM_HINT_RTP: break; default: return GF_NOT_SUPPORTED; } e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE); if (e) return e; trak = gf_isom_get_track_from_file(movie, trackNumber); if (!trak) return gf_isom_last_error(movie); //check we have a hint ... if ( !IsHintTrack(trak)) { return GF_BAD_PARAM; } hmhd = (GF_HintMediaHeaderBox *)trak->Media->information->InfoHeader; //make sure the subtype was not already defined if (hmhd->subType) return GF_BAD_PARAM; //store the HintTrack format for later use... hmhd->subType = HintType; //hint tracks always have a tref and everything ... if (!trak->References) { tref = (GF_TrackReferenceBox *) gf_isom_box_new_parent(&trak->child_boxes, GF_ISOM_BOX_TYPE_TREF); if (!tref) return GF_OUT_OF_MEM; e = trak_on_child_box((GF_Box*)trak, (GF_Box *)tref, GF_FALSE); if (e) return e; } tref = trak->References; //do we have a hint reference on this trak ??? e = Track_FindRef(trak, GF_ISOM_BOX_TYPE_HINT, &dpnd); if (e) return e; //if yes, return false (existing hint track...) if (dpnd) return GF_BAD_PARAM; //create our dep dpnd = (GF_TrackReferenceTypeBox *) gf_isom_box_new_parent(&tref->child_boxes, GF_ISOM_BOX_TYPE_REFT); if (!dpnd) return GF_OUT_OF_MEM; dpnd->reference_type = GF_ISOM_BOX_TYPE_HINT; //for RTP, we need to do some UDTA-related stuff... if (HintType != GF_ISOM_HINT_RTP) return GF_OK; if (!trak->udta) { //create one udta = (GF_UserDataBox *) gf_isom_box_new_parent(&trak->child_boxes, GF_ISOM_BOX_TYPE_UDTA); if (!udta) return GF_OUT_OF_MEM; e = trak_on_child_box((GF_Box*)trak, (GF_Box *) udta, GF_FALSE); if (e) return e; } udta = trak->udta; //HNTI e = udta_on_child_box((GF_Box *)udta, gf_isom_box_new(GF_ISOM_BOX_TYPE_HNTI), GF_FALSE); if (e) return e; /* //NAME e = udta_on_child_box((GF_Box *)udta, gf_isom_box_new(GF_ISOM_BOX_TYPE_NAME)); if (e) return e; //HINF return udta_on_child_box((GF_Box *)udta, gf_isom_box_new(GF_ISOM_BOX_TYPE_HINF)); */ return GF_OK; }
null
null
219,916
255041810364764904754887133327904349187
80
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
static void ReorderSDP(char *sdp_text, Bool is_movie_sdp) { char *cur; GF_List *lines = gf_list_new(); cur = sdp_text; while (cur) { char b; char *st = strstr(cur, "\r\n"); assert(st); st += 2; if (!st[0]) { AddSDPLine(lines, gf_strdup(cur), is_movie_sdp); break; } b = st[0]; st[0] = 0; AddSDPLine(lines, gf_strdup(cur), is_movie_sdp); st[0] = b; cur = st; } strcpy(sdp_text, ""); while (gf_list_count(lines)) { cur = (char *)gf_list_get(lines, 0); gf_list_rem(lines, 0); strcat(sdp_text, cur); gf_free(cur); } gf_list_del(lines); }
null
null
219,917
74901256357799333266260420107719477198
29
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
static void AddSDPLine(GF_List *list, char *sdp_text, Bool is_movie_sdp) { const char *sdp_order; u32 i, count = gf_list_count(list); char fc = sdp_text[0]; sdp_order = (is_movie_sdp) ? "vosiuepcbzkatr" : "micbka"; for (i=0; i<count; i++) { char *l = (char *)gf_list_get(list, i); char *s1 = (char *)strchr(sdp_order, l[0]); char *s2 = (char *)strchr(sdp_order, fc); if (s1 && s2 && (strlen(s2)>strlen(s1))) { gf_list_insert(list, sdp_text, i); return; } } gf_list_add(list, sdp_text); }
null
null
219,918
98472167440378562335349646213298687464
18
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
GF_Err gf_isom_rtp_packet_set_flags(GF_ISOFile *the_file, u32 trackNumber, u8 PackingBit, u8 eXtensionBit, u8 MarkerBit, u8 disposable_packet, u8 IsRepeatedPacket) { GF_TrackBox *trak; GF_HintSampleEntryBox *entry; GF_RTPPacket *pck; u32 dataRefIndex, ind; GF_Err e; trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !CheckHintFormat(trak, GF_ISOM_HINT_RTP)) return GF_BAD_PARAM; e = Media_GetSampleDesc(trak->Media, trak->Media->information->sampleTable->currentEntryIndex, (GF_SampleEntryBox **) &entry, &dataRefIndex); if (e) return e; if (!entry->hint_sample) return GF_BAD_PARAM; ind = gf_list_count(entry->hint_sample->packetTable); if (!ind) return GF_BAD_PARAM; pck = (GF_RTPPacket *)gf_list_get(entry->hint_sample->packetTable, ind-1); pck->P_bit = PackingBit ? 1 : 0; pck->X_bit = eXtensionBit ? 1 : 0; pck->M_bit = MarkerBit ? 1 : 0; pck->B_bit = disposable_packet ? 1 : 0; pck->R_bit = IsRepeatedPacket ? 1 : 0; return GF_OK; }
null
null
219,919
293453141137838680878786004229024799820
31
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
const char *gf_isom_get_payt_info(GF_ISOFile *the_file, u32 trackNumber, u32 index, u32 *payID) { u32 i, count; GF_TrackBox *trak; GF_UserDataMap *map; GF_HintInfoBox *hinf; GF_PAYTBox *payt; trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !index) return NULL; if (!CheckHintFormat(trak, GF_ISOM_HINT_RTP)) return NULL; map = udta_getEntry(trak->udta, GF_ISOM_BOX_TYPE_HINF, NULL); if (!map) return NULL; if (gf_list_count(map->boxes) != 1) return NULL; hinf = (GF_HintInfoBox *)gf_list_get(map->boxes, 0); count = 0; i = 0; while ((payt = (GF_PAYTBox*)gf_list_enum(hinf->child_boxes, &i))) { if (payt->type == GF_ISOM_BOX_TYPE_PAYT) { count++; if (count == index) { if (payID) *payID=payt->payloadCode; return payt->payloadString; } } } return NULL; }
null
null
219,920
210074761557105885880164353644682872330
30
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
GF_Err gf_isom_end_hint_sample(GF_ISOFile *the_file, u32 trackNumber, u8 IsRandomAccessPoint) { GF_TrackBox *trak; GF_HintSampleEntryBox *entry; u32 dataRefIndex; GF_Err e; GF_BitStream *bs; GF_ISOSample *samp; trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !IsHintTrack(trak)) return GF_BAD_PARAM; e = Media_GetSampleDesc(trak->Media, trak->Media->information->sampleTable->currentEntryIndex, (GF_SampleEntryBox **) &entry, &dataRefIndex); if (e) return e; if (!entry->hint_sample) return GF_BAD_PARAM; //first of all, we need to adjust the offset for data referenced IN THIS hint sample //and get some PckSize e = AdjustHintInfo(entry, trak->Media->information->sampleTable->SampleSize->sampleCount + 1); if (e) return e; //ok, let's write the sample bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); e = gf_isom_hint_sample_write(entry->hint_sample, bs); if (e) { gf_bs_del(bs); return e; } samp = gf_isom_sample_new(); samp->CTS_Offset = 0; samp->IsRAP = IsRandomAccessPoint; samp->DTS = entry->hint_sample->TransmissionTime; //get the sample gf_bs_get_content(bs, &samp->data, &samp->dataLength); gf_bs_del(bs); //finally add the sample e = gf_isom_add_sample(the_file, trackNumber, trak->Media->information->sampleTable->currentEntryIndex, samp); gf_isom_sample_del(&samp); //and delete the sample in our entry ... gf_isom_hint_sample_del(entry->hint_sample); entry->hint_sample = NULL; return e; }
null
null
219,921
158103088005568807083436501970262073740
45
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
GF_Err gf_isom_hint_sample_description_data(GF_ISOFile *the_file, u32 trackNumber, GF_ISOTrackID SourceTrackID, u32 StreamDescriptionIndex, u16 DataLength, u32 offsetInDescription, u8 AtBegin) { GF_TrackBox *trak; GF_HintSampleEntryBox *entry; u32 count; u16 refIndex; GF_HintPacket *pck; GF_StreamDescDTE *dte; GF_Err e; GF_TrackReferenceTypeBox *hint; trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !IsHintTrack(trak)) return GF_BAD_PARAM; e = Media_GetSampleDesc(trak->Media, trak->Media->information->sampleTable->currentEntryIndex, (GF_SampleEntryBox **) &entry, &count); if (e) return e; if (!entry->hint_sample) return GF_BAD_PARAM; count = gf_list_count(entry->hint_sample->packetTable); if (!count) return GF_BAD_PARAM; pck = (GF_HintPacket *)gf_list_get(entry->hint_sample->packetTable, count - 1); dte = (GF_StreamDescDTE *) NewDTE(3); dte->byteOffset = offsetInDescription; dte->dataLength = DataLength; dte->streamDescIndex = StreamDescriptionIndex; if (SourceTrackID == trak->Header->trackID) { dte->trackRefIndex = (s8) -1; } else { //get (or set) the track reference index e = Track_FindRef(trak, GF_ISOM_REF_HINT, &hint); if (e) return e; e = reftype_AddRefTrack(hint, SourceTrackID, &refIndex); if (e) return e; //WARNING: IN QT, MUST BE 0-based !!! dte->trackRefIndex = (u8) (refIndex - 1); } return gf_isom_hint_pck_add_dte(pck, (GF_GenericDTE *)dte, AtBegin); }
null
null
219,922
242800491694738465939206196811356653579
38
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
GF_Err gf_isom_sdp_track_get(GF_ISOFile *the_file, u32 trackNumber, const char **sdp, u32 *length) { GF_TrackBox *trak; GF_UserDataMap *map; GF_HintTrackInfoBox *hnti; GF_SDPBox *sdpa; *sdp = NULL; *length = 0; trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak) return GF_BAD_PARAM; if (!trak->udta) return GF_OK; map = udta_getEntry(trak->udta, GF_ISOM_BOX_TYPE_HNTI, NULL); if (!map) return GF_ISOM_INVALID_FILE; //we should have only one HNTI in the UDTA if (gf_list_count(map->boxes) != 1) return GF_ISOM_INVALID_FILE; hnti = (GF_HintTrackInfoBox *)gf_list_get(map->boxes, 0); if (!hnti->SDP) return GF_OK; sdpa = (GF_SDPBox *) hnti->SDP; *length = (u32) strlen(sdpa->sdpText); *sdp = sdpa->sdpText; return GF_OK; }
null
null
219,923
338370763598761451166600377320121134018
28
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
GF_Err gf_isom_begin_hint_sample(GF_ISOFile *the_file, u32 trackNumber, u32 HintDescriptionIndex, u32 TransmissionTime) { GF_TrackBox *trak; u32 descIndex, dataRefIndex; GF_HintSample *samp; GF_HintSampleEntryBox *entry; GF_Err e; trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !IsHintTrack(trak)) return GF_BAD_PARAM; //assert we're increasing the timing... if (trak->Media->information->sampleTable->TimeToSample->w_LastDTS > TransmissionTime) return GF_BAD_PARAM; //store the descIndex for this sample descIndex = HintDescriptionIndex; if (!HintDescriptionIndex) { descIndex = trak->Media->information->sampleTable->currentEntryIndex; } e = Media_GetSampleDesc(trak->Media, descIndex, (GF_SampleEntryBox **) &entry, &dataRefIndex); if (e) return e; if (!entry || !dataRefIndex) return GF_BAD_PARAM; //set the current to this one if no packet is used if (entry->hint_sample) return GF_BAD_PARAM; trak->Media->information->sampleTable->currentEntryIndex = descIndex; //create a new sample based on the protocol type of the hint description entry samp = gf_isom_hint_sample_new(entry->type); if (!samp) return GF_NOT_SUPPORTED; //OK, let's store the time of this sample samp->TransmissionTime = TransmissionTime; //OK, set our sample in the entry... entry->hint_sample = samp; return GF_OK; }
null
null
219,924
46946908096206453677684696708321339309
36
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
GF_Err gf_isom_rtp_set_timescale(GF_ISOFile *the_file, u32 trackNumber, u32 HintDescriptionIndex, u32 TimeScale) { GF_TrackBox *trak; GF_HintSampleEntryBox *hdesc; u32 i, count; GF_TSHintEntryBox *ent; trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !CheckHintFormat(trak, GF_ISOM_HINT_RTP)) return GF_BAD_PARAM; //OK, create a new HintSampleDesc hdesc = (GF_HintSampleEntryBox *)gf_list_get(trak->Media->information->sampleTable->SampleDescription->child_boxes, HintDescriptionIndex - 1); if (!hdesc) return GF_BAD_PARAM; count = gf_list_count(hdesc->child_boxes); for (i=0; i< count; i++) { ent = (GF_TSHintEntryBox *)gf_list_get(hdesc->child_boxes, i); if (ent->type == GF_ISOM_BOX_TYPE_TIMS) { ent->timeScale = TimeScale; return GF_OK; } } //we have to create a new entry... ent = (GF_TSHintEntryBox *) gf_isom_box_new_parent(&hdesc->child_boxes, GF_ISOM_BOX_TYPE_TIMS); if (!ent) return GF_OUT_OF_MEM; ent->timeScale = TimeScale; return GF_OK; }
null
null
219,925
292189839692510489774428973643368163843
29
fixed #1904
other
gpac
ad18ece95fa064efc0995c4ab2c985f77fb166ec
0
Bool CheckHintFormat(GF_TrackBox *trak, u32 HintType) { if (!IsHintTrack(trak)) return GF_FALSE; if (GetHintFormat(trak) != HintType) return GF_FALSE; return GF_TRUE; }
null
null
219,926
317536793013640395475854124678291362831
6
fixed #1904
other
tensorflow
6b5adc0877de832b2a7c189532dbbbc64622eeb6
0
Status ConstantFolding::EvaluateOneFoldable(const NodeDef& node, std::vector<NodeDef>* outputs, bool* result_too_large) { TensorVector inputs; TensorVector output_tensors; auto inputs_cleanup = gtl::MakeCleanup([&inputs, &output_tensors] { for (const auto& input : inputs) { delete input.tensor; } for (const auto& output : output_tensors) { if (output.tensor) { delete output.tensor; } } }); size_t total_inputs_size = 0; for (const auto& input : node.input()) { const TensorId input_tensor = ParseTensorName(input); if (input_tensor.index() < 0) { // Control dependency break; } const NodeDef* input_node = node_map_->GetNode(input); if (!IsReallyConstant(*input_node)) { return Status(error::INVALID_ARGUMENT, strings::StrCat("Can't fold ", node.name(), ", its ", input, " isn't constant")); } TF_RETURN_IF_ERROR(CheckAttrExists(*input_node, "value")); const TensorProto& raw_val = input_node->attr().at("value").tensor(); if (raw_val.dtype() == DT_INVALID) { return Status( error::INVALID_ARGUMENT, strings::StrCat("A tensor in the input node, with TensorId of ", input_tensor.ToString(), " has a dtype of DT_INVALID.")); } if (IsRefType(raw_val.dtype())) { return errors::InvalidArgument( "Not allowed to construct a tensor with reference dtype, got ", DataTypeString(raw_val.dtype())); } Tensor* value = new Tensor(raw_val.dtype(), raw_val.tensor_shape()); if (!value->FromProto(raw_val)) { delete (value); return errors::InvalidArgument("Unable to make Tensor from proto for ", node.name(), " with shape ", raw_val.tensor_shape().DebugString()); } inputs.emplace_back(value); total_inputs_size += value->TotalBytes(); } TF_RETURN_IF_ERROR(EvaluateNode(node, inputs, &output_tensors)); if (output_tensors.empty()) { return Status(error::INVALID_ARGUMENT, "Expected at least one output."); } outputs->resize(output_tensors.size()); for (size_t i = 0; i < output_tensors.size(); i++) { string node_name = OptimizedNodeName(node, "-folded"); if (output_tensors.size() > 1) { node_name = strings::StrCat(node_name, "-", i); } if (output_tensors[i].tensor) { Status s = CreateNodeDef(node_name, output_tensors[i], &outputs->at(i), total_inputs_size); if (!s.ok()) { *result_too_large = true; return s; } } else { // Create an empty NodeDef to identify dead outputs (e.g. the output of a // switch that's not selected by the switch predicate). outputs->at(i) = NodeDef(); } } return Status::OK(); }
null
null
219,931
231987099200292982244850954107641655885
80
Prevent `CHECK`-fail when building reference tensor. The tensor constructor does not allow reference dtypes, as these should not show up explicitly. However, when passed these invalid types instead of building an invalid object the constructor crashes via a `CHECK`-fail. We have a static builder that properly handles this case but is not applicable given current usage. Instead, before calling the constructor, we can check that the dtype is not a reference type and return an error otherwise, given that the dtype is user controlled so malicious users can trigger denial of service. PiperOrigin-RevId: 409662503 Change-Id: I5892f831fde7f276cd7ab34519cf6b8061c71a59
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_add_user_middleware_module (const struct _u_request * request, struct _u_response * response, void * user_middleware_data) { struct config_elements * config = (struct config_elements *)user_middleware_data; json_t * j_module, * j_module_valid, * j_result; j_module = ulfius_get_json_body_request(request, NULL); if (j_module != NULL) { j_module_valid = is_user_middleware_module_valid(config, j_module, 1); if (check_result_value(j_module_valid, G_OK)) { j_result = add_user_middleware_module(config, j_module); if (check_result_value(j_result, G_ERROR_PARAM)) { if (json_object_get(j_result, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_result, "error")); } else { response->status = 400; } } else if (!check_result_value(j_result, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_add_user_middleware_module - Error add_user_middleware_module"); response->status = 500; } else { y_log_message(Y_LOG_LEVEL_INFO, "Event - User backend module '%s' added (%s)", json_string_value(json_object_get(j_module, "name")), json_string_value(json_object_get(j_module, "module"))); } json_decref(j_result); } else if (check_result_value(j_module_valid, G_ERROR_PARAM)) { if (json_object_get(j_module_valid, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_module_valid, "error")); } else { response->status = 400; } } else if (!check_result_value(j_module_valid, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_add_user_middleware_module - Error is_user_middleware_module_valid"); response->status = 500; } json_decref(j_module_valid); } else { response->status = 400; } json_decref(j_module); return U_CALLBACK_CONTINUE; }
null
null
219,940
235273852631064183702987165248791954450
39
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_get_user_module_list (const struct _u_request * request, struct _u_response * response, void * user_data) { UNUSED(request); struct config_elements * config = (struct config_elements *)user_data; json_t * j_module; j_module = get_user_module_list(config); if (check_result_value(j_module, G_OK)) { ulfius_set_json_body_response(response, 200, json_object_get(j_module, "module")); } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_get_user_module_list - Error get_user_module_list"); response->status = 500; } json_decref(j_module); return U_CALLBACK_CONTINUE; }
null
null
219,941
118687047158808448384251568151022598531
15
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_set_user_auth_scheme_module (const struct _u_request * request, struct _u_response * response, void * user_auth_scheme_data) { struct config_elements * config = (struct config_elements *)user_auth_scheme_data; json_t * j_module, * j_module_valid, * j_search_module; j_search_module = get_user_auth_scheme_module(config, u_map_get(request->map_url, "name")); if (check_result_value(j_search_module, G_OK)) { j_module = ulfius_get_json_body_request(request, NULL); if (j_module != NULL) { json_object_del(j_module, "enabled"); j_module_valid = is_user_auth_scheme_module_valid(config, j_module, 0); if (check_result_value(j_module_valid, G_OK)) { if (set_user_auth_scheme_module(config, u_map_get(request->map_url, "name"), j_module) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_set_user_auth_scheme_module - Error set_user_auth_scheme_module"); response->status = 500; } else { y_log_message(Y_LOG_LEVEL_INFO, "Event - User auth scheme module '%s' updated", u_map_get(request->map_url, "name")); } } else if (check_result_value(j_module_valid, G_ERROR_PARAM)) { if (json_object_get(j_module_valid, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_module_valid, "error")); } else { response->status = 400; } } else if (!check_result_value(j_module_valid, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_set_user_auth_scheme_module - Error is_user_auth_scheme_module_valid"); response->status = 500; } json_decref(j_module_valid); } else { response->status = 400; } json_decref(j_module); } else if (check_result_value(j_search_module, G_ERROR_NOT_FOUND)) { response->status = 404; } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_set_user_auth_scheme_module - Error get_user_auth_scheme_module"); response->status = 500; } json_decref(j_search_module); return U_CALLBACK_CONTINUE; }
null
null
219,942
313477835625487963903027020488154296694
41
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_user_update_profile (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; json_t * j_profile, * j_result; j_profile = ulfius_get_json_body_request(request, NULL); if (j_profile != NULL && json_is_object(j_profile)) { j_result = user_set_profile(config, json_string_value(json_object_get((json_t *)response->shared_data, "username")), j_profile); if (check_result_value(j_result, G_ERROR_PARAM)) { if (json_object_get(j_result, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_result, "error")); } else { response->status = 400; } } else if (!check_result_value(j_result, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_update_profile - Error user_set_profile"); response->status = 500; } else { y_log_message(Y_LOG_LEVEL_INFO, "Event - User '%s' updated (profile)", json_string_value(json_object_get((json_t *)response->shared_data, "username"))); } json_decref(j_result); } else { response->status = 400; } json_decref(j_profile); return U_CALLBACK_CONTINUE; }
null
null
219,943
51100912978387741529690730121253036179
27
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_add_plugin_module (const struct _u_request * request, struct _u_response * response, void * plugin_data) { struct config_elements * config = (struct config_elements *)plugin_data; json_t * j_module, * j_module_valid, * j_result; j_module = ulfius_get_json_body_request(request, NULL); if (j_module != NULL) { j_module_valid = is_plugin_module_valid(config, j_module, 1); if (check_result_value(j_module_valid, G_OK)) { j_result = add_plugin_module(config, j_module); if (check_result_value(j_result, G_ERROR_PARAM)) { if (json_object_get(j_result, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_result, "error")); } else { response->status = 400; } } else if (!check_result_value(j_result, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_add_plugin_module - Error add_plugin_module"); response->status = 500; } else { y_log_message(Y_LOG_LEVEL_INFO, "Event - Plugin module '%s' added (%s)", json_string_value(json_object_get(j_module, "name")), json_string_value(json_object_get(j_module, "module"))); } json_decref(j_result); } else if (check_result_value(j_module_valid, G_ERROR_PARAM)) { if (json_object_get(j_module_valid, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_module_valid, "error")); } else { response->status = 400; } } else if (!check_result_value(j_module_valid, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_add_plugin_module - Error is_plugin_module_valid"); response->status = 500; } json_decref(j_module_valid); } else { response->status = 400; } json_decref(j_module); return U_CALLBACK_CONTINUE; }
null
null
219,944
209344670355867147187935194763492736526
39
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_add_user_auth_scheme_module (const struct _u_request * request, struct _u_response * response, void * user_auth_scheme_data) { struct config_elements * config = (struct config_elements *)user_auth_scheme_data; json_t * j_module, * j_module_valid, * j_result; j_module = ulfius_get_json_body_request(request, NULL); if (j_module != NULL) { j_module_valid = is_user_auth_scheme_module_valid(config, j_module, 1); if (check_result_value(j_module_valid, G_OK)) { j_result = add_user_auth_scheme_module(config, j_module); if (check_result_value(j_result, G_ERROR_PARAM)) { if (json_object_get(j_result, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_result, "error")); } else { response->status = 400; } } else if (!check_result_value(j_result, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_add_user_auth_scheme_module - Error add_user_auth_scheme_module"); response->status = 500; } else { y_log_message(Y_LOG_LEVEL_INFO, "Event - User auth scheme module '%s' added (%s)", json_string_value(json_object_get(j_module, "name")), json_string_value(json_object_get(j_module, "module"))); } json_decref(j_result); } else if (check_result_value(j_module_valid, G_ERROR_PARAM)) { if (json_object_get(j_module_valid, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_module_valid, "error")); } else { response->status = 400; } } else if (!check_result_value(j_module_valid, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_add_user_auth_scheme_module - Error is_user_auth_scheme_module_valid"); response->status = 500; } json_decref(j_module_valid); } else { response->status = 400; } json_decref(j_module); return U_CALLBACK_CONTINUE; }
null
null
219,945
204919697036561265653227530713518704498
39
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_manage_client_module (const struct _u_request * request, struct _u_response * response, void * client_data) { struct config_elements * config = (struct config_elements *)client_data; json_t * j_search_module, * j_result, * j_result2; j_search_module = get_client_module(config, u_map_get(request->map_url, "name")); if (check_result_value(j_search_module, G_OK)) { if (0 == o_strcmp("enable", u_map_get(request->map_url, "action"))) { j_result = manage_client_module(config, u_map_get(request->map_url, "name"), GLEWLWYD_MODULE_ACTION_START); if (check_result_value(j_result, G_ERROR_PARAM)) { if (json_object_get(j_result, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_result, "error")); } else { response->status = 400; } } else if (!check_result_value(j_result, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_manage_client_module - Error manage_client_module enable"); response->status = 500; } json_decref(j_result); } else if (0 == o_strcmp("disable", u_map_get(request->map_url, "action"))) { j_result = manage_client_module(config, u_map_get(request->map_url, "name"), GLEWLWYD_MODULE_ACTION_STOP); if (check_result_value(j_result, G_ERROR_PARAM)) { if (json_object_get(j_result, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_result, "error")); } else { response->status = 400; } } else if (!check_result_value(j_result, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_manage_client_module - Error manage_client_module disable"); response->status = 500; } json_decref(j_result); } else if (0 == o_strcmp("reset", u_map_get(request->map_url, "action"))) { j_result = manage_client_module(config, u_map_get(request->map_url, "name"), GLEWLWYD_MODULE_ACTION_STOP); if (check_result_value(j_result, G_ERROR_PARAM)) { if (json_object_get(j_result, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_result, "error")); } else { response->status = 400; } } else if (!check_result_value(j_result, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_manage_client_module - Error manage_client_module reset (1)"); response->status = 500; } else { j_result2 = manage_client_module(config, u_map_get(request->map_url, "name"), GLEWLWYD_MODULE_ACTION_START); if (check_result_value(j_result2, G_ERROR_PARAM)) { if (json_object_get(j_result2, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_result2, "error")); } else { response->status = 400; } } else if (!check_result_value(j_result2, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_manage_client_module - Error manage_client_module reset (2)"); response->status = 500; } json_decref(j_result2); } json_decref(j_result); } else { response->status = 400; } } else if (check_result_value(j_search_module, G_ERROR_NOT_FOUND)) { response->status = 404; } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_manage_client_module - Error get_client_module"); response->status = 500; } json_decref(j_search_module); return U_CALLBACK_CONTINUE; }
null
null
219,946
315307111948570737082575701701199787651
70
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_user_auth (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; json_t * j_param = ulfius_get_json_body_request(request, NULL), * j_result = NULL; const char * ip_source = get_ip_source(request); char * issued_for = get_client_hostname(request); char * session_uid, expires[129]; time_t now; struct tm ts; time(&now); now += GLEWLWYD_DEFAULT_SESSION_EXPIRATION_COOKIE; gmtime_r(&now, &ts); strftime(expires, 128, "%a, %d %b %Y %T %Z", &ts); if (j_param != NULL) { if (json_string_length(json_object_get(j_param, "username"))) { if (json_object_get(j_param, "scheme_type") == NULL || 0 == o_strcmp(json_string_value(json_object_get(j_param, "scheme_type")), "password")) { if (json_string_length(json_object_get(j_param, "password"))) { j_result = auth_check_user_credentials(config, json_string_value(json_object_get(j_param, "username")), json_string_value(json_object_get(j_param, "password"))); if (check_result_value(j_result, G_OK)) { if ((session_uid = get_session_id(config, request)) == NULL) { session_uid = generate_session_id(); } if (user_session_update(config, session_uid, u_map_get_case(request->map_header, "user-agent"), issued_for, json_string_value(json_object_get(j_param, "username")), NULL, 1) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_auth - Error user_session_update (1)"); response->status = 500; } else { ulfius_add_cookie_to_response(response, config->session_key, session_uid, expires, 0, config->cookie_domain, "/", config->cookie_secure, 0); y_log_message(Y_LOG_LEVEL_INFO, "Event - User '%s' authenticated with password", json_string_value(json_object_get(j_param, "username"))); } o_free(session_uid); glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_VALID, 1, NULL); glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_VALID_SCHEME, 1, "scheme_type", "password", NULL); } else { if (check_result_value(j_result, G_ERROR_UNAUTHORIZED)) { y_log_message(Y_LOG_LEVEL_WARNING, "Security - Authorization invalid for username %s at IP Address %s", json_string_value(json_object_get(j_param, "username")), ip_source); } response->status = 401; glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_INVALID, 1, NULL); glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_INVALID_SCHEME, 1, "scheme_type", "password", NULL); } json_decref(j_result); } else if (json_object_get(j_param, "password") != NULL && !json_is_string(json_object_get(j_param, "password"))) { ulfius_set_string_body_response(response, 400, "password must be a string"); } else { session_uid = get_session_id(config, request); j_result = get_users_for_session(config, session_uid); if (check_result_value(j_result, G_OK)) { // Refresh username to set as default if (user_session_update(config, u_map_get(request->map_cookie, config->session_key), u_map_get_case(request->map_header, "user-agent"), issued_for, json_string_value(json_object_get(j_param, "username")), NULL, 0) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_auth - Error user_session_update (3)"); response->status = 500; } else { ulfius_add_cookie_to_response(response, config->session_key, session_uid, expires, 0, config->cookie_domain, "/", config->cookie_secure, 0); } } else if (check_result_value(j_result, G_ERROR_NOT_FOUND)) { response->status = 401; } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_auth - Error get_users_for_session"); response->status = 500; } o_free(session_uid); json_decref(j_result); } } else { if (json_string_length(json_object_get(j_param, "scheme_type")) && json_string_length(json_object_get(j_param, "scheme_name")) && json_is_object(json_object_get(j_param, "value"))) { j_result = auth_check_user_scheme(config, json_string_value(json_object_get(j_param, "scheme_type")), json_string_value(json_object_get(j_param, "scheme_name")), json_string_value(json_object_get(j_param, "username")), json_object_get(j_param, "value"), request); if (check_result_value(j_result, G_ERROR_PARAM)) { ulfius_set_string_body_response(response, 400, "bad scheme response"); } else if (check_result_value(j_result, G_ERROR_UNAUTHORIZED)) { y_log_message(Y_LOG_LEVEL_WARNING, "Security - Authorization invalid for username %s at IP Address %s", json_string_value(json_object_get(j_param, "username")), ip_source); response->status = 401; glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_INVALID, 1, NULL); glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_INVALID_SCHEME, 1, "scheme_type", json_string_value(json_object_get(j_param, "scheme_type")), "scheme_name", json_string_value(json_object_get(j_param, "scheme_name")), NULL); } else if (check_result_value(j_result, G_ERROR_NOT_FOUND)) { response->status = 404; } else if (check_result_value(j_result, G_OK)) { if ((session_uid = get_session_id(config, request)) == NULL) { session_uid = generate_session_id(); } if (user_session_update(config, session_uid, u_map_get_case(request->map_header, "user-agent"), issued_for, json_string_value(json_object_get(j_param, "username")), json_string_value(json_object_get(j_param, "scheme_name")), 1) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_auth - Error user_session_update (4)"); response->status = 500; } else { ulfius_add_cookie_to_response(response, config->session_key, session_uid, expires, 0, config->cookie_domain, "/", config->cookie_secure, 0); y_log_message(Y_LOG_LEVEL_INFO, "Event - User '%s' authenticated with scheme '%s/%s'", json_string_value(json_object_get(j_param, "username")), json_string_value(json_object_get(j_param, "scheme_type")), json_string_value(json_object_get(j_param, "scheme_name"))); } o_free(session_uid); glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_VALID, 1, NULL); glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_VALID_SCHEME, 1, "scheme_type", json_string_value(json_object_get(j_param, "scheme_type")), "scheme_name", json_string_value(json_object_get(j_param, "scheme_name")), NULL); } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_auth - Error auth_check_user_scheme"); response->status = 500; } json_decref(j_result); } else { ulfius_set_string_body_response(response, 400, "scheme_type, scheme_name and value are mandatory"); } } } else { if (json_string_length(json_object_get(j_param, "scheme_type")) && json_string_length(json_object_get(j_param, "scheme_name")) && json_is_object(json_object_get(j_param, "value"))) { j_result = auth_check_identify_scheme(config, json_string_value(json_object_get(j_param, "scheme_type")), json_string_value(json_object_get(j_param, "scheme_name")), json_object_get(j_param, "value"), request); if (check_result_value(j_result, G_ERROR_PARAM)) { ulfius_set_string_body_response(response, 400, "bad scheme response"); } else if (check_result_value(j_result, G_ERROR_UNAUTHORIZED)) { y_log_message(Y_LOG_LEVEL_WARNING, "Security - Authorization invalid for username <UNKNOWN> at IP Address %s", ip_source); response->status = 401; } else if (check_result_value(j_result, G_ERROR_NOT_FOUND)) { response->status = 404; } else if (check_result_value(j_result, G_OK)) { if ((session_uid = get_session_id(config, request)) == NULL) { session_uid = generate_session_id(); } if (user_session_update(config, session_uid, u_map_get_case(request->map_header, "user-agent"), issued_for, json_string_value(json_object_get(j_result, "username")), json_string_value(json_object_get(j_param, "scheme_name")), 1) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_auth - Error user_session_update (4)"); response->status = 500; } else { ulfius_add_cookie_to_response(response, config->session_key, session_uid, expires, 0, config->cookie_domain, "/", config->cookie_secure, 0); y_log_message(Y_LOG_LEVEL_INFO, "Event - User '%s' authenticated with scheme '%s/%s'", json_string_value(json_object_get(j_result, "username")), json_string_value(json_object_get(j_param, "scheme_type")), json_string_value(json_object_get(j_param, "scheme_name"))); } o_free(session_uid); } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_auth - Error auth_check_user_scheme"); response->status = 500; } json_decref(j_result); } else { ulfius_set_string_body_response(response, 400, "username is mandatory"); } } } else { ulfius_set_string_body_response(response, 400, "Input parameters must be in JSON format"); } json_decref(j_param); o_free(issued_for); return U_CALLBACK_CONTINUE; }
null
null
219,947
76419304129816489518033097810387289401
137
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_get_scope_list (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; json_t * j_scope_list; size_t offset = 0, limit = GLEWLWYD_DEFAULT_LIMIT_SIZE; long int l_converted = 0; char * endptr = NULL; if (u_map_get(request->map_url, "offset") != NULL) { l_converted = strtol(u_map_get(request->map_url, "offset"), &endptr, 10); if (!(*endptr) && l_converted > 0) { offset = (size_t)l_converted; } } if (u_map_get(request->map_url, "limit") != NULL) { l_converted = strtol(u_map_get(request->map_url, "limit"), &endptr, 10); if (!(*endptr) && l_converted >= 0) { limit = (size_t)l_converted; } } j_scope_list = get_scope_list(config, u_map_get(request->map_url, "pattern"), offset, limit); if (check_result_value(j_scope_list, G_OK)) { ulfius_set_json_body_response(response, 200, json_object_get(j_scope_list, "scope")); } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_get_scope_list - Error get_scope_list"); response->status = 500; } json_decref(j_scope_list); return U_CALLBACK_CONTINUE; }
null
null
219,948
83587212155979169243607175699600095386
29
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_user_update_password (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; json_t * j_session, * j_password, * j_element = NULL; char * session_uid = get_session_id(config, request); const char ** passwords = NULL; int res; struct _user_module_instance * user_module; size_t index = 0; if (session_uid != NULL && o_strlen(session_uid)) { j_session = get_current_user_for_session(config, session_uid); if (check_result_value(j_session, G_OK)) { j_password = ulfius_get_json_body_request(request, NULL); user_module = get_user_module_instance(config, json_string_value(json_object_get(json_object_get(j_session, "user"), "source"))); if (user_module && user_module->multiple_passwords) { if (json_string_length(json_object_get(j_password, "old_password")) && json_is_array(json_object_get(j_password, "password"))) { if ((passwords = o_malloc(json_array_size(json_object_get(j_password, "password")) * sizeof(char *))) != NULL) { json_array_foreach(json_object_get(j_password, "password"), index, j_element) { passwords[index] = json_string_value(j_element); } if ((res = user_update_password(config, json_string_value(json_object_get(json_object_get(j_session, "user"), "username")), json_string_value(json_object_get(j_password, "old_password")), passwords, json_array_size(json_object_get(j_password, "password")))) == G_ERROR_PARAM) { response->status = 400; } else if (res != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_update_password - Error user_update_password (1)"); response->status = 500; } } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_update_password - Error allocating resources for passwords (1)"); response->status = 500; } o_free(passwords); } else { response->status = 400; } } else { if (json_string_length(json_object_get(j_password, "old_password")) && json_string_length(json_object_get(j_password, "password"))) { if ((passwords = o_malloc(sizeof(char *))) != NULL) { passwords[0] = json_string_value(json_object_get(j_password, "password")); if ((res = user_update_password(config, json_string_value(json_object_get(json_object_get(j_session, "user"), "username")), json_string_value(json_object_get(j_password, "old_password")), passwords, 1)) == G_ERROR_PARAM) { response->status = 400; } else if (res != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_update_password - Error user_update_password (2)"); response->status = 500; } } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_update_password - Error allocating resources for passwords (2)"); response->status = 500; } o_free(passwords); } else { response->status = 400; } } json_decref(j_password); } else if (check_result_value(j_session, G_ERROR_NOT_FOUND)) { response->status = 401; } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_update_password - Error get_current_user_for_session"); response->status = 500; } json_decref(j_session); } else { response->status = 401; } o_free(session_uid); return U_CALLBACK_CONTINUE; }
null
null
219,949
191033494144154089982609890617600079042
68
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_check_admin_session_or_api_key (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; char * session_uid = NULL; json_t * j_user; int ret, res; const char * api_key = u_map_get_case(request->map_header, GLEWLWYD_API_KEY_HEADER_KEY), * ip_source = get_ip_source(request); if (NULL != api_key && 0 == o_strncmp(GLEWLWYD_API_KEY_HEADER_PREFIX, api_key, o_strlen(GLEWLWYD_API_KEY_HEADER_PREFIX))) { if ((res = verify_api_key(config, api_key + o_strlen(GLEWLWYD_API_KEY_HEADER_PREFIX))) == G_OK) { if (ulfius_set_response_shared_data(response, json_pack("{so}", "username", json_null()), (void (*)(void *))&json_decref) != U_OK) { ret = U_CALLBACK_ERROR; } else { ret = U_CALLBACK_IGNORE; } } else if (res == G_ERROR_UNAUTHORIZED) { y_log_message(Y_LOG_LEVEL_WARNING, "Security - API key invalid at IP Address %s", ip_source); ret = U_CALLBACK_UNAUTHORIZED; } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_check_admin_session_or_api_key - Error verify_api_key"); ret = U_CALLBACK_ERROR; } } else if ((session_uid = get_session_id(config, request)) != NULL) { j_user = get_current_user_for_session(config, session_uid); if (check_result_value(j_user, G_OK) && json_object_get(json_object_get(j_user, "user"), "enabled") == json_true()) { if ((res = is_scope_list_valid_for_session(config, config->admin_scope, session_uid)) == G_OK) { if (ulfius_set_response_shared_data(response, json_deep_copy(json_object_get(j_user, "user")), (void (*)(void *))&json_decref) != U_OK) { ret = U_CALLBACK_ERROR; } else { ret = U_CALLBACK_IGNORE; } } else { if (res == G_ERROR) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_check_admin_session_or_api_key - Error is_scope_list_valid_for_session"); } ret = U_CALLBACK_UNAUTHORIZED; } } else { ret = U_CALLBACK_UNAUTHORIZED; } json_decref(j_user); o_free(session_uid); } else { ret = U_CALLBACK_UNAUTHORIZED; } return ret; }
null
null
219,950
287594855719647405201355655061158776124
46
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_get_scope (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; json_t * j_scope; j_scope = get_scope(config, u_map_get(request->map_url, "scope")); if (check_result_value(j_scope, G_OK)) { ulfius_set_json_body_response(response, 200, json_object_get(j_scope, "scope")); } else if (check_result_value(j_scope, G_ERROR_NOT_FOUND)) { response->status = 404; } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_get_scope - Error get_scope"); response->status = 500; } json_decref(j_scope); return U_CALLBACK_CONTINUE; }
null
null
219,951
93084691674045293571424482246061352573
16
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_default (const struct _u_request * request, struct _u_response * response, void * user_data) { UNUSED(request); UNUSED(user_data); json_t * json_body = json_pack("{ssss}", "error", "resource not found", "message", "no resource available at this address"); ulfius_set_json_body_response(response, 404, json_body); json_decref(json_body); return U_CALLBACK_CONTINUE; }
null
null
219,952
144091722267784776374162267921093408496
8
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_user_auth_register_get_delegate (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; json_t * j_param = ulfius_get_json_body_request(request, NULL), * j_result = NULL; if (j_param != NULL) { if (json_object_get(j_param, "username") != NULL && json_string_length(json_object_get(j_param, "username"))) { if (0 == o_strcasecmp(json_string_value(json_object_get((json_t *)response->shared_data, "username")), json_string_value(json_object_get(j_param, "username")))) { if (json_object_get(j_param, "scheme_type") != NULL && json_string_length(json_object_get(j_param, "scheme_type")) && json_object_get(j_param, "scheme_name") != NULL && json_string_length(json_object_get(j_param, "scheme_name"))) { j_result = auth_register_get_user_scheme(config, json_string_value(json_object_get(j_param, "scheme_type")), json_string_value(json_object_get(j_param, "scheme_name")), json_string_value(json_object_get(j_param, "username")), request); if (check_result_value(j_result, G_ERROR_PARAM)) { ulfius_set_string_body_response(response, 400, "bad scheme response"); } else if (check_result_value(j_result, G_ERROR_NOT_FOUND)) { response->status = 404; } else if (check_result_value(j_result, G_ERROR_UNAUTHORIZED)) { response->status = 401; } else if (check_result_value(j_result, G_OK)) { if (json_object_get(j_result, "register") != NULL) { ulfius_set_json_body_response(response, 200, json_object_get(j_result, "register")); } } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_auth_register_get_delegate - Error auth_register_get_user_scheme"); response->status = 500; } json_decref(j_result); } else { ulfius_set_string_body_response(response, 400, "scheme is mandatory"); } } else { ulfius_set_string_body_response(response, 400, "username invalid"); } } else { ulfius_set_string_body_response(response, 400, "username is mandatory"); } } else { ulfius_set_string_body_response(response, 400, "Input parameters must be in JSON format"); } json_decref(j_param); return U_CALLBACK_CONTINUE; }
null
null
219,953
91933401502315484206904280100512631505
39
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_set_user_module (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; json_t * j_module, * j_module_valid, * j_search_module; j_search_module = get_user_module(config, u_map_get(request->map_url, "name")); if (check_result_value(j_search_module, G_OK)) { j_module = ulfius_get_json_body_request(request, NULL); if (j_module != NULL) { json_object_del(j_module, "enabled"); j_module_valid = is_user_module_valid(config, j_module, 0); if (check_result_value(j_module_valid, G_OK)) { if (set_user_module(config, u_map_get(request->map_url, "name"), j_module) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_set_user_module - Error set_user_module"); response->status = 500; } else { y_log_message(Y_LOG_LEVEL_INFO, "Event - User backend module '%s' updated", u_map_get(request->map_url, "name")); } } else if (check_result_value(j_module_valid, G_ERROR_PARAM)) { if (json_object_get(j_module_valid, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_module_valid, "error")); } else { response->status = 400; } } else if (!check_result_value(j_module_valid, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_set_user_module - Error is_user_module_valid"); response->status = 500; } json_decref(j_module_valid); } else { response->status = 400; } json_decref(j_module); } else if (check_result_value(j_search_module, G_ERROR_NOT_FOUND)) { response->status = 404; } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_set_user_module - Error get_user_module"); response->status = 500; } json_decref(j_search_module); return U_CALLBACK_CONTINUE; }
null
null
219,954
336685720986763431154118546552662761515
41
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_get_client_module (const struct _u_request * request, struct _u_response * response, void * client_data) { struct config_elements * config = (struct config_elements *)client_data; json_t * j_module; j_module = get_client_module(config, u_map_get(request->map_url, "name")); if (check_result_value(j_module, G_OK)) { ulfius_set_json_body_response(response, 200, json_object_get(j_module, "module")); } else if (check_result_value(j_module, G_ERROR_NOT_FOUND)) { response->status = 404; } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_get_client_module - Error get_client_module"); response->status = 500; } json_decref(j_module); return U_CALLBACK_CONTINUE; }
null
null
219,955
333956815089051803475374657036414354501
16
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_get_client_module_list (const struct _u_request * request, struct _u_response * response, void * client_data) { UNUSED(request); struct config_elements * config = (struct config_elements *)client_data; json_t * j_module; j_module = get_client_module_list(config); if (check_result_value(j_module, G_OK)) { ulfius_set_json_body_response(response, 200, json_object_get(j_module, "module")); } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_get_client_module_list - Error get_client_module_list"); response->status = 500; } json_decref(j_module); return U_CALLBACK_CONTINUE; }
null
null
219,956
88603786131975368906804985067807831939
15
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_metrics (const struct _u_request * request, struct _u_response * response, void * user_data) { UNUSED(request); struct config_elements * config = (struct config_elements *)user_data; size_t i, j; char * content = o_strdup("# We have seen handsome noble-looking men but I have never seen a man like the one who now stands at the entrance of the gate.\n"); struct _glwd_metric * metric; if (!pthread_mutex_lock(&config->metrics_lock)) { u_map_put(response->map_header, ULFIUS_HTTP_HEADER_CONTENT, "text/plain; charset=utf-8"); for (i=0; i<pointer_list_size(&config->metrics_list); i++) { metric = (struct _glwd_metric *)pointer_list_get_at(&config->metrics_list, i); content = mstrcatf(content, "# HELP %s_total %s\n", metric->name, metric->help); content = mstrcatf(content, "# TYPE %s_total counter\n", metric->name); for (j=0; j<metric->data_size; j++) { if (metric->data[j].label != NULL) { content = mstrcatf(content, "%s_total{%s} %zu\n", metric->name, metric->data[j].label, metric->data[j].counter); } else { content = mstrcatf(content, "%s_total %zu\n", metric->name, metric->data[j].counter); } } } ulfius_set_string_body_response(response, 200, content); o_free(content); pthread_mutex_unlock(&config->metrics_lock); } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_metrics - Error lock"); response->status = 500; } return U_CALLBACK_CONTINUE; }
null
null
219,957
302227313544454852978684520904114969419
30
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_user_delete_profile (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; int ret = G_OK; const char * username = json_string_value(json_object_get((json_t *)response->shared_data, "username")); json_t * j_session, * j_cur_session; char * session_uid = get_session_id(config, request); size_t index; j_session = get_current_user_for_session(config, session_uid); if (check_result_value(j_session, G_ERROR_NOT_FOUND)) { response->status = 404; } else if (!check_result_value(j_session, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_delete_profile - Error get_current_user_for_session"); response->status = 500; } else { json_array_foreach(json_object_get(j_session, "session"), index, j_cur_session) { if (0 == o_strcasecmp(username, json_string_value(json_object_get(j_cur_session, "username")))) { if (delete_user_session_from_hash(config, json_string_value(json_object_get(j_cur_session, "username")), NULL) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_delete_profile - Error delete_user_session_from_hash"); response->status = 500; ret = G_ERROR; } else { if (user_session_delete(config, session_uid, json_string_value(json_object_get(j_cur_session, "username"))) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_delete_profile - Error user_session_delete"); response->status = 500; ret = G_ERROR; } else { y_log_message(Y_LOG_LEVEL_INFO, "Event - User '%s' removed (profile)", json_string_value(json_object_get((json_t *)response->shared_data, "username"))); } } } } json_decref(j_session); if (ret == G_OK) { ret = user_delete_profile(config, username); if (ret == G_ERROR_UNAUTHORIZED) { response->status = 403; } else if (ret != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_delete_profile - Error user_delete_profile"); response->status = 500; } } } o_free(session_uid); return U_CALLBACK_CONTINUE; }
null
null
219,958
78505062242950910631866755446017415994
47
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_delete_user_auth_scheme_module (const struct _u_request * request, struct _u_response * response, void * user_auth_scheme_data) { struct config_elements * config = (struct config_elements *)user_auth_scheme_data; json_t * j_search_module; j_search_module = get_user_auth_scheme_module(config, u_map_get(request->map_url, "name")); if (check_result_value(j_search_module, G_OK)) { if (delete_user_auth_scheme_module(config, u_map_get(request->map_url, "name")) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_delete_user_auth_scheme_module - Error delete_user_auth_scheme_module"); response->status = 500; } else { y_log_message(Y_LOG_LEVEL_INFO, "Event - User auth scheme module '%s' removed", u_map_get(request->map_url, "name")); } } else if (check_result_value(j_search_module, G_ERROR_NOT_FOUND)) { response->status = 404; } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_delete_user_auth_scheme_module - Error get_user_auth_scheme_module"); response->status = 500; } json_decref(j_search_module); return U_CALLBACK_CONTINUE; }
null
null
219,959
82902473220873389991956361903722476328
21
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_get_user_middleware_module (const struct _u_request * request, struct _u_response * response, void * user_middleware_data) { struct config_elements * config = (struct config_elements *)user_middleware_data; json_t * j_module; j_module = get_user_middleware_module(config, u_map_get(request->map_url, "name")); if (check_result_value(j_module, G_OK)) { ulfius_set_json_body_response(response, 200, json_object_get(j_module, "module")); } else if (check_result_value(j_module, G_ERROR_NOT_FOUND)) { response->status = 404; } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_get_user_middleware_module - Error get_user_middleware_module"); response->status = 500; } json_decref(j_module); return U_CALLBACK_CONTINUE; }
null
null
219,960
316736248724829088198299436821533423419
16
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_404_if_necessary (const struct _u_request * request, struct _u_response * response, void * user_data) { UNUSED(user_data); if (!request->callback_position) { response->status = 404; } return U_CALLBACK_COMPLETE; }
null
null
219,961
281230680505174835391293592960801697046
7
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_set_user (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; json_t * j_user, * j_user_valid, * j_search_user; j_search_user = get_user(config, u_map_get(request->map_url, "username"), u_map_get(request->map_url, "source")); if (check_result_value(j_search_user, G_OK)) { j_user = ulfius_get_json_body_request(request, NULL); if (j_user != NULL) { j_user_valid = is_user_valid(config, u_map_get(request->map_url, "username"), j_user, 0, json_string_value(json_object_get(json_object_get(j_search_user, "user"), "source"))); if (check_result_value(j_user_valid, G_OK)) { if (set_user(config, u_map_get(request->map_url, "username"), j_user, json_string_value(json_object_get(json_object_get(j_search_user, "user"), "source"))) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_set_user - Error set_user"); response->status = 500; } else { y_log_message(Y_LOG_LEVEL_INFO, "Event - User '%s' updated", u_map_get(request->map_url, "username")); } } else if (check_result_value(j_user_valid, G_ERROR_PARAM)) { if (json_object_get(j_user_valid, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_user_valid, "error")); } else { response->status = 400; } } else if (!check_result_value(j_user_valid, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_set_user - Error is_user_valid"); response->status = 500; } json_decref(j_user_valid); } else { response->status = 400; } json_decref(j_user); } else if (check_result_value(j_search_user, G_ERROR_NOT_FOUND)) { response->status = 404; } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_set_user - Error get_user"); response->status = 500; } json_decref(j_search_user); return U_CALLBACK_CONTINUE; }
null
null
219,962
60713208903472772391001013312021300404
40
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_set_user_session_scope_grant (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; json_t * j_user = (json_t *)response->shared_data, * j_body = ulfius_get_json_body_request(request, NULL), * j_client; int res; if (config != NULL && j_user != NULL) { if (json_object_get(j_body, "scope") != NULL && json_is_string(json_object_get(j_body, "scope"))) { j_client = get_client(config, u_map_get(request->map_url, "client_id"), NULL); if (check_result_value(j_client, G_OK) && json_object_get(json_object_get(j_client, "client"), "enabled") == json_true()) { res = set_granted_scopes_for_client(config, j_user, u_map_get(request->map_url, "client_id"), json_string_value(json_object_get(j_body, "scope"))); if (res == G_ERROR_NOT_FOUND) { response->status = 404; } else if (res == G_ERROR_PARAM) { response->status = 400; } else if (res == G_ERROR_UNAUTHORIZED) { response->status = 401; } else if (res != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_set_user_session_scope_grant - Error set_granted_scopes_for_client"); response->status = 500; } else { y_log_message(Y_LOG_LEVEL_INFO, "Event - User '%s' granted scope list '%s' for client '%s'", json_string_value(json_object_get(j_user, "username")), json_string_value(json_object_get(j_body, "scope")), u_map_get(request->map_url, "client_id")); } } else if (check_result_value(j_client, G_ERROR_NOT_FOUND) || json_object_get(json_object_get(j_client, "client"), "enabled") != json_true()) { response->status = 404; } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_set_user_session_scope_grant - Error get_client"); response->status = 500; } json_decref(j_client); } else { response->status = 400; } } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_set_user_session_scope_grant - Error config or j_user is NULL"); response->status = 500; } json_decref(j_body); return U_CALLBACK_CONTINUE; }
null
null
219,963
230562696272630499647139068575659910052
39
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_check_user_profile_valid (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; char * session_uid; json_t * j_user; int ret, res; if ((session_uid = get_session_id(config, request)) != NULL) { j_user = get_current_user_for_session(config, session_uid); if (check_result_value(j_user, G_OK) && json_object_get(json_object_get(j_user, "user"), "enabled") == json_true()) { if ((res = is_scope_list_valid_for_session(config, config->profile_scope, session_uid)) == G_OK) { if (ulfius_set_response_shared_data(response, json_deep_copy(json_object_get(j_user, "user")), (void (*)(void *))&json_decref) != U_OK) { ret = U_CALLBACK_ERROR; } else { ret = U_CALLBACK_IGNORE; } } else { if (res == G_ERROR) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_check_user_session - Error is_scope_list_valid_for_session"); } ret = U_CALLBACK_UNAUTHORIZED; } } else { ret = U_CALLBACK_UNAUTHORIZED; } json_decref(j_user); } else { ret = U_CALLBACK_UNAUTHORIZED; } o_free(session_uid); return ret; }
null
null
219,964
272088447412757687703677514334185686767
31
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_add_client_module (const struct _u_request * request, struct _u_response * response, void * client_data) { struct config_elements * config = (struct config_elements *)client_data; json_t * j_module, * j_module_valid, * j_result; j_module = ulfius_get_json_body_request(request, NULL); if (j_module != NULL) { j_module_valid = is_client_module_valid(config, j_module, 1); if (check_result_value(j_module_valid, G_OK)) { j_result = add_client_module(config, j_module); if (check_result_value(j_result, G_ERROR_PARAM)) { if (json_object_get(j_result, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_result, "error")); } else { response->status = 400; } } else if (!check_result_value(j_result, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_add_client_module - Error add_client_module"); response->status = 500; } else { y_log_message(Y_LOG_LEVEL_INFO, "Event - Client backend module '%s' added (%s)", json_string_value(json_object_get(j_module, "name")), json_string_value(json_object_get(j_module, "module"))); } json_decref(j_result); } else if (check_result_value(j_module_valid, G_ERROR_PARAM)) { if (json_object_get(j_module_valid, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_module_valid, "error")); } else { response->status = 400; } } else if (!check_result_value(j_module_valid, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_add_client_module - Error is_client_module_valid"); response->status = 500; } json_decref(j_module_valid); } else { response->status = 400; } json_decref(j_module); return U_CALLBACK_CONTINUE; }
null
null
219,965
180073030414436396534656263010736573680
39
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_set_client_module (const struct _u_request * request, struct _u_response * response, void * client_data) { struct config_elements * config = (struct config_elements *)client_data; json_t * j_module, * j_module_valid, * j_search_module; j_search_module = get_client_module(config, u_map_get(request->map_url, "name")); if (check_result_value(j_search_module, G_OK)) { j_module = ulfius_get_json_body_request(request, NULL); if (j_module != NULL) { json_object_del(j_module, "enabled"); j_module_valid = is_client_module_valid(config, j_module, 0); if (check_result_value(j_module_valid, G_OK)) { if (set_client_module(config, u_map_get(request->map_url, "name"), j_module) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_set_client_module - Error set_client_module"); response->status = 500; } else { y_log_message(Y_LOG_LEVEL_INFO, "Event - Client backend module '%s' updated", u_map_get(request->map_url, "name")); } } else if (check_result_value(j_module_valid, G_ERROR_PARAM)) { if (json_object_get(j_module_valid, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_module_valid, "error")); } else { response->status = 400; } } else if (!check_result_value(j_module_valid, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_set_client_module - Error is_client_module_valid"); response->status = 500; } json_decref(j_module_valid); } else { response->status = 400; } json_decref(j_module); } else if (check_result_value(j_search_module, G_ERROR_NOT_FOUND)) { response->status = 404; } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_set_client_module - Error get_client_module"); response->status = 500; } json_decref(j_search_module); return U_CALLBACK_CONTINUE; }
null
null
219,966
209849684401938437009860123716653593364
41
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_check_admin_session_delegate (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; char * session_uid; json_t * j_user, * j_delegate; int ret; if ((session_uid = get_session_id(config, request)) != NULL) { j_user = get_current_user_for_session(config, session_uid); if (check_result_value(j_user, G_OK) && json_object_get(json_object_get(j_user, "user"), "enabled") == json_true()) { if (is_scope_list_valid_for_session(config, config->admin_scope, session_uid) == G_OK) { j_delegate = get_user(config, u_map_get(request->map_url, "username"), NULL); if (check_result_value(j_delegate, G_OK)) { if (ulfius_set_response_shared_data(response, json_deep_copy(json_object_get(j_delegate, "user")), (void (*)(void *))&json_decref) != U_OK) { ret = U_CALLBACK_ERROR; } else { ret = U_CALLBACK_IGNORE; } } else { ret = U_CALLBACK_UNAUTHORIZED; } json_decref(j_delegate); } else { ret = U_CALLBACK_UNAUTHORIZED; } } else { ret = U_CALLBACK_UNAUTHORIZED; } json_decref(j_user); } else { ret = U_CALLBACK_UNAUTHORIZED; } o_free(session_uid); return ret; }
null
null
219,967
319207754655792570521059147414263248878
34
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_get_user_session_scope_grant (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; json_t * j_user = (json_t *)response->shared_data, * j_scope_list; if (config != NULL && j_user != NULL) { j_scope_list = get_granted_scopes_for_client(config, j_user, u_map_get(request->map_url, "client_id"), u_map_get(request->map_url, "scope_list")); if (check_result_value(j_scope_list, G_OK)) { ulfius_set_json_body_response(response, 200, json_object_get(j_scope_list, "grant")); } else if (check_result_value(j_scope_list, G_ERROR_NOT_FOUND)) { response->status = 404; } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_get_user_session_scope_grant - Error get_granted_scopes_for_client"); response->status = 500; } json_decref(j_scope_list); } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_get_user_session_scope_grant - Error config or j_user is NULL"); response->status = 500; } return U_CALLBACK_CONTINUE; }
null
null
219,968
185991743992307472930054110450817162992
21
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_delete_session (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; int res = delete_user_session_from_hash(config, json_string_value(json_object_get((json_t *)response->shared_data, "username")), u_map_get(request->map_url, "session_hash")); if (res == G_ERROR_NOT_FOUND) { response->status = 404; } else if (res != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_delete_session - Error delete_user_session_from_hash"); response->status = 500; } return U_CALLBACK_CONTINUE; }
null
null
219,969
79552606079179811991466234309013346654
11
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_check_admin_session (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; char * session_uid; json_t * j_user; int ret, res; if ((session_uid = get_session_id(config, request)) != NULL) { j_user = get_current_user_for_session(config, session_uid); if (check_result_value(j_user, G_OK) && json_object_get(json_object_get(j_user, "user"), "enabled") == json_true()) { if ((res = is_scope_list_valid_for_session(config, config->admin_scope, session_uid)) == G_OK) { if (ulfius_set_response_shared_data(response, json_deep_copy(json_object_get(j_user, "user")), (void (*)(void *))&json_decref) != U_OK) { ret = U_CALLBACK_ERROR; } else { ret = U_CALLBACK_IGNORE; } } else { if (res == G_ERROR) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_check_admin_session - Error is_scope_list_valid_for_session"); } ret = U_CALLBACK_UNAUTHORIZED; } } else { ret = U_CALLBACK_UNAUTHORIZED; } json_decref(j_user); } else { ret = U_CALLBACK_UNAUTHORIZED; } o_free(session_uid); return ret; }
null
null
219,970
178694998865454035584241286371125565126
31
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_reload_modules (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; UNUSED(request); close_user_module_instance_list(config); close_user_module_list(config); close_user_middleware_module_instance_list(config); close_user_middleware_module_list(config); close_client_module_instance_list(config); close_client_module_list(config); close_user_auth_scheme_module_instance_list(config); close_user_auth_scheme_module_list(config); close_plugin_module_instance_list(config); close_plugin_module_list(config); // Initialize user modules if (init_user_module_list(config) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "Error initializing user modules"); response->status = 500; } if (load_user_module_instance_list(config) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "Error loading user modules instances"); response->status = 500; } // Initialize user modules if (init_user_middleware_module_list(config) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "Error initializing user middleware modules"); response->status = 500; } if (load_user_middleware_module_instance_list(config) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "Error loading user middleware modules instances"); response->status = 500; } // Initialize client modules if (init_client_module_list(config) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "Error initializing client modules"); response->status = 500; } if (load_client_module_instance_list(config) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "Error loading client modules instances"); response->status = 500; } // Initialize user auth scheme modules if (init_user_auth_scheme_module_list(config) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "Error initializing user auth scheme modules"); response->status = 500; } if (load_user_auth_scheme_module_instance_list(config) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "Error loading user auth scheme modules instances"); response->status = 500; } // Initialize plugins if (init_plugin_module_list(config) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "Error initializing plugins modules"); response->status = 500; } if (load_plugin_module_instance_list(config) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "Error loading plugins modules instances"); response->status = 500; } return U_CALLBACK_CONTINUE; }
null
null
219,971
115872883426262742338027117536534776437
71
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_server_configuration (const struct _u_request * request, struct _u_response * response, void * user_data) { UNUSED(request); json_t * json_body = json_pack("{ssssssss}", "api_prefix", ((struct config_elements *)user_data)->api_prefix, "admin_scope", ((struct config_elements *)user_data)->admin_scope, "profile_scope", ((struct config_elements *)user_data)->profile_scope, "delete_profile", ((struct config_elements *)user_data)->delete_profile==GLEWLWYD_PROFILE_DELETE_UNAUTHORIZED?"no":"yes"); ulfius_set_json_body_response(response, 200, json_body); json_decref(json_body); return U_CALLBACK_CONTINUE; }
null
null
219,972
264424888748718174245952935146803419809
16
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_set_plugin_module (const struct _u_request * request, struct _u_response * response, void * plugin_data) { struct config_elements * config = (struct config_elements *)plugin_data; json_t * j_module, * j_module_valid, * j_search_module; j_search_module = get_plugin_module(config, u_map_get(request->map_url, "name")); if (check_result_value(j_search_module, G_OK)) { j_module = ulfius_get_json_body_request(request, NULL); if (j_module != NULL) { json_object_del(j_module, "enabled"); j_module_valid = is_plugin_module_valid(config, j_module, 0); if (check_result_value(j_module_valid, G_OK)) { if (set_plugin_module(config, u_map_get(request->map_url, "name"), j_module) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_set_plugin_module - Error set_plugin_module"); response->status = 500; } else { y_log_message(Y_LOG_LEVEL_INFO, "Event - Plugin module '%s' updated", u_map_get(request->map_url, "name")); } } else if (check_result_value(j_module_valid, G_ERROR_PARAM)) { if (json_object_get(j_module_valid, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_module_valid, "error")); } else { response->status = 400; } } else if (!check_result_value(j_module_valid, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_set_plugin_module - Error is_plugin_module_valid"); response->status = 500; } json_decref(j_module_valid); } else { response->status = 400; } json_decref(j_module); } else if (check_result_value(j_search_module, G_ERROR_NOT_FOUND)) { response->status = 404; } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_set_plugin_module - Error get_plugin_module"); response->status = 500; } json_decref(j_search_module); return U_CALLBACK_CONTINUE; }
null
null
219,973
288491611517756492784150033190526245754
41
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_add_user (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; json_t * j_user, * j_user_valid, * j_search_user, * j_body; j_user = ulfius_get_json_body_request(request, NULL); if (j_user != NULL) { j_user_valid = is_user_valid(config, NULL, j_user, 1, u_map_get(request->map_url, "source")); if (check_result_value(j_user_valid, G_OK)) { j_search_user = get_user(config, json_string_value(json_object_get(j_user, "username")), u_map_get(request->map_url, "source")); if (check_result_value(j_search_user, G_ERROR_NOT_FOUND)) { if (add_user(config, j_user, u_map_get(request->map_url, "source")) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_add_user - Error add_user"); response->status = 500; } else { y_log_message(Y_LOG_LEVEL_INFO, "Event - User '%s' added", json_string_value(json_object_get(j_user, "username"))); } } else if (check_result_value(j_search_user, G_OK)) { j_body = json_pack("{s[s]}", "error", "username already exists"); ulfius_set_json_body_response(response, 400, j_body); json_decref(j_body); } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_add_user - Error get_user"); response->status = 500; } json_decref(j_search_user); } else if (check_result_value(j_user_valid, G_ERROR_PARAM)) { if (json_object_get(j_user_valid, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_user_valid, "error")); } else { response->status = 400; } } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_add_user - Error is_user_valid"); response->status = 500; } json_decref(j_user_valid); } else { response->status = 400; } json_decref(j_user); return U_CALLBACK_CONTINUE; }
null
null
219,974
93902845501112986257150222288084465802
42
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_user_get_scheme_list (const struct _u_request * request, struct _u_response * response, void * user_data) { UNUSED(request); struct config_elements * config = (struct config_elements *)user_data; json_t * j_scheme_list = get_scheme_list_for_user(config, json_string_value(json_object_get((json_t *)response->shared_data, "username"))), * j_element; size_t index; if (check_result_value(j_scheme_list, G_OK)) { json_array_foreach(json_object_get(j_scheme_list, "scheme"), index, j_element) { json_object_del(j_element, "parameters"); } ulfius_set_json_body_response(response, 200, json_object_get(j_scheme_list, "scheme")); } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_get_scheme_list - Error get_scheme_list_for_user"); response->status = 500; } json_decref(j_scheme_list); return U_CALLBACK_CONTINUE; }
null
null
219,975
91089429563285677613744521152196445158
18
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_add_user_module (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; json_t * j_module, * j_module_valid, * j_result; j_module = ulfius_get_json_body_request(request, NULL); if (j_module != NULL) { j_module_valid = is_user_module_valid(config, j_module, 1); if (check_result_value(j_module_valid, G_OK)) { j_result = add_user_module(config, j_module); if (check_result_value(j_result, G_ERROR_PARAM)) { if (json_object_get(j_result, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_result, "error")); } else { response->status = 400; } } else if (!check_result_value(j_result, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_add_user_module - Error add_user_module"); response->status = 500; } else { y_log_message(Y_LOG_LEVEL_INFO, "Event - User backend module '%s' added (%s)", json_string_value(json_object_get(j_module, "name")), json_string_value(json_object_get(j_module, "module"))); } json_decref(j_result); } else if (check_result_value(j_module_valid, G_ERROR_PARAM)) { if (json_object_get(j_module_valid, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_module_valid, "error")); } else { response->status = 400; } } else if (!check_result_value(j_module_valid, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_add_user_module - Error is_user_module_valid"); response->status = 500; } json_decref(j_module_valid); } else { response->status = 400; } json_decref(j_module); return U_CALLBACK_CONTINUE; }
null
null
219,976
114521980029850434533989634127230936730
39
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_add_api_key (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; const char * issued_for = get_ip_source(request), * username = json_string_value(json_object_get((json_t *)response->shared_data, "username")), * user_agent = u_map_get_case(request->map_header, "user-agent"); json_t * j_api_key = generate_api_key(config, username, issued_for, user_agent); if (check_result_value(j_api_key, G_OK)) { ulfius_set_json_body_response(response, 200, json_object_get(j_api_key, "api_key")); y_log_message(Y_LOG_LEVEL_INFO, "Event - API key created for user '%s'", username); } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_add_api_key - Error generate_api_key"); response->status = 500; } json_decref(j_api_key); return U_CALLBACK_CONTINUE; }
null
null
219,977
69435053862477068525436727104660599935
15
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_get_plugin_module (const struct _u_request * request, struct _u_response * response, void * plugin_data) { struct config_elements * config = (struct config_elements *)plugin_data; json_t * j_module; j_module = get_plugin_module(config, u_map_get(request->map_url, "name")); if (check_result_value(j_module, G_OK)) { ulfius_set_json_body_response(response, 200, json_object_get(j_module, "module")); } else if (check_result_value(j_module, G_ERROR_NOT_FOUND)) { response->status = 404; } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_get_plugin_module - Error get_plugin_module"); response->status = 500; } json_decref(j_module); return U_CALLBACK_CONTINUE; }
null
null
219,978
69709046621819547641887808002698663284
16
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_get_client_list (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; json_t * j_client_list; size_t offset = 0, limit = GLEWLWYD_DEFAULT_LIMIT_SIZE; long int l_converted = 0; char * endptr = NULL; if (u_map_get(request->map_url, "offset") != NULL) { l_converted = strtol(u_map_get(request->map_url, "offset"), &endptr, 10); if (!(*endptr) && l_converted > 0) { offset = (size_t)l_converted; } } if (u_map_get(request->map_url, "limit") != NULL) { l_converted = strtol(u_map_get(request->map_url, "limit"), &endptr, 10); if (!(*endptr) && l_converted > 0) { limit = (size_t)l_converted; } } j_client_list = get_client_list(config, u_map_get(request->map_url, "pattern"), offset, limit, u_map_get(request->map_url, "source")); if (check_result_value(j_client_list, G_OK)) { ulfius_set_json_body_response(response, 200, json_object_get(j_client_list, "client")); } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_get_client_list - Error get_client_list"); response->status = 500; } json_decref(j_client_list); return U_CALLBACK_CONTINUE; }
null
null
219,979
218719037514311894275535861755349778687
29
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_user_get_session_list (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; json_t * j_session_list; size_t offset = 0, limit = GLEWLWYD_DEFAULT_LIMIT_SIZE; long int l_converted = 0; char * endptr = NULL, * sort = NULL; if (u_map_get(request->map_url, "offset") != NULL) { l_converted = strtol(u_map_get(request->map_url, "offset"), &endptr, 10); if (!(*endptr) && l_converted > 0) { offset = (size_t)l_converted; } } if (u_map_get(request->map_url, "limit") != NULL) { l_converted = strtol(u_map_get(request->map_url, "limit"), &endptr, 10); if (!(*endptr) && l_converted > 0) { limit = (size_t)l_converted; } } if (0 == o_strcmp(u_map_get(request->map_url, "sort"), "session_hash") || 0 == o_strcmp(u_map_get(request->map_url, "sort"), "user_agent") || 0 == o_strcmp(u_map_get(request->map_url, "sort"), "issued_for") || 0 == o_strcmp(u_map_get(request->map_url, "sort"), "expiration") || 0 == o_strcmp(u_map_get(request->map_url, "sort"), "last_login") || 0 == o_strcmp(u_map_get(request->map_url, "sort"), "enabled")) { sort = msprintf("gpgr_%s%s", u_map_get(request->map_url, "sort"), (u_map_get_case(request->map_url, "desc")!=NULL?" DESC":" ASC")); } j_session_list = get_user_session_list(config, json_string_value(json_object_get((json_t *)response->shared_data, "username")), u_map_get(request->map_url, "pattern"), offset, limit, sort); if (check_result_value(j_session_list, G_OK)) { ulfius_set_json_body_response(response, 200, json_object_get(j_session_list, "session")); } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_get_session_list - Error get_user_session_list"); response->status = 500; } json_decref(j_session_list); return U_CALLBACK_CONTINUE; }
null
null
219,980
254512397087740990875547676503178605056
32
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_set_client (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; json_t * j_client, * j_client_valid, * j_search_client; j_search_client = get_client(config, u_map_get(request->map_url, "client_id"), u_map_get(request->map_url, "source")); if (check_result_value(j_search_client, G_OK)) { j_client = ulfius_get_json_body_request(request, NULL); if (j_client != NULL) { j_client_valid = is_client_valid(config, u_map_get(request->map_url, "client_id"), j_client, 0, json_string_value(json_object_get(json_object_get(j_search_client, "client"), "source"))); if (check_result_value(j_client_valid, G_OK)) { if (set_client(config, u_map_get(request->map_url, "client_id"), j_client, json_string_value(json_object_get(json_object_get(j_search_client, "client"), "source"))) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_set_client - Error set_client"); response->status = 500; } else { y_log_message(Y_LOG_LEVEL_INFO, "Event - Client '%s' updated", u_map_get(request->map_url, "client_id")); } } else if (check_result_value(j_client_valid, G_ERROR_PARAM)) { if (json_object_get(j_client_valid, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_client_valid, "error")); } else { response->status = 400; } } else if (!check_result_value(j_client_valid, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_set_client - Error is_client_valid"); response->status = 500; } json_decref(j_client_valid); } else { response->status = 400; } json_decref(j_client); } else if (check_result_value(j_search_client, G_ERROR_NOT_FOUND)) { response->status = 404; } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_set_client - Error get_client"); response->status = 500; } json_decref(j_search_client); return U_CALLBACK_CONTINUE; }
null
null
219,981
145034285733104723855190760051638454208
40
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_delete_client_module (const struct _u_request * request, struct _u_response * response, void * client_data) { struct config_elements * config = (struct config_elements *)client_data; json_t * j_search_module; j_search_module = get_client_module(config, u_map_get(request->map_url, "name")); if (check_result_value(j_search_module, G_OK)) { if (delete_client_module(config, u_map_get(request->map_url, "name")) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_delete_client_module - Error delete_client_module"); response->status = 500; } else { y_log_message(Y_LOG_LEVEL_INFO, "Event - Client backend module '%s' removed", u_map_get(request->map_url, "name")); } } else if (check_result_value(j_search_module, G_ERROR_NOT_FOUND)) { response->status = 404; } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_delete_client_module - Error get_client_module"); response->status = 500; } json_decref(j_search_module); return U_CALLBACK_CONTINUE; }
null
null
219,982
259418569129430876007485650976649189278
21
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_user_auth_register_delegate (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; json_t * j_param = ulfius_get_json_body_request(request, NULL), * j_result = NULL; if (j_param != NULL) { if (json_object_get(j_param, "username") != NULL && json_is_string(json_object_get(j_param, "username")) && json_string_length(json_object_get(j_param, "username"))) { if (0 == o_strcasecmp(json_string_value(json_object_get((json_t *)response->shared_data, "username")), json_string_value(json_object_get(j_param, "username")))) { if (json_object_get(j_param, "scheme_type") != NULL && json_is_string(json_object_get(j_param, "scheme_type")) && json_string_length(json_object_get(j_param, "scheme_type")) && json_object_get(j_param, "scheme_name") != NULL && json_is_string(json_object_get(j_param, "scheme_name")) && json_string_length(json_object_get(j_param, "scheme_name"))) { j_result = auth_register_user_scheme(config, json_string_value(json_object_get(j_param, "scheme_type")), json_string_value(json_object_get(j_param, "scheme_name")), json_string_value(json_object_get(j_param, "username")), 1, json_object_get(j_param, "value"), request); if (check_result_value(j_result, G_ERROR_PARAM)) { if (json_object_get(j_result, "register") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_result, "register")); } else { ulfius_set_string_body_response(response, 400, "bad scheme response"); } } else if (check_result_value(j_result, G_ERROR_NOT_FOUND)) { response->status = 404; } else if (check_result_value(j_result, G_ERROR_UNAUTHORIZED)) { response->status = 401; } else if (check_result_value(j_result, G_OK)) { if (json_object_get(j_result, "register") != NULL) { ulfius_set_json_body_response(response, 200, json_object_get(j_result, "register")); } y_log_message(Y_LOG_LEVEL_INFO, "Event - User '%s' registered scheme '%s/%s' (delegation)", json_string_value(json_object_get(j_param, "username")), json_string_value(json_object_get(j_param, "scheme_type")), json_string_value(json_object_get(j_param, "scheme_name"))); } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_auth_register_delegate - Error auth_check_user_scheme"); response->status = 500; } json_decref(j_result); } else { ulfius_set_string_body_response(response, 400, "scheme is mandatory"); } } else { ulfius_set_string_body_response(response, 400, "username invalid"); } } else { ulfius_set_string_body_response(response, 400, "username is mandatory"); } } else { ulfius_set_string_body_response(response, 400, "Input parameters must be in JSON format"); } json_decref(j_param); return U_CALLBACK_CONTINUE; }
null
null
219,983
272454221481136724530852621751964189908
44
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_manage_user_module (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; json_t * j_search_module, * j_result, * j_result2; j_search_module = get_user_module(config, u_map_get(request->map_url, "name")); if (check_result_value(j_search_module, G_OK)) { if (0 == o_strcmp("enable", u_map_get(request->map_url, "action"))) { j_result = manage_user_module(config, u_map_get(request->map_url, "name"), GLEWLWYD_MODULE_ACTION_START); if (check_result_value(j_result, G_ERROR_PARAM)) { if (json_object_get(j_result, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_result, "error")); } else { response->status = 400; } } else if (!check_result_value(j_result, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_manage_user_module - Error manage_user_module enable"); response->status = 500; } json_decref(j_result); } else if (0 == o_strcmp("disable", u_map_get(request->map_url, "action"))) { j_result = manage_user_module(config, u_map_get(request->map_url, "name"), GLEWLWYD_MODULE_ACTION_STOP); if (check_result_value(j_result, G_ERROR_PARAM)) { if (json_object_get(j_result, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_result, "error")); } else { response->status = 400; } } else if (!check_result_value(j_result, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_manage_user_module - Error manage_user_module disable"); response->status = 500; } json_decref(j_result); } else if (0 == o_strcmp("reset", u_map_get(request->map_url, "action"))) { j_result = manage_user_module(config, u_map_get(request->map_url, "name"), GLEWLWYD_MODULE_ACTION_STOP); if (check_result_value(j_result, G_ERROR_PARAM)) { if (json_object_get(j_result, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_result, "error")); } else { response->status = 400; } } else if (!check_result_value(j_result, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_manage_user_module - Error manage_user_module reset (1)"); response->status = 500; } else { j_result2 = manage_user_module(config, u_map_get(request->map_url, "name"), GLEWLWYD_MODULE_ACTION_START); if (check_result_value(j_result2, G_ERROR_PARAM)) { if (json_object_get(j_result2, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_result2, "error")); } else { response->status = 400; } } else if (!check_result_value(j_result2, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_manage_user_module - Error manage_user_module reset (2)"); response->status = 500; } json_decref(j_result2); } json_decref(j_result); } else { response->status = 400; } } else if (check_result_value(j_search_module, G_ERROR_NOT_FOUND)) { response->status = 404; } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_manage_user_module - Error get_user_module"); response->status = 500; } json_decref(j_search_module); return U_CALLBACK_CONTINUE; }
null
null
219,984
94291082705727681136052655290753457141
70
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_check_user_session (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; char * session_uid; json_t * j_user; int ret; if ((session_uid = get_session_id(config, request)) != NULL) { j_user = get_current_user_for_session(config, session_uid); if (check_result_value(j_user, G_OK) && json_object_get(json_object_get(j_user, "user"), "enabled") == json_true()) { if (ulfius_set_response_shared_data(response, json_deep_copy(json_object_get(j_user, "user")), (void (*)(void *))&json_decref) != U_OK) { ret = U_CALLBACK_ERROR; } else { ret = U_CALLBACK_IGNORE; } } else { ret = U_CALLBACK_UNAUTHORIZED; } json_decref(j_user); } else { ret = U_CALLBACK_UNAUTHORIZED; } o_free(session_uid); return ret; }
null
null
219,985
126058730092827046134323283805662249479
24
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_user_get_plugin_list (const struct _u_request * request, struct _u_response * response, void * user_data) { UNUSED(request); struct config_elements * config = (struct config_elements *)user_data; json_t * j_plugin_list = get_plugin_module_list_for_user(config); if (check_result_value(j_plugin_list, G_OK)) { ulfius_set_json_body_response(response, 200, json_object_get(j_plugin_list, "module")); } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_get_plugin_list - Error j_plugin_list"); response->status = 500; } json_decref(j_plugin_list); return U_CALLBACK_CONTINUE; }
null
null
219,986
26031335017530830419105748053333037432
14
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_manage_user_middleware_module (const struct _u_request * request, struct _u_response * response, void * user_middleware_data) { struct config_elements * config = (struct config_elements *)user_middleware_data; json_t * j_search_module, * j_result, * j_result2; j_search_module = get_user_middleware_module(config, u_map_get(request->map_url, "name")); if (check_result_value(j_search_module, G_OK)) { if (0 == o_strcmp("enable", u_map_get(request->map_url, "action"))) { j_result = manage_user_middleware_module(config, u_map_get(request->map_url, "name"), GLEWLWYD_MODULE_ACTION_START); if (check_result_value(j_result, G_ERROR_PARAM)) { if (json_object_get(j_result, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_result, "error")); } else { response->status = 400; } } else if (!check_result_value(j_result, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_manage_user_middleware_module - Error manage_user_middleware_module enable"); response->status = 500; } json_decref(j_result); } else if (0 == o_strcmp("disable", u_map_get(request->map_url, "action"))) { j_result = manage_user_middleware_module(config, u_map_get(request->map_url, "name"), GLEWLWYD_MODULE_ACTION_STOP); if (check_result_value(j_result, G_ERROR_PARAM)) { if (json_object_get(j_result, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_result, "error")); } else { response->status = 400; } } else if (!check_result_value(j_result, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_manage_user_middleware_module - Error manage_user_middleware_module disable"); response->status = 500; } json_decref(j_result); } else if (0 == o_strcmp("reset", u_map_get(request->map_url, "action"))) { j_result = manage_user_middleware_module(config, u_map_get(request->map_url, "name"), GLEWLWYD_MODULE_ACTION_STOP); if (check_result_value(j_result, G_ERROR_PARAM)) { if (json_object_get(j_result, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_result, "error")); } else { response->status = 400; } } else if (!check_result_value(j_result, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_manage_user_middleware_module - Error manage_user_middleware_module reset (1)"); response->status = 500; } else { j_result2 = manage_user_middleware_module(config, u_map_get(request->map_url, "name"), GLEWLWYD_MODULE_ACTION_START); if (check_result_value(j_result2, G_ERROR_PARAM)) { if (json_object_get(j_result2, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_result2, "error")); } else { response->status = 400; } } else if (!check_result_value(j_result2, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_manage_user_middleware_module - Error manage_user_middleware_module reset (2)"); response->status = 500; } json_decref(j_result2); } json_decref(j_result); } else { response->status = 400; } } else if (check_result_value(j_search_module, G_ERROR_NOT_FOUND)) { response->status = 404; } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_manage_user_middleware_module - Error get_user_middleware_module"); response->status = 500; } json_decref(j_search_module); return U_CALLBACK_CONTINUE; }
null
null
219,987
110475741687785223967101802758139502252
70
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_add_scope (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; json_t * j_scope, * j_scope_valid, * j_search_scope, * j_body; j_scope = ulfius_get_json_body_request(request, NULL); if (j_scope != NULL) { j_scope_valid = is_scope_valid(config, j_scope, 1); if (check_result_value(j_scope_valid, G_OK)) { j_search_scope = get_scope(config, json_string_value(json_object_get(j_scope, "name"))); if (check_result_value(j_search_scope, G_ERROR_NOT_FOUND)) { if (add_scope(config, j_scope) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_add_scope - Error add_scope"); response->status = 500; } else { y_log_message(Y_LOG_LEVEL_INFO, "Event - Scope '%s' added", json_string_value(json_object_get(j_scope, "name"))); } } else if (check_result_value(j_search_scope, G_OK)) { j_body = json_pack("{s[s]}", "error", "scope already exists"); ulfius_set_json_body_response(response, 400, j_body); json_decref(j_body); } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_add_scope - Error get_scope"); response->status = 500; } json_decref(j_search_scope); } else if (check_result_value(j_scope_valid, G_ERROR_PARAM)) { ulfius_set_json_body_response(response, 400, json_object_get(j_scope_valid, "error")); } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_add_scope - Error is_scope_valid"); response->status = 500; } json_decref(j_scope_valid); } else { response->status = 400; } json_decref(j_scope); return U_CALLBACK_CONTINUE; }
null
null
219,988
233296489444780294077478639911255413712
38
Fix update session when auth fail
other
glewlwyd
125281f1c0d4b6a8b49f7e55a757205a2ef01fbe
0
int callback_glewlwyd_get_user_middleware_module_list (const struct _u_request * request, struct _u_response * response, void * user_middleware_data) { UNUSED(request); struct config_elements * config = (struct config_elements *)user_middleware_data; json_t * j_module; j_module = get_user_middleware_module_list(config); if (check_result_value(j_module, G_OK)) { ulfius_set_json_body_response(response, 200, json_object_get(j_module, "module")); } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_get_user_middleware_module_list - Error get_user_middleware_module_list"); response->status = 500; } json_decref(j_module); return U_CALLBACK_CONTINUE; }
null
null
219,989
320733285218488581372297480349026876787
15
Fix update session when auth fail
other