Fix speling error...
Log_fatal("out of memory");
memset(ch, 0, sizeof(channel_t));
ch->id = id;
- strncpy(ch->name, name, MAX_TEXT);
- strncpy(ch->desc, desc, MAX_TEXT);
+ ch->name = strdup(name);
+ if (desc)
+ ch->desc = strdup(desc);
init_list_entry(&ch->subs);
init_list_entry(&ch->node);
init_list_entry(&ch->clients);
conf_channel_link_t chlink;
const char *defaultChannelName;
- defaultChannelName = getStrConf(DEAFULT_CHANNEL);
+ defaultChannelName = getStrConf(DEFAULT_CHANNEL);
for (i = 0; ; i++) {
if (Conf_getNextChannel(&chdesc, i) < 0) {
Chan_iterate(&ch_itr);
} while (ch_itr != NULL && strcmp(ch_itr->name, chlink.source) != 0);
if (ch_itr == NULL)
- Log_fatal("Error in channel link configuration: source channel '%s' not found.", chlink.source);
+ Log_fatal("Error in channel link configuration: source channel '%s' not found.",
+ chlink.source);
else
ch_src = ch_itr;
Chan_iterate(&ch_itr);
} while (ch_itr != NULL && strcmp(ch_itr->name, chlink.destination) != 0);
if (ch_itr == NULL)
- Log_fatal("Error in channel link configuration: destination channel '%s' not found", chlink.destination);
+ Log_fatal("Error in channel link configuration: destination channel '%s' not found",
+ chlink.destination);
else
ch_dst = ch_itr;
void Chan_free()
{
struct dlist *itr, *save;
+ channel_t *ch;
list_iterate_safe(itr, save, &channels) {
- Log_debug("Free channel %s", list_get_entry(itr, channel_t, flatlist_node)->name);
- free(list_get_entry(itr, channel_t, flatlist_node));
+ ch = list_get_entry(itr, channel_t, flatlist_node);
+ Log_debug("Free channel %s", ch->name);
+ free(ch->name);
+ if (ch->desc)
+ free(ch->desc);
+ free(ch);
}
}
typedef struct channel {
int id;
- char name[MAX_TEXT];
- char desc[MAX_TEXT];
+ char *name;
+ char *desc;
struct channel *parent;
bool_t temporary, noenter;
struct dlist node;
return DEFAULT_WELCOME;
}
break;
- case DEAFULT_CHANNEL:
+ case DEFAULT_CHANNEL:
setting = config_lookup(&configuration, "default_channel");
if (!setting)
return "";
setting = config_lookup(&configuration, configstr);
if (setting == NULL)
return -1; /* Required */
- strncpy(chdesc->name, config_setting_get_string(setting), MAX_TEXT);
+ chdesc->name = config_setting_get_string(setting);
sprintf(configstr, "channels.[%d].parent", index);
setting = config_lookup(&configuration, configstr);
if (setting == NULL)
return -1; /* Required */
- strncpy(chdesc->parent, config_setting_get_string(setting), MAX_TEXT);
+ chdesc->parent = config_setting_get_string(setting);
sprintf(configstr, "channels.[%d].description", index);
setting = config_lookup(&configuration, configstr);
if (setting == NULL) /* Optional */
- strncpy(chdesc->description, "", MAX_TEXT);
+ chdesc->description = NULL;
else
- strncpy(chdesc->description, config_setting_get_string(setting), MAX_TEXT);
+ chdesc->description = config_setting_get_string(setting);
sprintf(configstr, "channels.[%d].noenter", index);
setting = config_lookup(&configuration, configstr);
setting = config_lookup(&configuration, configstr);
if (setting == NULL)
return -1;
- strncpy(chlink->source, config_setting_get_string(setting), MAX_TEXT);
+ chlink->source = config_setting_get_string(setting);
sprintf(configstr, "channel_links.[%d].destination", index);
setting = config_lookup(&configuration, configstr);
if (setting == NULL)
return -1;
- strncpy(chlink->destination, config_setting_get_string(setting), MAX_TEXT);
+ chlink->destination = config_setting_get_string(setting);
return 0;
}
WELCOMETEXT,
MAX_BANDWIDTH,
MAX_CLIENTS,
- DEAFULT_CHANNEL,
+ DEFAULT_CHANNEL,
} param_t;
typedef struct {
- char parent[MAX_TEXT];
- char name[MAX_TEXT];
- char description[MAX_TEXT];
+ const char *parent;
+ const char *name;
+ const char *description;
bool_t noenter;
} conf_channel_t;
typedef struct {
- char source[MAX_TEXT];
- char destination[MAX_TEXT];
+ const char *source;
+ const char *destination;
} conf_channel_link_t;
int Conf_init(const char *conffile);
#include "list.h"
#include "client.h"
#include "messages.h"
+#include "messagehandler.h"
#include "crypt.h"
#include "channel.h"
#include "conf.h"
#include "voicetarget.h"
+#define MAX_TEXT 512
+
extern channel_t *defaultChan;
extern int iCodecAlpha, iCodecBeta;
extern bool_t bPreferAlpha;
goto disconnect;
}
}
- if (msg->payload.authenticate->password && strncmp(getStrConf(PASSPHRASE), msg->payload.authenticate->password, MAX_TEXT) != 0) {
- char buf[64];
- sprintf(buf, "Wrong server password");
- Log_debug("Wrong server password: %s", msg->payload.authenticate->password);
- sendServerReject(client, buf, MUMBLE_PROTO__REJECT__REJECT_TYPE__WrongServerPW);
- goto disconnect;
+ if (strlen(getStrConf(PASSPHRASE)) > 0) {
+ if (!msg->payload.authenticate->password || strncmp(getStrConf(PASSPHRASE), msg->payload.authenticate->password, MAX_TEXT) != 0) {
+ char buf[64];
+ sprintf(buf, "Wrong server password");
+ sendServerReject(client, buf, MUMBLE_PROTO__REJECT__REJECT_TYPE__WrongServerPW);
+ Log_debug("Wrong server password: %s", msg->payload.authenticate->password);
+ goto disconnect;
+ }
}
if (strlen(msg->payload.authenticate->username) == 0 ||
strlen(msg->payload.authenticate->username) >= MAX_TEXT) { /* XXX - other invalid names? */
sendmsg->payload.channelState->parent = ch_itr->parent->id;
}
sendmsg->payload.channelState->name = strdup(ch_itr->name);
- if (strlen(ch_itr->desc) > 0) {
+ if (ch_itr->desc)
sendmsg->payload.channelState->description = strdup(ch_itr->desc);
- }
Log_debug("Send channel info: %s", sendmsg->payload.channelState->name);
Client_send_message(client, sendmsg);
#define PROTVER_PATCH 0
#define PROTOCOL_VERSION ((PROTVER_MAJOR << 16) | (PROTVER_MINOR << 8) | (PROTVER_PATCH))
-#define MAX_TEXT 512
-
-
#define PERM_NONE 0x0
#define PERM_WRITE 0x1
#define PERM_TRAVERSE 0x2