提交 d99b4bb8 authored 作者: Anthony Minessale's avatar Anthony Minessale

misc fixes

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5053 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 578e2cd3
......@@ -35,7 +35,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#endif
#include <string.h>
......@@ -82,7 +82,7 @@
static int opt_timeout = 30;
static void sha1_hash(char *out, char *in, unsigned int len);
static void sha1_hash(char *out, unsigned char *in, unsigned int len);
static int b64encode(unsigned char *in, size_t ilen, unsigned char *out, size_t olen);
static void ldl_random_string(char *buf, uint16_t len, char *set);
......@@ -725,7 +725,7 @@ static ldl_avatar_t *ldl_get_avatar(ldl_handle_t *handle, char *path, char *from
int fd = -1;
size_t bytes;
char *key;
char hash[128] = "";
//char hash[128] = "";
if (from && (ap = (ldl_avatar_t *) apr_hash_get(globals.avatar_hash, from, APR_HASH_KEY_STRING))) {
return ap;
......@@ -756,8 +756,7 @@ static ldl_avatar_t *ldl_get_avatar(ldl_handle_t *handle, char *path, char *from
ap = malloc(sizeof(*ap));
assert(ap != NULL);
memset(ap, 0, sizeof(*ap));
ldl_random_string(hash, sizeof(hash) -1, NULL);
sha1_hash(ap->hash, hash, (unsigned)strlen(hash));
sha1_hash(ap->hash, (unsigned char *) image, (unsigned int)bytes);
ap->path = strdup(path);
key = ldl_handle_strdup(handle, from);
......@@ -1048,21 +1047,21 @@ static int b64encode(unsigned char *in, size_t ilen, unsigned char *out, size_t
return 0;
}
static void sha1_hash(char *out, char *in, unsigned int len)
static void sha1_hash(char *out, unsigned char *in, unsigned int len)
{
sha_context_t sha;
SHA1Context sha;
char *p;
int x;
unsigned char digest[20] = "";
unsigned char digest[SHA1_HASH_SIZE] = "";
SHA1Init(&sha);
SHA1Update(&sha, (unsigned char *) in, len);
SHA1Update(&sha, in, len);
SHA1Final(digest, &sha);
SHA1Final(&sha, digest);
p = out;
for (x = 0; x < 20; x++) {
for (x = 0; x < SHA1_HASH_SIZE; x++) {
p += sprintf(p, "%2.2x", digest[x]);
}
}
......@@ -1084,7 +1083,7 @@ static int on_stream_component(ldl_handle_t *handle, int type, iks *node)
char handshake[512] = "";
snprintf(secret, sizeof(secret), "%s%s", pak->id, handle->password);
sha1_hash(hash, secret, (unsigned)strlen(secret));
sha1_hash(hash, (unsigned char *) secret, (unsigned int)strlen(secret));
snprintf(handshake, sizeof(handshake), "<handshake>%s</handshake>", hash);
iks_send_raw(handle->parser, handshake);
handle->state = CS_START;
......
/*
* libDingaLing XMPP Jingle Library
* Copyright (C) 2005/2006, Anthony Minessale II <anthmct@yahoo.com>
/*-
* Copyright (c) 2001-2003 Allan Saddi <allan@saddi.com>
* All rights reserved.
*
* Version: MPL 1.1
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is libDingaLing XMPP Jingle Library
*
* The Initial Developer of the Original Code is
* Steve Reid <steve@edmweb.com>
* Portions created by the Initial Developer are Copyright (C)
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Steve Reid <steve@edmweb.com>
*
* sha1.h
* THIS SOFTWARE IS PROVIDED BY ALLAN SADDI AND HIS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL ALLAN SADDI OR HIS CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id: sha1.h 347 2003-02-23 22:11:49Z asaddi $
*/
/*! \file sha1.h
\brief SHA1
*/
#ifndef __SHA1_H
#define __SHA1_H
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __STUPIDFORMATBUG__
}
#endif
#undef inline
#define inline __inline
#ifndef _SHA1_H
#define _SHA1_H
#ifndef uint32_t
#ifdef WIN32
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
typedef __int8 int8_t;
typedef __int16 int16_t;
typedef __int32 int32_t;
typedef __int64 int64_t;
typedef unsigned long in_addr_t;
#if HAVE_INTTYPES_H
# include <inttypes.h>
#else
#include <limits.h>
#include <inttypes.h>
#include <sys/types.h>
#include <inttypes.h>
#include <unistd.h>
#include <stdlib.h>
#include <time.h>
#endif
# if HAVE_STDINT_H
# include <stdint.h>
# endif
#endif
typedef struct {
uint32_t state[5];
uint32_t count[2];
unsigned char buffer[64];
} sha_context_t;
#define SHA1_HASH_SIZE 20
/* Hash size in 32-bit words */
#define SHA1_HASH_WORDS 5
struct _SHA1Context {
uint64_t totalLength;
uint32_t hash[SHA1_HASH_WORDS];
uint32_t bufferLength;
union {
uint32_t words[16];
uint8_t bytes[64];
} buffer;
#ifdef RUNTIME_ENDIAN
int littleEndian;
#endif /* RUNTIME_ENDIAN */
};
void SHA1Transform(uint32_t state[5], unsigned char buffer[64]);
void SHA1Init(sha_context_t* context);
void SHA1Update(sha_context_t* context, unsigned char* data, uint32_t len);
void SHA1Final(unsigned char digest[20], sha_context_t* context);
typedef struct _SHA1Context SHA1Context;
#ifdef __cplusplus
}
extern "C" {
#endif
void SHA1Init (SHA1Context *sc);
void SHA1Update (SHA1Context *sc, const void *data, uint32_t len);
void SHA1Final (SHA1Context *sc, uint8_t hash[SHA1_HASH_SIZE]);
#ifdef __cplusplus
}
#endif
#endif /* _SHA1_H */
......@@ -1420,15 +1420,11 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
switch_find_local_ip(mod_sofia_globals.guess_ip, sizeof(mod_sofia_globals.guess_ip), AF_INET);
if (switch_event_bind((char *) modname, SWITCH_EVENT_CUSTOM, MULTICAST_EVENT, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
return SWITCH_STATUS_TERM;
}
switch_core_hash_init(&mod_sofia_globals.profile_hash, module_pool);
switch_core_hash_init(&mod_sofia_globals.gateway_hash, module_pool);
switch_mutex_init(&mod_sofia_globals.hash_mutex, SWITCH_MUTEX_NESTED, module_pool);
if (config_sofia(0, NULL) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_GENERR;
}
......@@ -1437,6 +1433,14 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(const switch_loadable_mod
mod_sofia_globals.running = 1;
switch_mutex_unlock(mod_sofia_globals.mutex);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Waiting for profiles to start\n");
switch_yield(1500000);
if (switch_event_bind((char *) modname, SWITCH_EVENT_CUSTOM, MULTICAST_EVENT, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
return SWITCH_STATUS_TERM;
}
if (switch_event_bind((char *) modname, SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_SUBCLASS_ANY, sofia_presence_event_handler, NULL)
!= SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
......
......@@ -176,6 +176,11 @@ static int db_is_up(switch_odbc_handle_t *handle)
char *err_str = NULL;
SQLCHAR sql[] = "select 1";
if (!handle) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "No DB Handle\n");
goto done;
}
if (SQLAllocHandle(SQL_HANDLE_STMT, handle->con, &stmt) != SQL_SUCCESS) {
goto error;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论