/*
 *    struct {
 *        opaque cookie<1..2^16-1>;
 *    } Cookie;
 */
SECStatus
tls13_ClientHandleHrrCookie(const sslSocket *ss, TLSExtensionData *xtnData, PRUint16 ex_type, SECItem *data)
{
    SECStatus rv;

    SSL_TRC(3, ("%d: TLS13[%d]: handle cookie extension",
                SSL_GETPID(), ss->fd));

    PORT_Assert(ss->vrange.max >= SSL_LIBRARY_VERSION_TLS_1_3);

    /* IMPORTANT: this is only valid while the HelloRetryRequest is still valid. */
    rv = ssl3_ExtConsumeHandshakeVariable(
        ss, &CONST_CAST(sslSocket, ss)->ssl3.hs.cookie, 2,
        &data->data, &data->len);
    if (rv != SECSuccess) {
        PORT_SetError(SSL_ERROR_RX_MALFORMED_HELLO_RETRY_REQUEST);
        return SECFailure;
    }
    if (!ss->ssl3.hs.cookie.len || data->len) {
        ssl3_ExtSendAlert(ss, alert_fatal, decode_error);
        PORT_SetError(SSL_ERROR_RX_MALFORMED_HELLO_RETRY_REQUEST);
        return SECFailure;
    }

    return SECSuccess;
}
Exemple #2
0
//
// Initializes the structure member representing the tab's text
//
void
TTabItem::SetLabel(LPCTSTR str, int len)
{
  pszText = CONST_CAST(LPTSTR, str);
  cchTextMax = len ? len : ::_tcslen(str);
  mask |= TCIF_TEXT;
}
Exemple #3
0
template <class elem_t, class holder_t> void
adlist_tos_base<elem_t, holder_t>::set_elem_by_num(size_t elem_num,
        elem_t the_elem)
{
    assert(elem_num >= 0);
    if (elem_num >= _cached_size)
    {
        while (_cached_size < elem_num)
            append(zero((elem_t *)0));
        append(the_elem);
        return;
    }
    if (elem_num < _index_size)
    {
        _index[elem_num]->data = the_elem;
        return;
    }
    if (_index_size == 0)
    {
        _index[0] = _head_e;
        typedef adlist_tos_base<elem_t, holder_t> *this_type;
        ++(CONST_CAST(this_type, this)->_index_size);
    }
    size_t total = _index_size - 1;
    holder_t *follow = _index[total];
    while (total < elem_num)
    {
        ++total;
        follow = follow->next;
        _index[total] = follow;
    }
    follow->data = the_elem;
}
Exemple #4
0
template <class elem_t, class holder_t> tos_handle<elem_t>
adlist_tos_base<elem_t, holder_t>::handle_for_num(size_t position)
const
{
    if (position < 0)
        return build_handle(0);
    else if (position >= _cached_size)
        return build_handle(0);
    if (position < _index_size)
        return build_handle(_index[position]);
    if (_index_size == 0)
    {
        _index[0] = _head_e;
        typedef adlist_tos_base<elem_t, holder_t> *this_type;
        ++(CONST_CAST(this_type, this)->_index_size);
    }
    size_t total = _index_size - 1;
    holder_t *follow = _index[total];
    while (total < position)
    {
        ++total;
        follow = follow->next;
        _index[total] = follow;
    }
    return build_handle(follow);
}
Exemple #5
0
template <class elem_t, class holder_t> elem_t
adlist_tos_base<elem_t, holder_t>::elem_by_num(size_t position)
const
{
    if (position < 0)
        return zero((elem_t *)0);
    else if (position >= _cached_size)
        return zero((elem_t *)0);
    if (position < _index_size)
        return _index[position]->data;
    if (_index_size == 0)
    {
        _index[0] = _head_e;
        typedef adlist_tos_base<elem_t, holder_t> *this_type;
        ++(CONST_CAST(this_type, this)->_index_size);
    }
    size_t total = _index_size - 1;
    holder_t *follow = _index[total];
    while (total < position)
    {
        ++total;
        follow = follow->next;
        _index[total] = follow;
    }
    return follow->data;
}
TRI_doc_datafile_info_t* TRI_FindDatafileInfoPrimaryCollection (TRI_primary_collection_t* primary,
                                                                TRI_voc_fid_t fid,
                                                                bool create) {
  TRI_doc_datafile_info_t const* found;
  TRI_doc_datafile_info_t* dfi;

  found = TRI_LookupByKeyAssociativePointer(&primary->_datafileInfo, &fid);

  if (found != NULL) {
    return CONST_CAST(found);
  }

  if (! create) {
    return NULL;
  }

  // allocate and set to 0
  dfi = TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, sizeof(TRI_doc_datafile_info_t), true);

  if (dfi == NULL) {
    return NULL;
  }

  dfi->_fid = fid;

  TRI_InsertKeyAssociativePointer(&primary->_datafileInfo, &fid, dfi, true);

  return dfi;
}
  template <class elem_t, class holder_t> tos_handle<elem_t>
cdlist_tos_base<elem_t, holder_t>::handle_for_num(size_t position)
  const
{
  size_t total;
  holder_t *follow;
  if (position < 0)
  {
    return this->build_handle(0);
  }
  else if (position >= _cached_size)
  {
    return this->build_handle(0);
  }
  else if (position <= _cached_index / 2)
  {
    /* Start at front. */
    total = 0;
    follow = _head_e;
  }
  else if (position <= (_cached_index + _cached_size) / 2)
  {
    /* Start at cache. */
    total = _cached_index;
    follow = _cached_e;
  }
  else
  {
    /* Start at end. */
    total = _cached_size - 1;
    follow = _tail_e;
  }
  while (total < position)
  {
    ++total;
    follow = follow->next;
  }
  while (total > position)
  {
    --total;
    follow = follow->previous;
  }
  typedef cdlist_tos_base<elem_t, holder_t> *this_type;
  CONST_CAST(this_type, this)->_cached_index = total;
  CONST_CAST(this_type, this)->_cached_e = follow;
  return this->build_handle(follow);
}
SECStatus
tls13_ClientHandleKeyShareXtnHrr(const sslSocket *ss, TLSExtensionData *xtnData, PRUint16 ex_type, SECItem *data)
{
    SECStatus rv;
    PRUint32 tmp;
    const sslNamedGroupDef *group;

    PORT_Assert(!ss->sec.isServer);
    PORT_Assert(ss->vrange.max >= SSL_LIBRARY_VERSION_TLS_1_3);

    SSL_TRC(3, ("%d: SSL3[%d]: handle key_share extension in HRR",
                SSL_GETPID(), ss->fd));

    rv = ssl3_ExtConsumeHandshakeNumber(ss, &tmp, 2, &data->data, &data->len);
    if (rv != SECSuccess) {
        return SECFailure; /* error code already set */
    }
    if (data->len) {
        ssl3_ExtSendAlert(ss, alert_fatal, decode_error);
        PORT_SetError(SSL_ERROR_RX_MALFORMED_HELLO_RETRY_REQUEST);
        return SECFailure;
    }

    group = ssl_LookupNamedGroup((SSLNamedGroup)tmp);
    /* If the group is not enabled, or we already have a share for the
     * requested group, abort. */
    if (!ssl_NamedGroupEnabled(ss, group) ||
        ssl_HaveEphemeralKeyPair(ss, group)) {
        ssl3_ExtSendAlert(ss, alert_fatal, illegal_parameter);
        PORT_SetError(SSL_ERROR_RX_MALFORMED_HELLO_RETRY_REQUEST);
        return SECFailure;
    }

    /* Now delete all the key shares per [draft-ietf-tls-tls13 S 4.1.2] */
    ssl_FreeEphemeralKeyPairs(CONST_CAST(sslSocket, ss));

    /* And replace with our new share. */
    rv = tls13_CreateKeyShare(CONST_CAST(sslSocket, ss), group);
    if (rv != SECSuccess) {
        ssl3_ExtSendAlert(ss, alert_fatal, internal_error);
        PORT_SetError(SEC_ERROR_KEYGEN_FAIL);
        return SECFailure;
    }

    return SECSuccess;
}
//
/// IsValid overrides TValidator's virtual function and compares the string passed
/// in str with the format picture specified in Pic. IsValid returns true if Pic is
/// NULL or if Picture returns Complete for str, indicating that str needs no
/// further input to meet the specified format; otherwise, it returns false.
//
bool
TPXPictureValidator::IsValid(LPCTSTR input)
{
  if (Pic.empty())
    return true;

  TPicResult rslt = Picture(CONST_CAST(LPTSTR,input), false);
  return rslt == prComplete || rslt == prEmpty;
}
//
/// Sets the text of the HeaderItem object.
/// \note The format flags is not updated to contain any alignment flags
//
void
THdrItem::SetText(LPCTSTR str)
{
  mask      |= (HDI_TEXT|HDI_FORMAT);
  fmt       |= (HDF_STRING);
  pszText    = CONST_CAST(LPTSTR, str);
  cchTextMax = static_cast<int>(::_tcslen(str)+1);   // This is probably superfluous,
                                // albeit harmless
}
Exemple #11
0
template <class elem_t, class holder_t> size_t
cdlist_tos_base<elem_t, holder_t>::position(elem_t the_elem) const
{
  size_t total = 0;
  holder_t *follow = _head_e;
  while (follow != 0)
  {
    if (follow->data == the_elem)
    {
      typedef cdlist_tos_base<elem_t, holder_t> *this_type;
      CONST_CAST(this_type, this)->_cached_e = follow;
      CONST_CAST(this_type, this)->_cached_index = total;
      return total;
    }
    ++total;
    follow = follow->next;
  }
  return (size_t)-1;
}
Exemple #12
0
template <class elem_t, class holder_t> tos_handle<elem_t>
cdlist_tos_base<elem_t, holder_t>::lookup_handle(elem_t the_elem) const
{
  size_t total = 0;
  holder_t *follow = _head_e;
  while (follow != 0)
  {
    if (follow->data == the_elem)
    {
      typedef cdlist_tos_base<elem_t, holder_t> *this_type;
      CONST_CAST(this_type, this)->_cached_e = follow;
      CONST_CAST(this_type, this)->_cached_index = total;
      return this->build_handle(follow);
    }
    ++total;
    follow = follow->next;
  }
  return this->build_handle(0);
}
Exemple #13
0
bool typset_has(const struct typset *_set, const struct typ *_t) {
  struct typset *set = CONST_CAST(_set);
  struct typ *t = CONST_CAST(_t);

  struct vectyploc *tentatives = &set->tentatives;
  for (ssize_t n = 0; n < vectyploc_count(tentatives); ++n) {
    struct typ *s = **vectyploc_get(tentatives, n);
    if (!typ_is_tentative(s) && typ_hash_ready(s)) {
      add_final(set, s);
      n += vectyploc_remove_replace_with_last(tentatives, n);
    }

    if (typ_equal(t, s)) {
      return true;
    }
  }

  const uint32_t *existing = fintypset_get(&set->set, t);
  return existing != NULL && *existing;
}
static bool write_object(binn* parent, object_t* object) {
    for (size_t i = 0; i < object->l; ++i) {
        char* key = CONST_CAST(object->children[i * 2].str);
        object_t* value = object->children + i * 2 + 1;
        switch (value->type) {
            case type_nil:     if (!binn_object_set_null(parent, key))                        return false;  break;
            case type_bool:    if (!binn_object_set_bool(parent, key, (BOOL)value->b))        return false;  break;
            case type_double:  if (!binn_object_set_double(parent, key, value->d))            return false;  break;
            case type_int:     if (!binn_object_set_int64(parent, key, value->i))             return false;  break;
            case type_uint:    if (!binn_object_set_uint64(parent, key, value->u))            return false;  break;
            case type_str:     if (!binn_object_set_str(parent, key, CONST_CAST(value->str))) return false;  break;

            case type_array: {
                binn child;
                binn_create_list(&child);
                bool ok = write_list(&child, value);
                if (ok)
                    ok = binn_object_set_object(parent, key, &child);
                binn_free(&child);
                if (!ok)
                    return false;
            } break;

            case type_map: {
                binn child;
                binn_create_object(&child);
                bool ok = write_object(&child, value);
                if (ok)
                    ok = binn_object_set_object(parent, key, &child);
                binn_free(&child);
                if (!ok)
                    return false;
            } break;

            default:
                return false;
        }
    }
    return true;
}
Exemple #15
0
template <class elem_t, class holder_t> void
adlist_tos_base<elem_t, holder_t>::insert(size_t elem_num,
        elem_t the_elem)
{
    assert(elem_num >= 0);
    if (elem_num == 0)
    {
        prepend(the_elem);
        return;
    }
    if (elem_num >= _cached_size)
    {
        while (_cached_size < elem_num)
            append(zero((elem_t *)0));
        append(the_elem);
        return;
    }
    extend_array();
    holder_t *follow;
    if (elem_num - 1 < _index_size)
    {
        follow = _index[elem_num - 1];
    }
    else
    {
        if (_index_size == 0)
        {
            _index[0] = _head_e;
            typedef adlist_tos_base<elem_t, holder_t> *this_type;
            ++(CONST_CAST(this_type, this)->_index_size);
        }
        size_t total = _index_size - 1;
        follow = _index[total];
        while (total < elem_num - 1)
        {
            ++total;
            follow = follow->next;
            _index[total] = follow;
        }
    }
    holder_t *new_e = new holder_t(the_elem, follow->next, follow);
    follow->next = new_e;
    if (_tail_e == follow)
        _tail_e = new_e;
    else
        new_e->next->previous = new_e;
    _index[elem_num] = new_e;
    _index_size = elem_num + 1;
    ++_cached_size;
}
Exemple #16
0
template <class elem_t, class holder_t> void
adlist_tos_base<elem_t, holder_t>::remove(size_t elem_num)
{
    if (elem_num < 0)
        return;
    else if (elem_num >= _cached_size)
        return;
    holder_t *follow;
    if (elem_num < _index_size)
    {
        follow = _index[elem_num];
    }
    else
    {
        if (_index_size == 0)
        {
            _index[0] = _head_e;
            typedef adlist_tos_base<elem_t, holder_t> *this_type;
            ++(CONST_CAST(this_type, this)->_index_size);
        }
        size_t total = _index_size - 1;
        follow = _index[total];
        while (total < elem_num)
        {
            ++total;
            follow = follow->next;
            _index[total] = follow;
        }
    }
    holder_t *old_e = follow;
    if (_head_e == old_e)
        _head_e = old_e->next;
    else
        old_e->previous->next = old_e->next;
    if (_tail_e == old_e)
        _tail_e = old_e->previous;
    else
        old_e->next->previous = old_e->previous;
    old_e->remove_ref();
    if (old_e->delete_me())
        delete old_e;
    _index_size = elem_num;
    --_cached_size;
}
Exemple #17
0
template <class elem_t, class holder_t> tos_handle<elem_t>
adlist_tos_base<elem_t, holder_t>::lookup_handle(elem_t the_elem) const
{
    size_t total = 0;
    holder_t *follow = _head_e;
    while (follow != 0)
    {
        if (total >= _index_size)
        {
            _index[total] = follow;
            typedef adlist_tos_base<elem_t, holder_t> *this_type;
            ++(CONST_CAST(this_type, this)->_index_size);
        }
        if (follow->data == the_elem)
            return build_handle(follow);
        ++total;
        follow = follow->next;
    }
    return build_handle(0);
}
Exemple #18
0
template <class elem_t, class holder_t> size_t
adlist_tos_base<elem_t, holder_t>::position(elem_t the_elem) const
{
    size_t total = 0;
    holder_t *follow = _head_e;
    while (follow != 0)
    {
        if (total >= _index_size)
        {
            _index[total] = follow;
            typedef adlist_tos_base<elem_t, holder_t> *this_type;
            ++(CONST_CAST(this_type, this)->_index_size);
        }
        if (follow->data == the_elem)
            return total;
        ++total;
        follow = follow->next;
    }
    return (size_t)-1;
}
GLenum glxewContextInit (GLXEW_CONTEXT_ARG_DEF_LIST)
{
  int major, minor;
  const GLubyte* extStart;
  const GLubyte* extEnd;
  /* initialize core GLX 1.2 */
  if (_glewInit_GLX_VERSION_1_2(GLEW_CONTEXT_ARG_VAR_INIT)) return GLEW_ERROR_GLX_VERSION_11_ONLY;
  /* initialize flags */
  CONST_CAST(GLXEW_VERSION_1_0) = GL_TRUE;
  CONST_CAST(GLXEW_VERSION_1_1) = GL_TRUE;
  CONST_CAST(GLXEW_VERSION_1_2) = GL_TRUE;
  CONST_CAST(GLXEW_VERSION_1_3) = GL_TRUE;
  CONST_CAST(GLXEW_VERSION_1_4) = GL_TRUE;
  /* query GLX version */
  glXQueryVersion(glXGetCurrentDisplay(), &major, &minor);
  if (major == 1 && minor <= 3)
  {
    switch (minor)
    {
      case 3:
      CONST_CAST(GLXEW_VERSION_1_4) = GL_FALSE;
      break;
      case 2:
      CONST_CAST(GLXEW_VERSION_1_4) = GL_FALSE;
      CONST_CAST(GLXEW_VERSION_1_3) = GL_FALSE;
      break;
      default:
      return GLEW_ERROR_GLX_VERSION_11_ONLY;
      break;
    }
  }
  /* query GLX extension string */
  extStart = 0;
  if (glXGetCurrentDisplay != NULL)
    extStart = (const GLubyte*)glXGetClientString(glXGetCurrentDisplay(), GLX_EXTENSIONS);
  if (extStart == 0)
    extStart = (const GLubyte *)"";
  extEnd = extStart + _glewStrLen(extStart);
Exemple #20
0
static int RemoveGeoIndex (TRI_index_t* idx,
                           TRI_doc_mptr_t const* doc,
                           bool isRollback) {
  GeoCoordinate gc;
  TRI_shaped_json_t shapedJson;
  TRI_geo_index_t* geo;
  TRI_shaper_t* shaper;
  bool missing;
  bool ok;
  double latitude;
  double longitude;

  geo = (TRI_geo_index_t*) idx;
  shaper = geo->base._collection->getShaper();  // ONLY IN INDEX, PROTECTED by RUNTIME
  TRI_EXTRACT_SHAPED_JSON_MARKER(shapedJson, doc->getDataPtr());  // ONLY IN INDEX, PROTECTED by RUNTIME

  // lookup OLD latitude and longitude
  if (geo->_location != 0) {
    ok = ExtractDoubleList(shaper, &shapedJson, geo->_location, &latitude, &longitude, &missing);
  }
  else {
    ok = ExtractDoubleArray(shaper, &shapedJson, geo->_latitude, &latitude, &missing);
    ok = ok && ExtractDoubleArray(shaper, &shapedJson, geo->_longitude, &longitude, &missing);
  }

  // and remove old entry
  if (ok) {
    gc.latitude = latitude;
    gc.longitude = longitude;

    gc.data = CONST_CAST(doc);

    // ignore non-existing elements in geo-index
    GeoIndex_remove(geo->_geoIndex, &gc);
  }

  return TRI_ERROR_NO_ERROR;
}
Exemple #21
0
int PQIndex_remove (PQIndex* idx, TRI_doc_mptr_t const* doc) {
  TRI_pq_index_element_t* item;  
  bool ok;

  if (idx == NULL) {
    return TRI_ERROR_ARANGO_INDEX_PQ_REMOVE_FAILED;
  }

  // ...........................................................................
  // Check if item exists in the associative array.
  // ...........................................................................

  item = TRI_FindByKeyAssociativeArray(idx->_aa, CONST_CAST(doc));

  if (item == NULL) {
    return TRI_ERROR_ARANGO_INDEX_PQ_REMOVE_ITEM_MISSING;
  }
  
  // ...........................................................................
  // Remove item from the priority queue
  // ...........................................................................
  
  ok = idx->_pq->remove(idx->_pq, item->pqSlot, true);
 
  // ...........................................................................
  // Remove item from associative array
  // Must come after remove above, since update storage will be called.
  // ...........................................................................
  
  ok = TRI_RemoveElementAssociativeArray(idx->_aa, item, NULL) && ok;
  
  if (!ok) {
    return TRI_ERROR_ARANGO_INDEX_PQ_REMOVE_FAILED;
  }

  return TRI_ERROR_NO_ERROR;
}
Exemple #22
0
static int FillIndexSearchValueByHashIndexElement (TRI_hash_index_t* idx,
                                                   TRI_index_search_value_t* key,
                                                   TRI_hash_index_element_t* element) {
  char const* ptr;
  size_t n;
  size_t i;

  n = idx->_paths._length;
  key->_values = TRI_Allocate(TRI_UNKNOWN_MEM_ZONE, n * sizeof(TRI_shaped_json_t), false);

  if (key->_values == NULL) {
    return TRI_ERROR_OUT_OF_MEMORY;
  }

  ptr = (char const*) element->_document->_data;

  for (i = 0;  i < n;  ++i) {
    key->_values[i]._sid = element->_subObjects[i]._sid;
    key->_values[i]._data.length = element->_subObjects[i]._length;
    key->_values[i]._data.data = CONST_CAST(ptr + element->_subObjects[i]._offset);
  }

  return TRI_ERROR_NO_ERROR;
}
Exemple #23
0
static bool Compactifier (TRI_df_marker_t const* marker, 
                          void* data, 
                          TRI_datafile_t* datafile, 
                          bool journal) {
  TRI_df_marker_t* result;
  TRI_doc_mptr_t const* found;
  TRI_document_collection_t* document;
  TRI_primary_collection_t* primary;
  compaction_context_t* context;
  int res;

  context  = data;
  document = context->_document;
  primary  = &document->base;

  // new or updated document
  if (marker->_type == TRI_DOC_MARKER_KEY_DOCUMENT ||
      marker->_type == TRI_DOC_MARKER_KEY_EDGE) {

    TRI_doc_document_key_marker_t const* d;
    TRI_doc_mptr_t* found2;
    TRI_voc_key_t key;
    bool deleted;

    d = (TRI_doc_document_key_marker_t const*) marker;
    key = (char*) d + d->_offsetKey;

    // check if the document is still active
    TRI_READ_LOCK_DOCUMENTS_INDEXES_PRIMARY_COLLECTION(primary);

    found = TRI_LookupByKeyAssociativePointer(&primary->_primaryIndex, key);
    deleted = (found == NULL || found->_rid > d->_rid);

    TRI_READ_UNLOCK_DOCUMENTS_INDEXES_PRIMARY_COLLECTION(primary);

    if (deleted) {
      LOG_TRACE("found a stale document: %s", key);
      return true;
    }
    
    context->_keepDeletions = true;

    // write to compactor files
    res = CopyMarker(document, context->_compactor, marker, &result);

    if (res != TRI_ERROR_NO_ERROR) {
      LOG_FATAL_AND_EXIT("cannot write compactor file: %s", TRI_last_error());
    }

    // check if the document is still active
    TRI_WRITE_LOCK_DOCUMENTS_INDEXES_PRIMARY_COLLECTION(primary);

    found = TRI_LookupByKeyAssociativePointer(&primary->_primaryIndex, key);
    deleted = found == NULL;

    if (deleted) {
      context->_dfi._numberDead += 1;
      context->_dfi._sizeDead += (int64_t) marker->_size;
      
      TRI_WRITE_UNLOCK_DOCUMENTS_INDEXES_PRIMARY_COLLECTION(primary);

      LOG_DEBUG("found a stale document after copying: %s", key);

      return true;
    }

    found2 = CONST_CAST(found);
    assert(found2->_data != NULL);
    assert(((TRI_df_marker_t*) found2->_data)->_size > 0);

    // the fid might change
    if (found->_fid != context->_compactor->_fid) {
      // update old datafile's info
      TRI_doc_datafile_info_t* dfi = TRI_FindDatafileInfoPrimaryCollection(primary, found->_fid, false);

      if (dfi != NULL) {
        dfi->_numberDead += 1;
        dfi->_sizeDead += (int64_t) marker->_size;
      }

      found2->_fid = context->_compactor->_fid;
    }

    // let marker point to the new position
    found2->_data = result;

    // let _key point to the new key position
    found2->_key = ((char*) result) + (((TRI_doc_document_key_marker_t*) result)->_offsetKey);

    // update datafile info
    context->_dfi._numberAlive += 1;
    context->_dfi._sizeAlive += (int64_t) marker->_size;

    TRI_WRITE_UNLOCK_DOCUMENTS_INDEXES_PRIMARY_COLLECTION(primary);
  }

  // deletion
  else if (marker->_type == TRI_DOC_MARKER_KEY_DELETION && 
           context->_keepDeletions) {
    // write to compactor files
    res = CopyMarker(document, context->_compactor, marker, &result);

    if (res != TRI_ERROR_NO_ERROR) {
      LOG_FATAL_AND_EXIT("cannot write compactor file: %s", TRI_last_error());
    }

    // update datafile info
    context->_dfi._numberDeletion++;
  }
  else if (marker->_type == TRI_DOC_MARKER_BEGIN_TRANSACTION ||
           marker->_type == TRI_DOC_MARKER_COMMIT_TRANSACTION ||
           marker->_type == TRI_DOC_MARKER_ABORT_TRANSACTION ||
           marker->_type == TRI_DOC_MARKER_PREPARE_TRANSACTION) {
    // write to compactor files
    res = CopyMarker(document, context->_compactor, marker, &result);

    if (res != TRI_ERROR_NO_ERROR) {
      LOG_FATAL_AND_EXIT("cannot write compactor file: %s", TRI_last_error());
    }
    
    context->_dfi._numberTransaction++;
    context->_dfi._sizeTransaction += (int64_t) marker->_size;
  }

  return true;
}
static
#endif
GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
{
  const GLubyte* s;
  GLuint dot;
  GLint major, minor;
  /* query opengl version */
  s = glGetString(GL_VERSION);
  dot = _glewStrCLen(s, '.');
  if (dot == 0)
    return GLEW_ERROR_NO_GL_VERSION;
  
  major = s[dot-1]-'0';
  minor = s[dot+1]-'0';

  if (minor < 0 || minor > 9)
    minor = 0;
  if (major<0 || major>9)
    return GLEW_ERROR_NO_GL_VERSION;
  

  if (major == 1 && minor == 0)
  {
    return GLEW_ERROR_GL_VERSION_10_ONLY;
  }
  else
  {
    CONST_CAST(GLEW_VERSION_4_1)   = ( major > 4 )                 || ( major == 4 && minor >= 1 ) ? GL_TRUE : GL_FALSE;
    CONST_CAST(GLEW_VERSION_4_0)   = GLEW_VERSION_4_1   == GL_TRUE || ( major == 4               ) ? GL_TRUE : GL_FALSE;
    CONST_CAST(GLEW_VERSION_3_3)   = GLEW_VERSION_4_0   == GL_TRUE || ( major == 3 && minor >= 3 ) ? GL_TRUE : GL_FALSE;
    CONST_CAST(GLEW_VERSION_3_2)   = GLEW_VERSION_3_3   == GL_TRUE || ( major == 3 && minor >= 2 ) ? GL_TRUE : GL_FALSE;
    CONST_CAST(GLEW_VERSION_3_1)   = GLEW_VERSION_3_2   == GL_TRUE || ( major == 3 && minor >= 1 ) ? GL_TRUE : GL_FALSE;
    CONST_CAST(GLEW_VERSION_3_0)   = GLEW_VERSION_3_1   == GL_TRUE || ( major == 3               ) ? GL_TRUE : GL_FALSE;
    CONST_CAST(GLEW_VERSION_2_1)   = GLEW_VERSION_3_0   == GL_TRUE || ( major == 2 && minor >= 1 ) ? GL_TRUE : GL_FALSE;    
    CONST_CAST(GLEW_VERSION_2_0)   = GLEW_VERSION_2_1   == GL_TRUE || ( major == 2               ) ? GL_TRUE : GL_FALSE;
    CONST_CAST(GLEW_VERSION_1_5)   = GLEW_VERSION_2_0   == GL_TRUE || ( major == 1 && minor >= 5 ) ? GL_TRUE : GL_FALSE;
    CONST_CAST(GLEW_VERSION_1_4)   = GLEW_VERSION_1_5   == GL_TRUE || ( major == 1 && minor >= 4 ) ? GL_TRUE : GL_FALSE;
    CONST_CAST(GLEW_VERSION_1_3)   = GLEW_VERSION_1_4   == GL_TRUE || ( major == 1 && minor >= 3 ) ? GL_TRUE : GL_FALSE;
    CONST_CAST(GLEW_VERSION_1_2_1) = GLEW_VERSION_1_3   == GL_TRUE                                 ? GL_TRUE : GL_FALSE; 
    CONST_CAST(GLEW_VERSION_1_2)   = GLEW_VERSION_1_2_1 == GL_TRUE || ( major == 1 && minor >= 2 ) ? GL_TRUE : GL_FALSE;
    CONST_CAST(GLEW_VERSION_1_1)   = GLEW_VERSION_1_2   == GL_TRUE || ( major == 1 && minor >= 1 ) ? GL_TRUE : GL_FALSE;
  }
/* Handle a TLS 1.3 PreSharedKey Extension. We only accept PSKs
 * that contain session tickets. */
SECStatus
tls13_ServerHandlePreSharedKeyXtn(const sslSocket *ss, TLSExtensionData *xtnData, PRUint16 ex_type,
                                  SECItem *data)
{
    SECItem inner;
    SECStatus rv;
    unsigned int numIdentities = 0;
    unsigned int numBinders = 0;

    SSL_TRC(3, ("%d: SSL3[%d]: handle pre_shared_key extension",
                SSL_GETPID(), ss->fd));

    /* If we are doing < TLS 1.3, then ignore this. */
    if (ss->version < SSL_LIBRARY_VERSION_TLS_1_3) {
        return SECSuccess;
    }

    /* Parse the identities list. */
    rv = ssl3_ExtConsumeHandshakeVariable(ss,
                                          &inner, 2, &data->data, &data->len);
    if (rv != SECSuccess) {
        return SECFailure;
    }

    while (inner.len) {
        SECItem label;
        PRUint32 utmp;

        rv = ssl3_ExtConsumeHandshakeVariable(ss, &label, 2,
                                              &inner.data, &inner.len);
        if (rv != SECSuccess)
            return rv;
        if (!label.len) {
            goto alert_loser;
        }

        /* Read and discard session ticket age. Bug 1295163 */
        rv = ssl3_ExtConsumeHandshake(ss, &utmp, 4,
                                      &inner.data, &inner.len);
        if (rv != SECSuccess)
            return rv;

        if (!numIdentities) {
            PRINT_BUF(50, (ss, "Handling PreSharedKey value",
                           label.data, label.len));
            rv = ssl3_ProcessSessionTicketCommon(
                CONST_CAST(sslSocket, ss), &label);
            /* This only happens if we have an internal error, not
             * a malformed ticket. Bogus tickets just don't resume
             * and return SECSuccess. */
            if (rv != SECSuccess)
                return SECFailure;
        }
        ++numIdentities;
    }

    xtnData->pskBinderPrefixLen = ss->ssl3.hs.messages.len - data->len;

    /* Parse the binders list. */
    rv = ssl3_ExtConsumeHandshakeVariable(ss,
                                          &inner, 2, &data->data, &data->len);
    if (rv != SECSuccess)
        return SECFailure;
    if (data->len) {
        goto alert_loser;
    }

    while (inner.len) {
        SECItem binder;
        rv = ssl3_ExtConsumeHandshakeVariable(ss, &binder, 1,
                                              &inner.data, &inner.len);
        if (rv != SECSuccess)
            return rv;
        if (binder.len < 32) {
            goto alert_loser;
        }

        if (!numBinders) {
            xtnData->pskBinder = binder;
        }
        ++numBinders;
    }

    if (numBinders != numIdentities)
        goto alert_loser;

    /* Keep track of negotiated extensions. Note that this does not
     * mean we are resuming. */
    xtnData->negotiated[xtnData->numNegotiated++] = ex_type;

    return SECSuccess;

alert_loser:
    ssl3_ExtSendAlert(ss, alert_fatal, illegal_parameter);
    PORT_SetError(SSL_ERROR_MALFORMED_PRE_SHARED_KEY);
    return SECFailure;
}
/* Called by clients.
 *
 *      struct {
 *         opaque identity<0..2^16-1>;
 *         uint32 obfuscated_ticket_age;
 *     } PskIdentity;
 *
 *     opaque PskBinderEntry<32..255>;
 *
 *     struct {
 *         select (Handshake.msg_type) {
 *             case client_hello:
 *                 PskIdentity identities<6..2^16-1>;
 *                 PskBinderEntry binders<33..2^16-1>;
 *
 *             case server_hello:
 *                 uint16 selected_identity;
 *         };
 *
 *     } PreSharedKeyExtension;

 * Presently the only way to get a PSK is by resumption, so this is
 * really a ticket label and there will be at most one.
 */
PRInt32
tls13_ClientSendPreSharedKeyXtn(const sslSocket *ss, TLSExtensionData *xtnData,
                                PRBool append,
                                PRUint32 maxBytes)
{
    PRInt32 extension_length;
    PRInt32 identities_length;
    PRInt32 binders_length;
    NewSessionTicket *session_ticket;

    /* We only set statelessResume on the client in TLS 1.3 code. */
    if (!ss->statelessResume)
        return 0;

    PORT_Assert(ss->vrange.max >= SSL_LIBRARY_VERSION_TLS_1_3);

    /* The length computations are simplified by the fact that there
     * is just one ticket at most. */
    session_ticket = &ss->sec.ci.sid->u.ssl3.locked.sessionTicket;
    identities_length =
        2 +                              /* vector length */
        2 + session_ticket->ticket.len + /* identity length + ticket len */
        4;                               /* obfuscated_ticket_age */
    binders_length =
        2 + /* vector length */
        1 + tls13_GetHashSizeForHash(
                tls13_GetHashForCipherSuite(ss->sec.ci.sid->u.ssl3.cipherSuite));
    extension_length =
        2 + 2 + /* Type + length */
        identities_length + binders_length;

    if (maxBytes < (PRUint32)extension_length) {
        PORT_Assert(0);
        return 0;
    }

    if (append) {
        SECStatus rv;
        PRTime age;
        unsigned int prefixLength;
        PRUint8 binder[TLS13_MAX_FINISHED_SIZE];
        unsigned int binderLen;

        /* extension_type */
        rv = ssl3_ExtAppendHandshakeNumber(ss, ssl_tls13_pre_shared_key_xtn, 2);
        if (rv != SECSuccess)
            goto loser;
        rv = ssl3_ExtAppendHandshakeNumber(ss, extension_length - 4, 2);
        if (rv != SECSuccess)
            goto loser;
        rv = ssl3_ExtAppendHandshakeNumber(ss, identities_length - 2, 2);
        if (rv != SECSuccess)
            goto loser;
        rv = ssl3_ExtAppendHandshakeVariable(ss, session_ticket->ticket.data,
                                             session_ticket->ticket.len, 2);
        if (rv != SECSuccess)
            goto loser;

        /* Obfuscated age. */
        age = PR_Now() - session_ticket->received_timestamp;
        age /= PR_USEC_PER_MSEC;
        age += session_ticket->ticket_age_add;
        rv = ssl3_ExtAppendHandshakeNumber(ss, age, 4);
        if (rv != SECSuccess)
            goto loser;

        /* Now the binders. */
        prefixLength = ss->ssl3.hs.messages.len;
        rv = tls13_ComputePskBinder(CONST_CAST(sslSocket, ss), PR_TRUE,
                                    prefixLength, binder, &binderLen,
                                    sizeof(binder));
        if (rv != SECSuccess)
            goto loser;
        PORT_Assert(binderLen == tls13_GetHashSize(ss));
        rv = ssl3_ExtAppendHandshakeNumber(ss, binders_length - 2, 2);
        if (rv != SECSuccess)
            goto loser;
        rv = ssl3_ExtAppendHandshakeVariable(ss,
                                             binder, binderLen, 1);
        if (rv != SECSuccess)
            goto loser;

        PRINT_BUF(50, (ss, "Sending PreSharedKey value",
                       session_ticket->ticket.data,
                       session_ticket->ticket.len));

        xtnData->sentSessionTicketInClientHello = PR_TRUE;
        xtnData->advertised[xtnData->numAdvertised++] =
            ssl_tls13_pre_shared_key_xtn;
    }
    return extension_length;

loser:
    xtnData->ticketTimestampVerified = PR_FALSE;
    return -1;
}
Exemple #27
0
static
#endif
GLenum glewContextInit (GLEW_CONTEXT_ARG_DEF_LIST)
{
  const GLubyte* s;
  GLuint dot, major, minor;
  /* query opengl version */
  s = glGetString(GL_VERSION);
  dot = _glewStrCLen(s, '.');
  major = dot-1;
  minor = dot+1;
  if (dot == 0 || s[minor] == '\0')
    return GLEW_ERROR_NO_GL_VERSION;
  if (s[major] == '1' && s[minor] == '0')
  {
	return GLEW_ERROR_GL_VERSION_10_ONLY;
  }
  else
  {
    CONST_CAST(GLEW_VERSION_1_1) = GL_TRUE;
	if (s[major] >= '2')
	{
      CONST_CAST(GLEW_VERSION_1_2) = GL_TRUE;
      CONST_CAST(GLEW_VERSION_1_3) = GL_TRUE;
      CONST_CAST(GLEW_VERSION_1_4) = GL_TRUE;
	  CONST_CAST(GLEW_VERSION_1_5) = GL_TRUE;
	  CONST_CAST(GLEW_VERSION_2_0) = GL_TRUE;
	  if (s[minor] >= '1')
	  {
	    CONST_CAST(GLEW_VERSION_2_1) = GL_TRUE;
      }
	}
	else
	{
	  if (s[minor] >= '5')
	  {
		CONST_CAST(GLEW_VERSION_1_2) = GL_TRUE;
		CONST_CAST(GLEW_VERSION_1_3) = GL_TRUE;
		CONST_CAST(GLEW_VERSION_1_4) = GL_TRUE;
		CONST_CAST(GLEW_VERSION_1_5) = GL_TRUE;
		CONST_CAST(GLEW_VERSION_2_0) = GL_FALSE;
		CONST_CAST(GLEW_VERSION_2_1) = GL_FALSE;
	  }
	  if (s[minor] == '4')
	  {
		CONST_CAST(GLEW_VERSION_1_2) = GL_TRUE;
		CONST_CAST(GLEW_VERSION_1_3) = GL_TRUE;
		CONST_CAST(GLEW_VERSION_1_4) = GL_TRUE;
		CONST_CAST(GLEW_VERSION_1_5) = GL_FALSE;
		CONST_CAST(GLEW_VERSION_2_0) = GL_FALSE;
		CONST_CAST(GLEW_VERSION_2_1) = GL_FALSE;
	  }
	  if (s[minor] == '3')
	  {
		CONST_CAST(GLEW_VERSION_1_2) = GL_TRUE;
		CONST_CAST(GLEW_VERSION_1_3) = GL_TRUE;
		CONST_CAST(GLEW_VERSION_1_4) = GL_FALSE;
		CONST_CAST(GLEW_VERSION_1_5) = GL_FALSE;
		CONST_CAST(GLEW_VERSION_2_0) = GL_FALSE;
		CONST_CAST(GLEW_VERSION_2_1) = GL_FALSE;
	  }
	  if (s[minor] == '2')
	  {
		CONST_CAST(GLEW_VERSION_1_2) = GL_TRUE;
		CONST_CAST(GLEW_VERSION_1_3) = GL_FALSE;
		CONST_CAST(GLEW_VERSION_1_4) = GL_FALSE;
		CONST_CAST(GLEW_VERSION_1_5) = GL_FALSE;
		CONST_CAST(GLEW_VERSION_2_0) = GL_FALSE;
		CONST_CAST(GLEW_VERSION_2_1) = GL_FALSE;
	  }
	  if (s[minor] < '2')
	  {
		CONST_CAST(GLEW_VERSION_1_2) = GL_FALSE;
		CONST_CAST(GLEW_VERSION_1_3) = GL_FALSE;
		CONST_CAST(GLEW_VERSION_1_4) = GL_FALSE;
		CONST_CAST(GLEW_VERSION_1_5) = GL_FALSE;
		CONST_CAST(GLEW_VERSION_2_0) = GL_FALSE;
		CONST_CAST(GLEW_VERSION_2_1) = GL_FALSE;
	  }
	}
  }
Exemple #28
0
static const char *collect_module_flag(const struct module *mod, ident flag) {
  char **r = ident2str_get(&CONST_CAST(mod)->build.flags, flag);
  return r == NULL ? "" : *r;
}
Exemple #29
0
void debug_print_typset(const struct module *mod, const struct typset *set) {
  error never = typset_foreach(CONST_CAST(mod), CONST_CAST(set), print_each, NULL);
  assert(!never);
}
Exemple #30
0
static int HashIndexHelper (TRI_hash_index_t const* hashIndex,
                            TRI_hash_index_element_t* hashElement,
                            TRI_doc_mptr_t const* document) {
  int res;
  size_t j;

  TRI_shaper_t* shaper;                 // underlying shaper
  TRI_shape_access_t const* acc;        // shape accessor
  TRI_shaped_json_t shapedObject;	// the sub-object
  TRI_shaped_json_t shapedJson;         // the object behind document
  TRI_shaped_sub_t shapedSub;           // the relative sub-object

  shaper = hashIndex->base._collection->_shaper;

  // .............................................................................
  // Assign the document to the TRI_hash_index_element_t structure - so that it
  // can later be retreived.
  // .............................................................................

  TRI_EXTRACT_SHAPED_JSON_MARKER(shapedJson, document->_data);

  hashElement->_document = CONST_CAST(document);

  // .............................................................................
  // Extract the attribute values
  // .............................................................................

  res = TRI_ERROR_NO_ERROR;

  for (j = 0;  j < hashIndex->_paths._length;  ++j) {
    TRI_shape_pid_t path = *((TRI_shape_pid_t*)(TRI_AtVector(&hashIndex->_paths, j)));

    // determine if document has that particular shape
    acc = TRI_FindAccessorVocShaper(shaper, shapedJson._sid, path);

    // field not part of the object
    if (acc == NULL || acc->_shape == NULL) {
      shapedSub._sid = shaper->_sidNull;
      shapedSub._length = 0;
      shapedSub._offset = 0;

      res = TRI_WARNING_ARANGO_INDEX_HASH_DOCUMENT_ATTRIBUTE_MISSING;
    }

    // extract the field
    else {
      if (! TRI_ExecuteShapeAccessor(acc, &shapedJson, &shapedObject)) {
        // hashElement->fields: memory deallocated in the calling procedure
        return TRI_ERROR_INTERNAL;
      }

      if (shapedObject._sid == shaper->_sidNull) {
        res = TRI_WARNING_ARANGO_INDEX_HASH_DOCUMENT_ATTRIBUTE_MISSING;
      }

      shapedSub._sid = shapedObject._sid;
      shapedSub._length = shapedObject._data.length;
      shapedSub._offset = ((char const*) shapedObject._data.data) - ((char const*) document->_data);
    }

    // store the json shaped sub-object -- this is what will be hashed
    hashElement->_subObjects[j] = shapedSub;
  }

  return res;
}