X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fsasl.cc;h=40d37e3a6e9f165743f22e56fc84803b5f35cbcf;hb=3dcd41c50068eec906a1a11a178e9b3f08ef2326;hp=32906cc8a8858e82056d8b87c822afd53147be0f;hpb=098b147ae544499cda8b3c7333173bb5f6e01b82;p=m6w6%2Flibmemcached diff --git a/libmemcached/sasl.cc b/libmemcached/sasl.cc index 32906cc8..40d37e3a 100644 --- a/libmemcached/sasl.cc +++ b/libmemcached/sasl.cc @@ -40,7 +40,10 @@ #if defined(LIBMEMCACHED_WITH_SASL_SUPPORT) && LIBMEMCACHED_WITH_SASL_SUPPORT +#if defined(HAVE_LIBSASL) && HAVE_LIBSASL #include +#endif + #include void memcached_set_sasl_callbacks(memcached_st *ptr, @@ -133,9 +136,10 @@ memcached_return_t memcached_sasl_authenticate_connection(memcached_server_st *s } /* SANITY CHECK: SASL can only be used with the binary protocol */ - if (server->root->flags.binary_protocol == false) + if (memcached_is_binary(server->root) == false) { - return MEMCACHED_PROTOCOL_ERROR; + return memcached_set_error(*server, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, + memcached_literal_param("memcached_sasl_authenticate_connection() is not supported via the ASCII protocol")); } /* Try to get the supported mech from the server. Servers without SASL @@ -229,7 +233,7 @@ memcached_return_t memcached_sasl_authenticate_connection(memcached_server_st *s do { /* send the packet */ - struct libmemcached_io_vector_st vector[]= + libmemcached_io_vector_st vector[]= { { request.bytes, sizeof(request.bytes) }, { chosenmech, keylen }, @@ -321,7 +325,7 @@ memcached_return_t memcached_set_sasl_auth_data(memcached_st *ptr, memcached_destroy_sasl_auth_data(ptr); - sasl_callback_t *callbacks= (sasl_callback_t*)libmemcached_calloc(ptr, 4, sizeof(sasl_callback_t)); + sasl_callback_t *callbacks= libmemcached_xcalloc(ptr, 4, sasl_callback_t); size_t password_length= strlen(password); size_t username_length= strlen(username); char *name= (char *)libmemcached_malloc(ptr, username_length +1); @@ -423,7 +427,7 @@ memcached_return_t memcached_clone_sasl(memcached_st *clone, const memcached_st * into the list, but if we don't know the ID we don't know how to handle * the context... */ - size_t total= 0; + ptrdiff_t total= 0; while (source->sasl.callbacks[total].id != SASL_CB_LIST_END) { @@ -441,7 +445,7 @@ memcached_return_t memcached_clone_sasl(memcached_st *clone, const memcached_st ++total; } - sasl_callback_t *callbacks= (sasl_callback_t*)libmemcached_calloc(clone, total +1, sizeof(sasl_callback_t)); + sasl_callback_t *callbacks= libmemcached_xcalloc(clone, total +1, sasl_callback_t); if (callbacks == NULL) { return MEMCACHED_MEMORY_ALLOCATION_FAILURE; @@ -449,7 +453,7 @@ memcached_return_t memcached_clone_sasl(memcached_st *clone, const memcached_st memcpy(callbacks, source->sasl.callbacks, (total + 1) * sizeof(sasl_callback_t)); /* Now update the context... */ - for (size_t x= 0; x < total; ++x) + for (ptrdiff_t x= 0; x < total; ++x) { if (callbacks[x].id == SASL_CB_USER || callbacks[x].id == SASL_CB_AUTHNAME) { @@ -458,7 +462,7 @@ memcached_return_t memcached_clone_sasl(memcached_st *clone, const memcached_st if (callbacks[x].context == NULL) { /* Failed to allocate memory, clean up previously allocated memory */ - for (size_t y= 0; y < x; ++y) + for (ptrdiff_t y= 0; y < x; ++y) { libmemcached_free(clone, clone->sasl.callbacks[y].context); } @@ -475,7 +479,7 @@ memcached_return_t memcached_clone_sasl(memcached_st *clone, const memcached_st if (n == NULL) { /* Failed to allocate memory, clean up previously allocated memory */ - for (size_t y= 0; y < x; ++y) + for (ptrdiff_t y= 0; y < x; ++y) { libmemcached_free(clone, clone->sasl.callbacks[y].context); }