X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=apps%2Fsilcd%2Fserverconfig.c;h=cd5a0d3749365fd362d8fefb6d00810fe2395ca9;hb=b3e67d3dfa6409755be33f352b5a86fbb094a570;hp=b5dbc04ce5a90ba6c885c9202719d725d270f96f;hpb=bb8ce8c6460403e9220d9f96eb0e6bd2a20d31f0;p=silc.git diff --git a/apps/silcd/serverconfig.c b/apps/silcd/serverconfig.c index b5dbc04c..cd5a0d37 100644 --- a/apps/silcd/serverconfig.c +++ b/apps/silcd/serverconfig.c @@ -113,18 +113,26 @@ static bool my_parse_authdata(SilcAuthMethod auth_meth, char *p, { if (auth_meth == SILC_AUTH_PASSWORD) { /* p is a plain text password */ - if (auth_data) - *auth_data = (void *) strdup(p); - if (auth_data_len) - *auth_data_len = (SilcUInt32) strlen(p); + if (auth_data && auth_data_len) { + if (!silc_utf8_valid(p, strlen(p))) { + *auth_data_len = silc_utf8_encoded_len(p, strlen(p), 0); + *auth_data = silc_calloc(*auth_data_len, sizeof(unsigned char)); + silc_utf8_encode(p, strlen(p), SILC_STRING_ASCII, *auth_data, + *auth_data_len); + } else { + *auth_data = (void *) strdup(p); + *auth_data_len = (SilcUInt32) strlen(p); + } + } } else if (auth_meth == SILC_AUTH_PUBLIC_KEY) { /* p is a public key file name */ SilcPublicKey public_key; if (!silc_pkcs_load_public_key(p, &public_key, SILC_PKCS_FILE_PEM)) if (!silc_pkcs_load_public_key(p, &public_key, SILC_PKCS_FILE_BIN)) { - SILC_SERVER_LOG_ERROR(("\nError while parsing config file at line %lu: " - "Could not load public key file!\n", line)); + SILC_SERVER_LOG_ERROR(("\nError while parsing config file at line " + "%lu: Could not load public key file!\n", + line)); return FALSE; }