security:choose_mech fix DEAD CODE warning
... by removing the "do {} while (0)" block. Coverity CID 1306669
This commit is contained in:
parent
45bad4ac97
commit
99eafc49bb
@ -480,56 +480,54 @@ static CURLcode choose_mech(struct connectdata *conn)
|
|||||||
void *tmp_allocation;
|
void *tmp_allocation;
|
||||||
const struct Curl_sec_client_mech *mech = &Curl_krb5_client_mech;
|
const struct Curl_sec_client_mech *mech = &Curl_krb5_client_mech;
|
||||||
|
|
||||||
do {
|
tmp_allocation = realloc(conn->app_data, mech->size);
|
||||||
tmp_allocation = realloc(conn->app_data, mech->size);
|
if(tmp_allocation == NULL) {
|
||||||
if(tmp_allocation == NULL) {
|
failf(data, "Failed realloc of size %u", mech->size);
|
||||||
failf(data, "Failed realloc of size %u", mech->size);
|
mech = NULL;
|
||||||
mech = NULL;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
return CURLE_OUT_OF_MEMORY;
|
}
|
||||||
}
|
conn->app_data = tmp_allocation;
|
||||||
conn->app_data = tmp_allocation;
|
|
||||||
|
|
||||||
if(mech->init) {
|
if(mech->init) {
|
||||||
ret = mech->init(conn->app_data);
|
ret = mech->init(conn->app_data);
|
||||||
if(ret) {
|
if(ret) {
|
||||||
infof(data, "Failed initialization for %s. Skipping it.\n",
|
infof(data, "Failed initialization for %s. Skipping it.\n",
|
||||||
mech->name);
|
mech->name);
|
||||||
continue;
|
return CURLE_FAILED_INIT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
infof(data, "Trying mechanism %s...\n", mech->name);
|
||||||
|
ret = ftp_send_command(conn, "AUTH %s", mech->name);
|
||||||
|
if(ret < 0)
|
||||||
|
/* FIXME: This error is too generic but it is OK for now. */
|
||||||
|
return CURLE_COULDNT_CONNECT;
|
||||||
|
|
||||||
|
if(ret/100 != 3) {
|
||||||
|
switch(ret) {
|
||||||
|
case 504:
|
||||||
|
infof(data, "Mechanism %s is not supported by the server (server "
|
||||||
|
"returned ftp code: 504).\n", mech->name);
|
||||||
|
break;
|
||||||
|
case 534:
|
||||||
|
infof(data, "Mechanism %s was rejected by the server (server returned "
|
||||||
|
"ftp code: 534).\n", mech->name);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if(ret/100 == 5) {
|
||||||
|
infof(data, "server does not support the security extensions\n");
|
||||||
|
return CURLE_USE_SSL_FAILED;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
return CURLE_LOGIN_DENIED;
|
||||||
|
}
|
||||||
|
|
||||||
infof(data, "Trying mechanism %s...\n", mech->name);
|
/* Authenticate */
|
||||||
ret = ftp_send_command(conn, "AUTH %s", mech->name);
|
ret = mech->auth(conn->app_data, conn);
|
||||||
if(ret < 0)
|
|
||||||
/* FIXME: This error is too generic but it is OK for now. */
|
|
||||||
return CURLE_COULDNT_CONNECT;
|
|
||||||
|
|
||||||
if(ret/100 != 3) {
|
if(ret != AUTH_CONTINUE) {
|
||||||
switch(ret) {
|
if(ret != AUTH_OK) {
|
||||||
case 504:
|
|
||||||
infof(data, "Mechanism %s is not supported by the server (server "
|
|
||||||
"returned ftp code: 504).\n", mech->name);
|
|
||||||
break;
|
|
||||||
case 534:
|
|
||||||
infof(data, "Mechanism %s was rejected by the server (server returned "
|
|
||||||
"ftp code: 534).\n", mech->name);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
if(ret/100 == 5) {
|
|
||||||
infof(data, "server does not support the security extensions\n");
|
|
||||||
return CURLE_USE_SSL_FAILED;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Authenticate */
|
|
||||||
ret = mech->auth(conn->app_data, conn);
|
|
||||||
|
|
||||||
if(ret == AUTH_CONTINUE)
|
|
||||||
continue;
|
|
||||||
else if(ret != AUTH_OK) {
|
|
||||||
/* Mechanism has dumped the error to stderr, don't error here. */
|
/* Mechanism has dumped the error to stderr, don't error here. */
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -545,8 +543,7 @@ static CURLcode choose_mech(struct connectdata *conn)
|
|||||||
/* Set the requested protection level */
|
/* Set the requested protection level */
|
||||||
/* BLOCKING */
|
/* BLOCKING */
|
||||||
(void)sec_set_protection_level(conn);
|
(void)sec_set_protection_level(conn);
|
||||||
|
}
|
||||||
} WHILE_FALSE;
|
|
||||||
|
|
||||||
return CURLE_OK;
|
return CURLE_OK;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user