idx
int64 | func_before
string | Vulnerability Classification
string | vul
int64 | func_after
string | patch
string | CWE ID
string | lines_before
string | lines_after
string |
|---|---|---|---|---|---|---|---|---|
4,000
|
static int get_crl_score(X509_STORE_CTX *ctx, X509 **pissuer,
unsigned int *preasons, X509_CRL *crl, X509 *x)
{
int crl_score = 0;
unsigned int tmp_reasons = *preasons, crl_reasons;
/* First see if we can reject CRL straight away */
/* Invalid IDP cannot be processed */
if (crl->idp_flags & IDP_INVALID)
return 0;
/* Reason codes or indirect CRLs need extended CRL support */
if (!(ctx->param->flags & X509_V_FLAG_EXTENDED_CRL_SUPPORT)) {
if (crl->idp_flags & (IDP_INDIRECT | IDP_REASONS))
return 0;
} else if (crl->idp_flags & IDP_REASONS) {
/* If no new reasons reject */
if (!(crl->idp_reasons & ~tmp_reasons))
return 0;
}
/* Don't process deltas at this stage */
else if (crl->base_crl_number)
return 0;
/* If issuer name doesn't match certificate need indirect CRL */
if (X509_NAME_cmp(X509_get_issuer_name(x), X509_CRL_get_issuer(crl))) {
if (!(crl->idp_flags & IDP_INDIRECT))
return 0;
} else
crl_score |= CRL_SCORE_ISSUER_NAME;
if (!(crl->flags & EXFLAG_CRITICAL))
crl_score |= CRL_SCORE_NOCRITICAL;
/* Check expiry */
if (check_crl_time(ctx, crl, 0))
crl_score |= CRL_SCORE_TIME;
/* Check authority key ID and locate certificate issuer */
crl_akid_check(ctx, crl, pissuer, &crl_score);
/* If we can't locate certificate issuer at this point forget it */
if (!(crl_score & CRL_SCORE_AKID))
return 0;
/* Check cert for matching CRL distribution points */
if (crl_crldp_check(x, crl, crl_score, &crl_reasons)) {
/* If no new reasons reject */
if (!(crl_reasons & ~tmp_reasons))
return 0;
tmp_reasons |= crl_reasons;
crl_score |= CRL_SCORE_SCOPE;
}
*preasons = tmp_reasons;
return crl_score;
}
| null | 0
|
static int get_crl_score(X509_STORE_CTX *ctx, X509 **pissuer,
unsigned int *preasons, X509_CRL *crl, X509 *x)
{
int crl_score = 0;
unsigned int tmp_reasons = *preasons, crl_reasons;
/* First see if we can reject CRL straight away */
/* Invalid IDP cannot be processed */
if (crl->idp_flags & IDP_INVALID)
return 0;
/* Reason codes or indirect CRLs need extended CRL support */
if (!(ctx->param->flags & X509_V_FLAG_EXTENDED_CRL_SUPPORT)) {
if (crl->idp_flags & (IDP_INDIRECT | IDP_REASONS))
return 0;
} else if (crl->idp_flags & IDP_REASONS) {
/* If no new reasons reject */
if (!(crl->idp_reasons & ~tmp_reasons))
return 0;
}
/* Don't process deltas at this stage */
else if (crl->base_crl_number)
return 0;
/* If issuer name doesn't match certificate need indirect CRL */
if (X509_NAME_cmp(X509_get_issuer_name(x), X509_CRL_get_issuer(crl))) {
if (!(crl->idp_flags & IDP_INDIRECT))
return 0;
} else
crl_score |= CRL_SCORE_ISSUER_NAME;
if (!(crl->flags & EXFLAG_CRITICAL))
crl_score |= CRL_SCORE_NOCRITICAL;
/* Check expiry */
if (check_crl_time(ctx, crl, 0))
crl_score |= CRL_SCORE_TIME;
/* Check authority key ID and locate certificate issuer */
crl_akid_check(ctx, crl, pissuer, &crl_score);
/* If we can't locate certificate issuer at this point forget it */
if (!(crl_score & CRL_SCORE_AKID))
return 0;
/* Check cert for matching CRL distribution points */
if (crl_crldp_check(x, crl, crl_score, &crl_reasons)) {
/* If no new reasons reject */
if (!(crl_reasons & ~tmp_reasons))
return 0;
tmp_reasons |= crl_reasons;
crl_score |= CRL_SCORE_SCOPE;
}
*preasons = tmp_reasons;
return crl_score;
}
|
@@ -328,8 +328,8 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
xtmp = sk_X509_pop(ctx->chain);
X509_free(xtmp);
num--;
- ctx->last_untrusted--;
}
+ ctx->last_untrusted = sk_X509_num(ctx->chain);
retry = 1;
break;
}
|
CWE-254
| null | null |
4,001
|
static int get_crl_sk(X509_STORE_CTX *ctx, X509_CRL **pcrl, X509_CRL **pdcrl,
X509 **pissuer, int *pscore, unsigned int *preasons,
STACK_OF(X509_CRL) *crls)
{
int i, crl_score, best_score = *pscore;
unsigned int reasons, best_reasons = 0;
X509 *x = ctx->current_cert;
X509_CRL *crl, *best_crl = NULL;
X509 *crl_issuer = NULL, *best_crl_issuer = NULL;
for (i = 0; i < sk_X509_CRL_num(crls); i++) {
crl = sk_X509_CRL_value(crls, i);
reasons = *preasons;
crl_score = get_crl_score(ctx, &crl_issuer, &reasons, crl, x);
if (crl_score > best_score) {
best_crl = crl;
best_crl_issuer = crl_issuer;
best_score = crl_score;
best_reasons = reasons;
}
}
if (best_crl) {
if (*pcrl)
X509_CRL_free(*pcrl);
*pcrl = best_crl;
*pissuer = best_crl_issuer;
*pscore = best_score;
*preasons = best_reasons;
CRYPTO_add(&best_crl->references, 1, CRYPTO_LOCK_X509_CRL);
if (*pdcrl) {
X509_CRL_free(*pdcrl);
*pdcrl = NULL;
}
get_delta_sk(ctx, pdcrl, pscore, best_crl, crls);
}
if (best_score >= CRL_SCORE_VALID)
return 1;
return 0;
}
| null | 0
|
static int get_crl_sk(X509_STORE_CTX *ctx, X509_CRL **pcrl, X509_CRL **pdcrl,
X509 **pissuer, int *pscore, unsigned int *preasons,
STACK_OF(X509_CRL) *crls)
{
int i, crl_score, best_score = *pscore;
unsigned int reasons, best_reasons = 0;
X509 *x = ctx->current_cert;
X509_CRL *crl, *best_crl = NULL;
X509 *crl_issuer = NULL, *best_crl_issuer = NULL;
for (i = 0; i < sk_X509_CRL_num(crls); i++) {
crl = sk_X509_CRL_value(crls, i);
reasons = *preasons;
crl_score = get_crl_score(ctx, &crl_issuer, &reasons, crl, x);
if (crl_score > best_score) {
best_crl = crl;
best_crl_issuer = crl_issuer;
best_score = crl_score;
best_reasons = reasons;
}
}
if (best_crl) {
if (*pcrl)
X509_CRL_free(*pcrl);
*pcrl = best_crl;
*pissuer = best_crl_issuer;
*pscore = best_score;
*preasons = best_reasons;
CRYPTO_add(&best_crl->references, 1, CRYPTO_LOCK_X509_CRL);
if (*pdcrl) {
X509_CRL_free(*pdcrl);
*pdcrl = NULL;
}
get_delta_sk(ctx, pdcrl, pscore, best_crl, crls);
}
if (best_score >= CRL_SCORE_VALID)
return 1;
return 0;
}
|
@@ -328,8 +328,8 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
xtmp = sk_X509_pop(ctx->chain);
X509_free(xtmp);
num--;
- ctx->last_untrusted--;
}
+ ctx->last_untrusted = sk_X509_num(ctx->chain);
retry = 1;
break;
}
|
CWE-254
| null | null |
4,002
|
static void get_delta_sk(X509_STORE_CTX *ctx, X509_CRL **dcrl, int *pscore,
X509_CRL *base, STACK_OF(X509_CRL) *crls)
{
X509_CRL *delta;
int i;
if (!(ctx->param->flags & X509_V_FLAG_USE_DELTAS))
return;
if (!((ctx->current_cert->ex_flags | base->flags) & EXFLAG_FRESHEST))
return;
for (i = 0; i < sk_X509_CRL_num(crls); i++) {
delta = sk_X509_CRL_value(crls, i);
if (check_delta_base(delta, base)) {
if (check_crl_time(ctx, delta, 0))
*pscore |= CRL_SCORE_TIME_DELTA;
CRYPTO_add(&delta->references, 1, CRYPTO_LOCK_X509_CRL);
*dcrl = delta;
return;
}
}
*dcrl = NULL;
}
| null | 0
|
static void get_delta_sk(X509_STORE_CTX *ctx, X509_CRL **dcrl, int *pscore,
X509_CRL *base, STACK_OF(X509_CRL) *crls)
{
X509_CRL *delta;
int i;
if (!(ctx->param->flags & X509_V_FLAG_USE_DELTAS))
return;
if (!((ctx->current_cert->ex_flags | base->flags) & EXFLAG_FRESHEST))
return;
for (i = 0; i < sk_X509_CRL_num(crls); i++) {
delta = sk_X509_CRL_value(crls, i);
if (check_delta_base(delta, base)) {
if (check_crl_time(ctx, delta, 0))
*pscore |= CRL_SCORE_TIME_DELTA;
CRYPTO_add(&delta->references, 1, CRYPTO_LOCK_X509_CRL);
*dcrl = delta;
return;
}
}
*dcrl = NULL;
}
|
@@ -328,8 +328,8 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
xtmp = sk_X509_pop(ctx->chain);
X509_free(xtmp);
num--;
- ctx->last_untrusted--;
}
+ ctx->last_untrusted = sk_X509_num(ctx->chain);
retry = 1;
break;
}
|
CWE-254
| null | null |
4,003
|
static int get_issuer_sk(X509 **issuer, X509_STORE_CTX *ctx, X509 *x)
{
*issuer = find_issuer(ctx, ctx->other_ctx, x);
if (*issuer) {
CRYPTO_add(&(*issuer)->references, 1, CRYPTO_LOCK_X509);
return 1;
} else
return 0;
}
| null | 0
|
static int get_issuer_sk(X509 **issuer, X509_STORE_CTX *ctx, X509 *x)
{
*issuer = find_issuer(ctx, ctx->other_ctx, x);
if (*issuer) {
CRYPTO_add(&(*issuer)->references, 1, CRYPTO_LOCK_X509);
return 1;
} else
return 0;
}
|
@@ -328,8 +328,8 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
xtmp = sk_X509_pop(ctx->chain);
X509_free(xtmp);
num--;
- ctx->last_untrusted--;
}
+ ctx->last_untrusted = sk_X509_num(ctx->chain);
retry = 1;
break;
}
|
CWE-254
| null | null |
4,004
|
static int idp_check_dp(DIST_POINT_NAME *a, DIST_POINT_NAME *b)
{
X509_NAME *nm = NULL;
GENERAL_NAMES *gens = NULL;
GENERAL_NAME *gena, *genb;
int i, j;
if (!a || !b)
return 1;
if (a->type == 1) {
if (!a->dpname)
return 0;
/* Case 1: two X509_NAME */
if (b->type == 1) {
if (!b->dpname)
return 0;
if (!X509_NAME_cmp(a->dpname, b->dpname))
return 1;
else
return 0;
}
/* Case 2: set name and GENERAL_NAMES appropriately */
nm = a->dpname;
gens = b->name.fullname;
} else if (b->type == 1) {
if (!b->dpname)
return 0;
/* Case 2: set name and GENERAL_NAMES appropriately */
gens = a->name.fullname;
nm = b->dpname;
}
/* Handle case 2 with one GENERAL_NAMES and one X509_NAME */
if (nm) {
for (i = 0; i < sk_GENERAL_NAME_num(gens); i++) {
gena = sk_GENERAL_NAME_value(gens, i);
if (gena->type != GEN_DIRNAME)
continue;
if (!X509_NAME_cmp(nm, gena->d.directoryName))
return 1;
}
return 0;
}
/* Else case 3: two GENERAL_NAMES */
for (i = 0; i < sk_GENERAL_NAME_num(a->name.fullname); i++) {
gena = sk_GENERAL_NAME_value(a->name.fullname, i);
for (j = 0; j < sk_GENERAL_NAME_num(b->name.fullname); j++) {
genb = sk_GENERAL_NAME_value(b->name.fullname, j);
if (!GENERAL_NAME_cmp(gena, genb))
return 1;
}
}
return 0;
}
| null | 0
|
static int idp_check_dp(DIST_POINT_NAME *a, DIST_POINT_NAME *b)
{
X509_NAME *nm = NULL;
GENERAL_NAMES *gens = NULL;
GENERAL_NAME *gena, *genb;
int i, j;
if (!a || !b)
return 1;
if (a->type == 1) {
if (!a->dpname)
return 0;
/* Case 1: two X509_NAME */
if (b->type == 1) {
if (!b->dpname)
return 0;
if (!X509_NAME_cmp(a->dpname, b->dpname))
return 1;
else
return 0;
}
/* Case 2: set name and GENERAL_NAMES appropriately */
nm = a->dpname;
gens = b->name.fullname;
} else if (b->type == 1) {
if (!b->dpname)
return 0;
/* Case 2: set name and GENERAL_NAMES appropriately */
gens = a->name.fullname;
nm = b->dpname;
}
/* Handle case 2 with one GENERAL_NAMES and one X509_NAME */
if (nm) {
for (i = 0; i < sk_GENERAL_NAME_num(gens); i++) {
gena = sk_GENERAL_NAME_value(gens, i);
if (gena->type != GEN_DIRNAME)
continue;
if (!X509_NAME_cmp(nm, gena->d.directoryName))
return 1;
}
return 0;
}
/* Else case 3: two GENERAL_NAMES */
for (i = 0; i < sk_GENERAL_NAME_num(a->name.fullname); i++) {
gena = sk_GENERAL_NAME_value(a->name.fullname, i);
for (j = 0; j < sk_GENERAL_NAME_num(b->name.fullname); j++) {
genb = sk_GENERAL_NAME_value(b->name.fullname, j);
if (!GENERAL_NAME_cmp(gena, genb))
return 1;
}
}
return 0;
}
|
@@ -328,8 +328,8 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
xtmp = sk_X509_pop(ctx->chain);
X509_free(xtmp);
num--;
- ctx->last_untrusted--;
}
+ ctx->last_untrusted = sk_X509_num(ctx->chain);
retry = 1;
break;
}
|
CWE-254
| null | null |
4,005
|
static int internal_verify(X509_STORE_CTX *ctx)
{
int ok = 0, n;
X509 *xs, *xi;
EVP_PKEY *pkey = NULL;
int (*cb) (int xok, X509_STORE_CTX *xctx);
cb = ctx->verify_cb;
n = sk_X509_num(ctx->chain);
ctx->error_depth = n - 1;
n--;
xi = sk_X509_value(ctx->chain, n);
if (ctx->check_issued(ctx, xi, xi))
xs = xi;
else {
if (n <= 0) {
ctx->error = X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE;
ctx->current_cert = xi;
ok = cb(0, ctx);
goto end;
} else {
n--;
ctx->error_depth = n;
xs = sk_X509_value(ctx->chain, n);
}
}
/* ctx->error=0; not needed */
while (n >= 0) {
ctx->error_depth = n;
/*
* Skip signature check for self signed certificates unless
* explicitly asked for. It doesn't add any security and just wastes
* time.
*/
if (!xs->valid
&& (xs != xi
|| (ctx->param->flags & X509_V_FLAG_CHECK_SS_SIGNATURE))) {
if ((pkey = X509_get_pubkey(xi)) == NULL) {
ctx->error = X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY;
ctx->current_cert = xi;
ok = (*cb) (0, ctx);
if (!ok)
goto end;
} else if (X509_verify(xs, pkey) <= 0) {
ctx->error = X509_V_ERR_CERT_SIGNATURE_FAILURE;
ctx->current_cert = xs;
ok = (*cb) (0, ctx);
if (!ok) {
EVP_PKEY_free(pkey);
goto end;
}
}
EVP_PKEY_free(pkey);
pkey = NULL;
}
xs->valid = 1;
ok = check_cert_time(ctx, xs);
if (!ok)
goto end;
/* The last error (if any) is still in the error value */
ctx->current_issuer = xi;
ctx->current_cert = xs;
ok = (*cb) (1, ctx);
if (!ok)
goto end;
n--;
if (n >= 0) {
xi = xs;
xs = sk_X509_value(ctx->chain, n);
}
}
ok = 1;
end:
return ok;
}
| null | 0
|
static int internal_verify(X509_STORE_CTX *ctx)
{
int ok = 0, n;
X509 *xs, *xi;
EVP_PKEY *pkey = NULL;
int (*cb) (int xok, X509_STORE_CTX *xctx);
cb = ctx->verify_cb;
n = sk_X509_num(ctx->chain);
ctx->error_depth = n - 1;
n--;
xi = sk_X509_value(ctx->chain, n);
if (ctx->check_issued(ctx, xi, xi))
xs = xi;
else {
if (n <= 0) {
ctx->error = X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE;
ctx->current_cert = xi;
ok = cb(0, ctx);
goto end;
} else {
n--;
ctx->error_depth = n;
xs = sk_X509_value(ctx->chain, n);
}
}
/* ctx->error=0; not needed */
while (n >= 0) {
ctx->error_depth = n;
/*
* Skip signature check for self signed certificates unless
* explicitly asked for. It doesn't add any security and just wastes
* time.
*/
if (!xs->valid
&& (xs != xi
|| (ctx->param->flags & X509_V_FLAG_CHECK_SS_SIGNATURE))) {
if ((pkey = X509_get_pubkey(xi)) == NULL) {
ctx->error = X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY;
ctx->current_cert = xi;
ok = (*cb) (0, ctx);
if (!ok)
goto end;
} else if (X509_verify(xs, pkey) <= 0) {
ctx->error = X509_V_ERR_CERT_SIGNATURE_FAILURE;
ctx->current_cert = xs;
ok = (*cb) (0, ctx);
if (!ok) {
EVP_PKEY_free(pkey);
goto end;
}
}
EVP_PKEY_free(pkey);
pkey = NULL;
}
xs->valid = 1;
ok = check_cert_time(ctx, xs);
if (!ok)
goto end;
/* The last error (if any) is still in the error value */
ctx->current_issuer = xi;
ctx->current_cert = xs;
ok = (*cb) (1, ctx);
if (!ok)
goto end;
n--;
if (n >= 0) {
xi = xs;
xs = sk_X509_value(ctx->chain, n);
}
}
ok = 1;
end:
return ok;
}
|
@@ -328,8 +328,8 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
xtmp = sk_X509_pop(ctx->chain);
X509_free(xtmp);
num--;
- ctx->last_untrusted--;
}
+ ctx->last_untrusted = sk_X509_num(ctx->chain);
retry = 1;
break;
}
|
CWE-254
| null | null |
4,006
|
static int null_callback(int ok, X509_STORE_CTX *e)
{
return ok;
}
| null | 0
|
static int null_callback(int ok, X509_STORE_CTX *e)
{
return ok;
}
|
@@ -328,8 +328,8 @@ int X509_verify_cert(X509_STORE_CTX *ctx)
xtmp = sk_X509_pop(ctx->chain);
X509_free(xtmp);
num--;
- ctx->last_untrusted--;
}
+ ctx->last_untrusted = sk_X509_num(ctx->chain);
retry = 1;
break;
}
|
CWE-254
| null | null |
4,007
|
int ssl3_accept(SSL *s)
{
BUF_MEM *buf;
unsigned long alg_k, Time = (unsigned long)time(NULL);
void (*cb) (const SSL *ssl, int type, int val) = NULL;
int ret = -1;
int new_state, state, skip = 0;
RAND_add(&Time, sizeof(Time), 0);
ERR_clear_error();
clear_sys_error();
if (s->info_callback != NULL)
cb = s->info_callback;
else if (s->ctx->info_callback != NULL)
cb = s->ctx->info_callback;
/* init things to blank */
s->in_handshake++;
if (!SSL_in_init(s) || SSL_in_before(s))
SSL_clear(s);
if (s->cert == NULL) {
SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_NO_CERTIFICATE_SET);
return (-1);
}
#ifndef OPENSSL_NO_HEARTBEATS
/*
* If we're awaiting a HeartbeatResponse, pretend we already got and
* don't await it anymore, because Heartbeats don't make sense during
* handshakes anyway.
*/
if (s->tlsext_hb_pending) {
s->tlsext_hb_pending = 0;
s->tlsext_hb_seq++;
}
#endif
for (;;) {
state = s->state;
switch (s->state) {
case SSL_ST_RENEGOTIATE:
s->renegotiate = 1;
/* s->state=SSL_ST_ACCEPT; */
case SSL_ST_BEFORE:
case SSL_ST_ACCEPT:
case SSL_ST_BEFORE | SSL_ST_ACCEPT:
case SSL_ST_OK | SSL_ST_ACCEPT:
s->server = 1;
if (cb != NULL)
cb(s, SSL_CB_HANDSHAKE_START, 1);
if ((s->version >> 8) != 3) {
SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR);
return -1;
}
s->type = SSL_ST_ACCEPT;
if (s->init_buf == NULL) {
if ((buf = BUF_MEM_new()) == NULL) {
ret = -1;
goto end;
}
if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) {
BUF_MEM_free(buf);
ret = -1;
goto end;
}
s->init_buf = buf;
}
if (!ssl3_setup_buffers(s)) {
ret = -1;
goto end;
}
s->init_num = 0;
s->s3->flags &= ~TLS1_FLAGS_SKIP_CERT_VERIFY;
s->s3->flags &= ~SSL3_FLAGS_CCS_OK;
/*
* Should have been reset by ssl3_get_finished, too.
*/
s->s3->change_cipher_spec = 0;
if (s->state != SSL_ST_RENEGOTIATE) {
/*
* Ok, we now need to push on a buffering BIO so that the
* output is sent in a way that TCP likes :-)
*/
if (!ssl_init_wbio_buffer(s, 1)) {
ret = -1;
goto end;
}
ssl3_init_finished_mac(s);
s->state = SSL3_ST_SR_CLNT_HELLO_A;
s->ctx->stats.sess_accept++;
} else if (!s->s3->send_connection_binding &&
!(s->options &
SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) {
/*
* Server attempting to renegotiate with client that doesn't
* support secure renegotiation.
*/
SSLerr(SSL_F_SSL3_ACCEPT,
SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED);
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);
ret = -1;
goto end;
} else {
/*
* s->state == SSL_ST_RENEGOTIATE, we will just send a
* HelloRequest
*/
s->ctx->stats.sess_accept_renegotiate++;
s->state = SSL3_ST_SW_HELLO_REQ_A;
}
break;
case SSL3_ST_SW_HELLO_REQ_A:
case SSL3_ST_SW_HELLO_REQ_B:
s->shutdown = 0;
ret = ssl3_send_hello_request(s);
if (ret <= 0)
goto end;
s->s3->tmp.next_state = SSL3_ST_SW_HELLO_REQ_C;
s->state = SSL3_ST_SW_FLUSH;
s->init_num = 0;
ssl3_init_finished_mac(s);
break;
case SSL3_ST_SW_HELLO_REQ_C:
s->state = SSL_ST_OK;
break;
case SSL3_ST_SR_CLNT_HELLO_A:
case SSL3_ST_SR_CLNT_HELLO_B:
case SSL3_ST_SR_CLNT_HELLO_C:
s->shutdown = 0;
ret = ssl3_get_client_hello(s);
if (ret <= 0)
goto end;
#ifndef OPENSSL_NO_SRP
s->state = SSL3_ST_SR_CLNT_HELLO_D;
case SSL3_ST_SR_CLNT_HELLO_D:
{
int al;
if ((ret = ssl_check_srp_ext_ClientHello(s, &al)) < 0) {
/*
* callback indicates firther work to be done
*/
s->rwstate = SSL_X509_LOOKUP;
goto end;
}
if (ret != SSL_ERROR_NONE) {
ssl3_send_alert(s, SSL3_AL_FATAL, al);
/*
* This is not really an error but the only means to for
* a client to detect whether srp is supported.
*/
if (al != TLS1_AD_UNKNOWN_PSK_IDENTITY)
SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_CLIENTHELLO_TLSEXT);
ret = SSL_TLSEXT_ERR_ALERT_FATAL;
ret = -1;
goto end;
}
}
#endif
s->renegotiate = 2;
s->state = SSL3_ST_SW_SRVR_HELLO_A;
s->init_num = 0;
break;
case SSL3_ST_SW_SRVR_HELLO_A:
case SSL3_ST_SW_SRVR_HELLO_B:
ret = ssl3_send_server_hello(s);
if (ret <= 0)
goto end;
#ifndef OPENSSL_NO_TLSEXT
if (s->hit) {
if (s->tlsext_ticket_expected)
s->state = SSL3_ST_SW_SESSION_TICKET_A;
else
s->state = SSL3_ST_SW_CHANGE_A;
}
#else
if (s->hit)
s->state = SSL3_ST_SW_CHANGE_A;
#endif
else
s->state = SSL3_ST_SW_CERT_A;
s->init_num = 0;
break;
case SSL3_ST_SW_CERT_A:
case SSL3_ST_SW_CERT_B:
/* Check if it is anon DH or anon ECDH, */
/* normal PSK or KRB5 or SRP */
if (!
(s->s3->tmp.
new_cipher->algorithm_auth & (SSL_aNULL | SSL_aKRB5 |
SSL_aSRP))
&& !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) {
ret = ssl3_send_server_certificate(s);
if (ret <= 0)
goto end;
#ifndef OPENSSL_NO_TLSEXT
if (s->tlsext_status_expected)
s->state = SSL3_ST_SW_CERT_STATUS_A;
else
s->state = SSL3_ST_SW_KEY_EXCH_A;
} else {
skip = 1;
s->state = SSL3_ST_SW_KEY_EXCH_A;
}
#else
} else
skip = 1;
s->state = SSL3_ST_SW_KEY_EXCH_A;
#endif
s->init_num = 0;
break;
case SSL3_ST_SW_KEY_EXCH_A:
case SSL3_ST_SW_KEY_EXCH_B:
alg_k = s->s3->tmp.new_cipher->algorithm_mkey;
/*
* clear this, it may get reset by
* send_server_key_exchange
*/
s->s3->tmp.use_rsa_tmp = 0;
/*
* only send if a DH key exchange, fortezza or RSA but we have a
* sign only certificate PSK: may send PSK identity hints For
* ECC ciphersuites, we send a serverKeyExchange message only if
* the cipher suite is either ECDH-anon or ECDHE. In other cases,
* the server certificate contains the server's public key for
* key exchange.
*/
if (0
/*
* PSK: send ServerKeyExchange if PSK identity hint if
* provided
*/
#ifndef OPENSSL_NO_PSK
|| ((alg_k & SSL_kPSK) && s->ctx->psk_identity_hint)
#endif
#ifndef OPENSSL_NO_SRP
/* SRP: send ServerKeyExchange */
|| (alg_k & SSL_kSRP)
#endif
|| (alg_k & SSL_kEDH)
|| (alg_k & SSL_kEECDH)
|| ((alg_k & SSL_kRSA)
&& (s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL
|| (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher)
&& EVP_PKEY_size(s->cert->pkeys
[SSL_PKEY_RSA_ENC].privatekey) *
8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)
)
)
)
) {
ret = ssl3_send_server_key_exchange(s);
if (ret <= 0)
goto end;
} else
skip = 1;
s->state = SSL3_ST_SW_CERT_REQ_A;
s->init_num = 0;
break;
case SSL3_ST_SW_CERT_REQ_A:
case SSL3_ST_SW_CERT_REQ_B:
if ( /* don't request cert unless asked for it: */
!(s->verify_mode & SSL_VERIFY_PEER) ||
/*
* if SSL_VERIFY_CLIENT_ONCE is set, don't request cert
* during re-negotiation:
*/
((s->session->peer != NULL) &&
(s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) ||
/*
* never request cert in anonymous ciphersuites (see
* section "Certificate request" in SSL 3 drafts and in
* RFC 2246):
*/
((s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) &&
/*
* ... except when the application insists on
* verification (against the specs, but s3_clnt.c accepts
* this for SSL 3)
*/
!(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) ||
/*
* never request cert in Kerberos ciphersuites
*/
(s->s3->tmp.new_cipher->algorithm_auth & SSL_aKRB5) ||
/* don't request certificate for SRP auth */
(s->s3->tmp.new_cipher->algorithm_auth & SSL_aSRP)
/*
* With normal PSK Certificates and Certificate Requests
* are omitted
*/
|| (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) {
/* no cert request */
skip = 1;
s->s3->tmp.cert_request = 0;
s->state = SSL3_ST_SW_SRVR_DONE_A;
if (s->s3->handshake_buffer)
if (!ssl3_digest_cached_records(s))
return -1;
} else {
s->s3->tmp.cert_request = 1;
ret = ssl3_send_certificate_request(s);
if (ret <= 0)
goto end;
#ifndef NETSCAPE_HANG_BUG
s->state = SSL3_ST_SW_SRVR_DONE_A;
#else
s->state = SSL3_ST_SW_FLUSH;
s->s3->tmp.next_state = SSL3_ST_SR_CERT_A;
#endif
s->init_num = 0;
}
break;
case SSL3_ST_SW_SRVR_DONE_A:
case SSL3_ST_SW_SRVR_DONE_B:
ret = ssl3_send_server_done(s);
if (ret <= 0)
goto end;
s->s3->tmp.next_state = SSL3_ST_SR_CERT_A;
s->state = SSL3_ST_SW_FLUSH;
s->init_num = 0;
break;
case SSL3_ST_SW_FLUSH:
/*
* This code originally checked to see if any data was pending
* using BIO_CTRL_INFO and then flushed. This caused problems as
* documented in PR#1939. The proposed fix doesn't completely
* resolve this issue as buggy implementations of
* BIO_CTRL_PENDING still exist. So instead we just flush
* unconditionally.
*/
s->rwstate = SSL_WRITING;
if (BIO_flush(s->wbio) <= 0) {
ret = -1;
goto end;
}
s->rwstate = SSL_NOTHING;
s->state = s->s3->tmp.next_state;
break;
case SSL3_ST_SR_CERT_A:
case SSL3_ST_SR_CERT_B:
if (s->s3->tmp.cert_request) {
ret = ssl3_get_client_certificate(s);
if (ret <= 0)
goto end;
}
s->init_num = 0;
s->state = SSL3_ST_SR_KEY_EXCH_A;
break;
case SSL3_ST_SR_KEY_EXCH_A:
case SSL3_ST_SR_KEY_EXCH_B:
ret = ssl3_get_client_key_exchange(s);
if (ret <= 0)
goto end;
if (ret == 2) {
/*
* For the ECDH ciphersuites when the client sends its ECDH
* pub key in a certificate, the CertificateVerify message is
* not sent. Also for GOST ciphersuites when the client uses
* its key from the certificate for key exchange.
*/
#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG)
s->state = SSL3_ST_SR_FINISHED_A;
#else
if (s->s3->next_proto_neg_seen)
s->state = SSL3_ST_SR_NEXT_PROTO_A;
else
s->state = SSL3_ST_SR_FINISHED_A;
#endif
s->init_num = 0;
} else if (SSL_USE_SIGALGS(s)) {
s->state = SSL3_ST_SR_CERT_VRFY_A;
s->init_num = 0;
if (!s->session->peer)
break;
/*
* For sigalgs freeze the handshake buffer at this point and
* digest cached records.
*/
if (!s->s3->handshake_buffer) {
SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR);
return -1;
}
s->s3->flags |= TLS1_FLAGS_KEEP_HANDSHAKE;
if (!ssl3_digest_cached_records(s))
return -1;
} else {
int offset = 0;
int dgst_num;
s->state = SSL3_ST_SR_CERT_VRFY_A;
s->init_num = 0;
/*
* We need to get hashes here so if there is a client cert,
* it can be verified FIXME - digest processing for
* CertificateVerify should be generalized. But it is next
* step
*/
if (s->s3->handshake_buffer)
if (!ssl3_digest_cached_records(s))
return -1;
for (dgst_num = 0; dgst_num < SSL_MAX_DIGEST; dgst_num++)
if (s->s3->handshake_dgst[dgst_num]) {
int dgst_size;
s->method->ssl3_enc->cert_verify_mac(s,
EVP_MD_CTX_type
(s->
s3->handshake_dgst
[dgst_num]),
&(s->s3->
tmp.cert_verify_md
[offset]));
dgst_size =
EVP_MD_CTX_size(s->s3->handshake_dgst[dgst_num]);
if (dgst_size < 0) {
ret = -1;
goto end;
}
offset += dgst_size;
}
}
break;
case SSL3_ST_SR_CERT_VRFY_A:
case SSL3_ST_SR_CERT_VRFY_B:
/*
* This *should* be the first time we enable CCS, but be
* extra careful about surrounding code changes. We need
* to set this here because we don't know if we're
* expecting a CertificateVerify or not.
*/
if (!s->s3->change_cipher_spec)
s->s3->flags |= SSL3_FLAGS_CCS_OK;
/* we should decide if we expected this one */
ret = ssl3_get_cert_verify(s);
if (ret <= 0)
goto end;
#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG)
s->state = SSL3_ST_SR_FINISHED_A;
#else
if (s->s3->next_proto_neg_seen)
s->state = SSL3_ST_SR_NEXT_PROTO_A;
else
s->state = SSL3_ST_SR_FINISHED_A;
#endif
s->init_num = 0;
break;
#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
case SSL3_ST_SR_NEXT_PROTO_A:
case SSL3_ST_SR_NEXT_PROTO_B:
/*
* Enable CCS for resumed handshakes with NPN.
* In a full handshake with NPN, we end up here through
* SSL3_ST_SR_CERT_VRFY_B, where SSL3_FLAGS_CCS_OK was
* already set. Receiving a CCS clears the flag, so make
* sure not to re-enable it to ban duplicates.
* s->s3->change_cipher_spec is set when a CCS is
* processed in s3_pkt.c, and remains set until
* the client's Finished message is read.
*/
if (!s->s3->change_cipher_spec)
s->s3->flags |= SSL3_FLAGS_CCS_OK;
ret = ssl3_get_next_proto(s);
if (ret <= 0)
goto end;
s->init_num = 0;
s->state = SSL3_ST_SR_FINISHED_A;
break;
#endif
case SSL3_ST_SR_FINISHED_A:
case SSL3_ST_SR_FINISHED_B:
/*
* Enable CCS for resumed handshakes without NPN.
* In a full handshake, we end up here through
* SSL3_ST_SR_CERT_VRFY_B, where SSL3_FLAGS_CCS_OK was
* already set. Receiving a CCS clears the flag, so make
* sure not to re-enable it to ban duplicates.
* s->s3->change_cipher_spec is set when a CCS is
* processed in s3_pkt.c, and remains set until
* the client's Finished message is read.
*/
if (!s->s3->change_cipher_spec)
s->s3->flags |= SSL3_FLAGS_CCS_OK;
ret = ssl3_get_finished(s, SSL3_ST_SR_FINISHED_A,
SSL3_ST_SR_FINISHED_B);
if (ret <= 0)
goto end;
if (s->hit)
s->state = SSL_ST_OK;
#ifndef OPENSSL_NO_TLSEXT
else if (s->tlsext_ticket_expected)
s->state = SSL3_ST_SW_SESSION_TICKET_A;
#endif
else
s->state = SSL3_ST_SW_CHANGE_A;
s->init_num = 0;
break;
#ifndef OPENSSL_NO_TLSEXT
case SSL3_ST_SW_SESSION_TICKET_A:
case SSL3_ST_SW_SESSION_TICKET_B:
ret = ssl3_send_newsession_ticket(s);
if (ret <= 0)
goto end;
s->state = SSL3_ST_SW_CHANGE_A;
s->init_num = 0;
break;
case SSL3_ST_SW_CERT_STATUS_A:
case SSL3_ST_SW_CERT_STATUS_B:
ret = ssl3_send_cert_status(s);
if (ret <= 0)
goto end;
s->state = SSL3_ST_SW_KEY_EXCH_A;
s->init_num = 0;
break;
#endif
case SSL3_ST_SW_CHANGE_A:
case SSL3_ST_SW_CHANGE_B:
s->session->cipher = s->s3->tmp.new_cipher;
if (!s->method->ssl3_enc->setup_key_block(s)) {
ret = -1;
goto end;
}
ret = ssl3_send_change_cipher_spec(s,
SSL3_ST_SW_CHANGE_A,
SSL3_ST_SW_CHANGE_B);
if (ret <= 0)
goto end;
s->state = SSL3_ST_SW_FINISHED_A;
s->init_num = 0;
if (!s->method->ssl3_enc->change_cipher_state(s,
SSL3_CHANGE_CIPHER_SERVER_WRITE))
{
ret = -1;
goto end;
}
break;
case SSL3_ST_SW_FINISHED_A:
case SSL3_ST_SW_FINISHED_B:
ret = ssl3_send_finished(s,
SSL3_ST_SW_FINISHED_A,
SSL3_ST_SW_FINISHED_B,
s->method->
ssl3_enc->server_finished_label,
s->method->
ssl3_enc->server_finished_label_len);
if (ret <= 0)
goto end;
s->state = SSL3_ST_SW_FLUSH;
if (s->hit) {
#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG)
s->s3->tmp.next_state = SSL3_ST_SR_FINISHED_A;
#else
if (s->s3->next_proto_neg_seen) {
s->s3->tmp.next_state = SSL3_ST_SR_NEXT_PROTO_A;
} else
s->s3->tmp.next_state = SSL3_ST_SR_FINISHED_A;
#endif
} else
s->s3->tmp.next_state = SSL_ST_OK;
s->init_num = 0;
break;
case SSL_ST_OK:
/* clean a few things up */
ssl3_cleanup_key_block(s);
BUF_MEM_free(s->init_buf);
s->init_buf = NULL;
/* remove buffering on output */
ssl_free_wbio_buffer(s);
s->init_num = 0;
if (s->renegotiate == 2) { /* skipped if we just sent a
* HelloRequest */
s->renegotiate = 0;
s->new_session = 0;
ssl_update_cache(s, SSL_SESS_CACHE_SERVER);
s->ctx->stats.sess_accept_good++;
/* s->server=1; */
s->handshake_func = ssl3_accept;
if (cb != NULL)
cb(s, SSL_CB_HANDSHAKE_DONE, 1);
}
ret = 1;
goto end;
/* break; */
default:
SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_UNKNOWN_STATE);
ret = -1;
goto end;
/* break; */
}
if (!s->s3->tmp.reuse_message && !skip) {
if (s->debug) {
if ((ret = BIO_flush(s->wbio)) <= 0)
goto end;
}
if ((cb != NULL) && (s->state != state)) {
new_state = s->state;
s->state = state;
cb(s, SSL_CB_ACCEPT_LOOP, 1);
s->state = new_state;
}
}
skip = 0;
}
|
DoS
| 0
|
int ssl3_accept(SSL *s)
{
BUF_MEM *buf;
unsigned long alg_k, Time = (unsigned long)time(NULL);
void (*cb) (const SSL *ssl, int type, int val) = NULL;
int ret = -1;
int new_state, state, skip = 0;
RAND_add(&Time, sizeof(Time), 0);
ERR_clear_error();
clear_sys_error();
if (s->info_callback != NULL)
cb = s->info_callback;
else if (s->ctx->info_callback != NULL)
cb = s->ctx->info_callback;
/* init things to blank */
s->in_handshake++;
if (!SSL_in_init(s) || SSL_in_before(s))
SSL_clear(s);
if (s->cert == NULL) {
SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_NO_CERTIFICATE_SET);
return (-1);
}
#ifndef OPENSSL_NO_HEARTBEATS
/*
* If we're awaiting a HeartbeatResponse, pretend we already got and
* don't await it anymore, because Heartbeats don't make sense during
* handshakes anyway.
*/
if (s->tlsext_hb_pending) {
s->tlsext_hb_pending = 0;
s->tlsext_hb_seq++;
}
#endif
for (;;) {
state = s->state;
switch (s->state) {
case SSL_ST_RENEGOTIATE:
s->renegotiate = 1;
/* s->state=SSL_ST_ACCEPT; */
case SSL_ST_BEFORE:
case SSL_ST_ACCEPT:
case SSL_ST_BEFORE | SSL_ST_ACCEPT:
case SSL_ST_OK | SSL_ST_ACCEPT:
s->server = 1;
if (cb != NULL)
cb(s, SSL_CB_HANDSHAKE_START, 1);
if ((s->version >> 8) != 3) {
SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR);
return -1;
}
s->type = SSL_ST_ACCEPT;
if (s->init_buf == NULL) {
if ((buf = BUF_MEM_new()) == NULL) {
ret = -1;
goto end;
}
if (!BUF_MEM_grow(buf, SSL3_RT_MAX_PLAIN_LENGTH)) {
BUF_MEM_free(buf);
ret = -1;
goto end;
}
s->init_buf = buf;
}
if (!ssl3_setup_buffers(s)) {
ret = -1;
goto end;
}
s->init_num = 0;
s->s3->flags &= ~TLS1_FLAGS_SKIP_CERT_VERIFY;
s->s3->flags &= ~SSL3_FLAGS_CCS_OK;
/*
* Should have been reset by ssl3_get_finished, too.
*/
s->s3->change_cipher_spec = 0;
if (s->state != SSL_ST_RENEGOTIATE) {
/*
* Ok, we now need to push on a buffering BIO so that the
* output is sent in a way that TCP likes :-)
*/
if (!ssl_init_wbio_buffer(s, 1)) {
ret = -1;
goto end;
}
ssl3_init_finished_mac(s);
s->state = SSL3_ST_SR_CLNT_HELLO_A;
s->ctx->stats.sess_accept++;
} else if (!s->s3->send_connection_binding &&
!(s->options &
SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION)) {
/*
* Server attempting to renegotiate with client that doesn't
* support secure renegotiation.
*/
SSLerr(SSL_F_SSL3_ACCEPT,
SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED);
ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_HANDSHAKE_FAILURE);
ret = -1;
goto end;
} else {
/*
* s->state == SSL_ST_RENEGOTIATE, we will just send a
* HelloRequest
*/
s->ctx->stats.sess_accept_renegotiate++;
s->state = SSL3_ST_SW_HELLO_REQ_A;
}
break;
case SSL3_ST_SW_HELLO_REQ_A:
case SSL3_ST_SW_HELLO_REQ_B:
s->shutdown = 0;
ret = ssl3_send_hello_request(s);
if (ret <= 0)
goto end;
s->s3->tmp.next_state = SSL3_ST_SW_HELLO_REQ_C;
s->state = SSL3_ST_SW_FLUSH;
s->init_num = 0;
ssl3_init_finished_mac(s);
break;
case SSL3_ST_SW_HELLO_REQ_C:
s->state = SSL_ST_OK;
break;
case SSL3_ST_SR_CLNT_HELLO_A:
case SSL3_ST_SR_CLNT_HELLO_B:
case SSL3_ST_SR_CLNT_HELLO_C:
s->shutdown = 0;
ret = ssl3_get_client_hello(s);
if (ret <= 0)
goto end;
#ifndef OPENSSL_NO_SRP
s->state = SSL3_ST_SR_CLNT_HELLO_D;
case SSL3_ST_SR_CLNT_HELLO_D:
{
int al;
if ((ret = ssl_check_srp_ext_ClientHello(s, &al)) < 0) {
/*
* callback indicates firther work to be done
*/
s->rwstate = SSL_X509_LOOKUP;
goto end;
}
if (ret != SSL_ERROR_NONE) {
ssl3_send_alert(s, SSL3_AL_FATAL, al);
/*
* This is not really an error but the only means to for
* a client to detect whether srp is supported.
*/
if (al != TLS1_AD_UNKNOWN_PSK_IDENTITY)
SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_CLIENTHELLO_TLSEXT);
ret = SSL_TLSEXT_ERR_ALERT_FATAL;
ret = -1;
goto end;
}
}
#endif
s->renegotiate = 2;
s->state = SSL3_ST_SW_SRVR_HELLO_A;
s->init_num = 0;
break;
case SSL3_ST_SW_SRVR_HELLO_A:
case SSL3_ST_SW_SRVR_HELLO_B:
ret = ssl3_send_server_hello(s);
if (ret <= 0)
goto end;
#ifndef OPENSSL_NO_TLSEXT
if (s->hit) {
if (s->tlsext_ticket_expected)
s->state = SSL3_ST_SW_SESSION_TICKET_A;
else
s->state = SSL3_ST_SW_CHANGE_A;
}
#else
if (s->hit)
s->state = SSL3_ST_SW_CHANGE_A;
#endif
else
s->state = SSL3_ST_SW_CERT_A;
s->init_num = 0;
break;
case SSL3_ST_SW_CERT_A:
case SSL3_ST_SW_CERT_B:
/* Check if it is anon DH or anon ECDH, */
/* normal PSK or KRB5 or SRP */
if (!
(s->s3->tmp.
new_cipher->algorithm_auth & (SSL_aNULL | SSL_aKRB5 |
SSL_aSRP))
&& !(s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) {
ret = ssl3_send_server_certificate(s);
if (ret <= 0)
goto end;
#ifndef OPENSSL_NO_TLSEXT
if (s->tlsext_status_expected)
s->state = SSL3_ST_SW_CERT_STATUS_A;
else
s->state = SSL3_ST_SW_KEY_EXCH_A;
} else {
skip = 1;
s->state = SSL3_ST_SW_KEY_EXCH_A;
}
#else
} else
skip = 1;
s->state = SSL3_ST_SW_KEY_EXCH_A;
#endif
s->init_num = 0;
break;
case SSL3_ST_SW_KEY_EXCH_A:
case SSL3_ST_SW_KEY_EXCH_B:
alg_k = s->s3->tmp.new_cipher->algorithm_mkey;
/*
* clear this, it may get reset by
* send_server_key_exchange
*/
s->s3->tmp.use_rsa_tmp = 0;
/*
* only send if a DH key exchange, fortezza or RSA but we have a
* sign only certificate PSK: may send PSK identity hints For
* ECC ciphersuites, we send a serverKeyExchange message only if
* the cipher suite is either ECDH-anon or ECDHE. In other cases,
* the server certificate contains the server's public key for
* key exchange.
*/
if (0
/*
* PSK: send ServerKeyExchange if PSK identity hint if
* provided
*/
#ifndef OPENSSL_NO_PSK
|| ((alg_k & SSL_kPSK) && s->ctx->psk_identity_hint)
#endif
#ifndef OPENSSL_NO_SRP
/* SRP: send ServerKeyExchange */
|| (alg_k & SSL_kSRP)
#endif
|| (alg_k & SSL_kEDH)
|| (alg_k & SSL_kEECDH)
|| ((alg_k & SSL_kRSA)
&& (s->cert->pkeys[SSL_PKEY_RSA_ENC].privatekey == NULL
|| (SSL_C_IS_EXPORT(s->s3->tmp.new_cipher)
&& EVP_PKEY_size(s->cert->pkeys
[SSL_PKEY_RSA_ENC].privatekey) *
8 > SSL_C_EXPORT_PKEYLENGTH(s->s3->tmp.new_cipher)
)
)
)
) {
ret = ssl3_send_server_key_exchange(s);
if (ret <= 0)
goto end;
} else
skip = 1;
s->state = SSL3_ST_SW_CERT_REQ_A;
s->init_num = 0;
break;
case SSL3_ST_SW_CERT_REQ_A:
case SSL3_ST_SW_CERT_REQ_B:
if ( /* don't request cert unless asked for it: */
!(s->verify_mode & SSL_VERIFY_PEER) ||
/*
* if SSL_VERIFY_CLIENT_ONCE is set, don't request cert
* during re-negotiation:
*/
((s->session->peer != NULL) &&
(s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) ||
/*
* never request cert in anonymous ciphersuites (see
* section "Certificate request" in SSL 3 drafts and in
* RFC 2246):
*/
((s->s3->tmp.new_cipher->algorithm_auth & SSL_aNULL) &&
/*
* ... except when the application insists on
* verification (against the specs, but s3_clnt.c accepts
* this for SSL 3)
*/
!(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) ||
/*
* never request cert in Kerberos ciphersuites
*/
(s->s3->tmp.new_cipher->algorithm_auth & SSL_aKRB5) ||
/* don't request certificate for SRP auth */
(s->s3->tmp.new_cipher->algorithm_auth & SSL_aSRP)
/*
* With normal PSK Certificates and Certificate Requests
* are omitted
*/
|| (s->s3->tmp.new_cipher->algorithm_mkey & SSL_kPSK)) {
/* no cert request */
skip = 1;
s->s3->tmp.cert_request = 0;
s->state = SSL3_ST_SW_SRVR_DONE_A;
if (s->s3->handshake_buffer)
if (!ssl3_digest_cached_records(s))
return -1;
} else {
s->s3->tmp.cert_request = 1;
ret = ssl3_send_certificate_request(s);
if (ret <= 0)
goto end;
#ifndef NETSCAPE_HANG_BUG
s->state = SSL3_ST_SW_SRVR_DONE_A;
#else
s->state = SSL3_ST_SW_FLUSH;
s->s3->tmp.next_state = SSL3_ST_SR_CERT_A;
#endif
s->init_num = 0;
}
break;
case SSL3_ST_SW_SRVR_DONE_A:
case SSL3_ST_SW_SRVR_DONE_B:
ret = ssl3_send_server_done(s);
if (ret <= 0)
goto end;
s->s3->tmp.next_state = SSL3_ST_SR_CERT_A;
s->state = SSL3_ST_SW_FLUSH;
s->init_num = 0;
break;
case SSL3_ST_SW_FLUSH:
/*
* This code originally checked to see if any data was pending
* using BIO_CTRL_INFO and then flushed. This caused problems as
* documented in PR#1939. The proposed fix doesn't completely
* resolve this issue as buggy implementations of
* BIO_CTRL_PENDING still exist. So instead we just flush
* unconditionally.
*/
s->rwstate = SSL_WRITING;
if (BIO_flush(s->wbio) <= 0) {
ret = -1;
goto end;
}
s->rwstate = SSL_NOTHING;
s->state = s->s3->tmp.next_state;
break;
case SSL3_ST_SR_CERT_A:
case SSL3_ST_SR_CERT_B:
if (s->s3->tmp.cert_request) {
ret = ssl3_get_client_certificate(s);
if (ret <= 0)
goto end;
}
s->init_num = 0;
s->state = SSL3_ST_SR_KEY_EXCH_A;
break;
case SSL3_ST_SR_KEY_EXCH_A:
case SSL3_ST_SR_KEY_EXCH_B:
ret = ssl3_get_client_key_exchange(s);
if (ret <= 0)
goto end;
if (ret == 2) {
/*
* For the ECDH ciphersuites when the client sends its ECDH
* pub key in a certificate, the CertificateVerify message is
* not sent. Also for GOST ciphersuites when the client uses
* its key from the certificate for key exchange.
*/
#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG)
s->state = SSL3_ST_SR_FINISHED_A;
#else
if (s->s3->next_proto_neg_seen)
s->state = SSL3_ST_SR_NEXT_PROTO_A;
else
s->state = SSL3_ST_SR_FINISHED_A;
#endif
s->init_num = 0;
} else if (SSL_USE_SIGALGS(s)) {
s->state = SSL3_ST_SR_CERT_VRFY_A;
s->init_num = 0;
if (!s->session->peer)
break;
/*
* For sigalgs freeze the handshake buffer at this point and
* digest cached records.
*/
if (!s->s3->handshake_buffer) {
SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR);
return -1;
}
s->s3->flags |= TLS1_FLAGS_KEEP_HANDSHAKE;
if (!ssl3_digest_cached_records(s))
return -1;
} else {
int offset = 0;
int dgst_num;
s->state = SSL3_ST_SR_CERT_VRFY_A;
s->init_num = 0;
/*
* We need to get hashes here so if there is a client cert,
* it can be verified FIXME - digest processing for
* CertificateVerify should be generalized. But it is next
* step
*/
if (s->s3->handshake_buffer)
if (!ssl3_digest_cached_records(s))
return -1;
for (dgst_num = 0; dgst_num < SSL_MAX_DIGEST; dgst_num++)
if (s->s3->handshake_dgst[dgst_num]) {
int dgst_size;
s->method->ssl3_enc->cert_verify_mac(s,
EVP_MD_CTX_type
(s->
s3->handshake_dgst
[dgst_num]),
&(s->s3->
tmp.cert_verify_md
[offset]));
dgst_size =
EVP_MD_CTX_size(s->s3->handshake_dgst[dgst_num]);
if (dgst_size < 0) {
ret = -1;
goto end;
}
offset += dgst_size;
}
}
break;
case SSL3_ST_SR_CERT_VRFY_A:
case SSL3_ST_SR_CERT_VRFY_B:
/*
* This *should* be the first time we enable CCS, but be
* extra careful about surrounding code changes. We need
* to set this here because we don't know if we're
* expecting a CertificateVerify or not.
*/
if (!s->s3->change_cipher_spec)
s->s3->flags |= SSL3_FLAGS_CCS_OK;
/* we should decide if we expected this one */
ret = ssl3_get_cert_verify(s);
if (ret <= 0)
goto end;
#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG)
s->state = SSL3_ST_SR_FINISHED_A;
#else
if (s->s3->next_proto_neg_seen)
s->state = SSL3_ST_SR_NEXT_PROTO_A;
else
s->state = SSL3_ST_SR_FINISHED_A;
#endif
s->init_num = 0;
break;
#if !defined(OPENSSL_NO_TLSEXT) && !defined(OPENSSL_NO_NEXTPROTONEG)
case SSL3_ST_SR_NEXT_PROTO_A:
case SSL3_ST_SR_NEXT_PROTO_B:
/*
* Enable CCS for resumed handshakes with NPN.
* In a full handshake with NPN, we end up here through
* SSL3_ST_SR_CERT_VRFY_B, where SSL3_FLAGS_CCS_OK was
* already set. Receiving a CCS clears the flag, so make
* sure not to re-enable it to ban duplicates.
* s->s3->change_cipher_spec is set when a CCS is
* processed in s3_pkt.c, and remains set until
* the client's Finished message is read.
*/
if (!s->s3->change_cipher_spec)
s->s3->flags |= SSL3_FLAGS_CCS_OK;
ret = ssl3_get_next_proto(s);
if (ret <= 0)
goto end;
s->init_num = 0;
s->state = SSL3_ST_SR_FINISHED_A;
break;
#endif
case SSL3_ST_SR_FINISHED_A:
case SSL3_ST_SR_FINISHED_B:
/*
* Enable CCS for resumed handshakes without NPN.
* In a full handshake, we end up here through
* SSL3_ST_SR_CERT_VRFY_B, where SSL3_FLAGS_CCS_OK was
* already set. Receiving a CCS clears the flag, so make
* sure not to re-enable it to ban duplicates.
* s->s3->change_cipher_spec is set when a CCS is
* processed in s3_pkt.c, and remains set until
* the client's Finished message is read.
*/
if (!s->s3->change_cipher_spec)
s->s3->flags |= SSL3_FLAGS_CCS_OK;
ret = ssl3_get_finished(s, SSL3_ST_SR_FINISHED_A,
SSL3_ST_SR_FINISHED_B);
if (ret <= 0)
goto end;
if (s->hit)
s->state = SSL_ST_OK;
#ifndef OPENSSL_NO_TLSEXT
else if (s->tlsext_ticket_expected)
s->state = SSL3_ST_SW_SESSION_TICKET_A;
#endif
else
s->state = SSL3_ST_SW_CHANGE_A;
s->init_num = 0;
break;
#ifndef OPENSSL_NO_TLSEXT
case SSL3_ST_SW_SESSION_TICKET_A:
case SSL3_ST_SW_SESSION_TICKET_B:
ret = ssl3_send_newsession_ticket(s);
if (ret <= 0)
goto end;
s->state = SSL3_ST_SW_CHANGE_A;
s->init_num = 0;
break;
case SSL3_ST_SW_CERT_STATUS_A:
case SSL3_ST_SW_CERT_STATUS_B:
ret = ssl3_send_cert_status(s);
if (ret <= 0)
goto end;
s->state = SSL3_ST_SW_KEY_EXCH_A;
s->init_num = 0;
break;
#endif
case SSL3_ST_SW_CHANGE_A:
case SSL3_ST_SW_CHANGE_B:
s->session->cipher = s->s3->tmp.new_cipher;
if (!s->method->ssl3_enc->setup_key_block(s)) {
ret = -1;
goto end;
}
ret = ssl3_send_change_cipher_spec(s,
SSL3_ST_SW_CHANGE_A,
SSL3_ST_SW_CHANGE_B);
if (ret <= 0)
goto end;
s->state = SSL3_ST_SW_FINISHED_A;
s->init_num = 0;
if (!s->method->ssl3_enc->change_cipher_state(s,
SSL3_CHANGE_CIPHER_SERVER_WRITE))
{
ret = -1;
goto end;
}
break;
case SSL3_ST_SW_FINISHED_A:
case SSL3_ST_SW_FINISHED_B:
ret = ssl3_send_finished(s,
SSL3_ST_SW_FINISHED_A,
SSL3_ST_SW_FINISHED_B,
s->method->
ssl3_enc->server_finished_label,
s->method->
ssl3_enc->server_finished_label_len);
if (ret <= 0)
goto end;
s->state = SSL3_ST_SW_FLUSH;
if (s->hit) {
#if defined(OPENSSL_NO_TLSEXT) || defined(OPENSSL_NO_NEXTPROTONEG)
s->s3->tmp.next_state = SSL3_ST_SR_FINISHED_A;
#else
if (s->s3->next_proto_neg_seen) {
s->s3->tmp.next_state = SSL3_ST_SR_NEXT_PROTO_A;
} else
s->s3->tmp.next_state = SSL3_ST_SR_FINISHED_A;
#endif
} else
s->s3->tmp.next_state = SSL_ST_OK;
s->init_num = 0;
break;
case SSL_ST_OK:
/* clean a few things up */
ssl3_cleanup_key_block(s);
BUF_MEM_free(s->init_buf);
s->init_buf = NULL;
/* remove buffering on output */
ssl_free_wbio_buffer(s);
s->init_num = 0;
if (s->renegotiate == 2) { /* skipped if we just sent a
* HelloRequest */
s->renegotiate = 0;
s->new_session = 0;
ssl_update_cache(s, SSL_SESS_CACHE_SERVER);
s->ctx->stats.sess_accept_good++;
/* s->server=1; */
s->handshake_func = ssl3_accept;
if (cb != NULL)
cb(s, SSL_CB_HANDSHAKE_DONE, 1);
}
ret = 1;
goto end;
/* break; */
default:
SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_UNKNOWN_STATE);
ret = -1;
goto end;
/* break; */
}
if (!s->s3->tmp.reuse_message && !skip) {
if (s->debug) {
if ((ret = BIO_flush(s->wbio)) <= 0)
goto end;
}
if ((cb != NULL) && (s->state != state)) {
new_state = s->state;
s->state = state;
cb(s, SSL_CB_ACCEPT_LOOP, 1);
s->state = new_state;
}
}
skip = 0;
}
|
@@ -2251,10 +2251,17 @@ int ssl3_get_client_key_exchange(SSL *s)
if (alg_k & (SSL_kEDH | SSL_kDHr | SSL_kDHd)) {
int idx = -1;
EVP_PKEY *skey = NULL;
- if (n)
+ if (n > 1) {
n2s(p, i);
- else
+ } else {
+ if (alg_k & SSL_kDHE) {
+ al = SSL_AD_HANDSHAKE_FAILURE;
+ SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,
+ SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG);
+ goto f_err;
+ }
i = 0;
+ }
if (n && n != i + 2) {
if (!(s->options & SSL_OP_SSLEAY_080_CLIENT_DH_BUG)) {
SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,
|
CWE-20
| null | null |
4,008
|
int ssl3_get_client_certificate(SSL *s)
{
int i, ok, al, ret = -1;
X509 *x = NULL;
unsigned long l, nc, llen, n;
const unsigned char *p, *q;
unsigned char *d;
STACK_OF(X509) *sk = NULL;
n = s->method->ssl_get_message(s,
SSL3_ST_SR_CERT_A,
SSL3_ST_SR_CERT_B,
-1, s->max_cert_list, &ok);
if (!ok)
return ((int)n);
if (s->s3->tmp.message_type == SSL3_MT_CLIENT_KEY_EXCHANGE) {
if ((s->verify_mode & SSL_VERIFY_PEER) &&
(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) {
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,
SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE);
al = SSL_AD_HANDSHAKE_FAILURE;
goto f_err;
}
/*
* If tls asked for a client cert, the client must return a 0 list
*/
if ((s->version > SSL3_VERSION) && s->s3->tmp.cert_request) {
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,
SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST);
al = SSL_AD_UNEXPECTED_MESSAGE;
goto f_err;
}
s->s3->tmp.reuse_message = 1;
return (1);
}
if (s->s3->tmp.message_type != SSL3_MT_CERTIFICATE) {
al = SSL_AD_UNEXPECTED_MESSAGE;
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, SSL_R_WRONG_MESSAGE_TYPE);
goto f_err;
}
p = d = (unsigned char *)s->init_msg;
if ((sk = sk_X509_new_null()) == NULL) {
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, ERR_R_MALLOC_FAILURE);
goto err;
}
n2l3(p, llen);
if (llen + 3 != n) {
al = SSL_AD_DECODE_ERROR;
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, SSL_R_LENGTH_MISMATCH);
goto f_err;
}
for (nc = 0; nc < llen;) {
n2l3(p, l);
if ((l + nc + 3) > llen) {
al = SSL_AD_DECODE_ERROR;
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,
SSL_R_CERT_LENGTH_MISMATCH);
goto f_err;
}
q = p;
x = d2i_X509(NULL, &p, l);
if (x == NULL) {
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, ERR_R_ASN1_LIB);
goto err;
}
if (p != (q + l)) {
al = SSL_AD_DECODE_ERROR;
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,
SSL_R_CERT_LENGTH_MISMATCH);
goto f_err;
}
if (!sk_X509_push(sk, x)) {
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, ERR_R_MALLOC_FAILURE);
goto err;
}
x = NULL;
nc += l + 3;
}
if (sk_X509_num(sk) <= 0) {
/* TLS does not mind 0 certs returned */
if (s->version == SSL3_VERSION) {
al = SSL_AD_HANDSHAKE_FAILURE;
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,
SSL_R_NO_CERTIFICATES_RETURNED);
goto f_err;
}
/* Fail for TLS only if we required a certificate */
else if ((s->verify_mode & SSL_VERIFY_PEER) &&
(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) {
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,
SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE);
al = SSL_AD_HANDSHAKE_FAILURE;
goto f_err;
}
/* No client certificate so digest cached records */
if (s->s3->handshake_buffer && !ssl3_digest_cached_records(s)) {
al = SSL_AD_INTERNAL_ERROR;
goto f_err;
}
} else {
i = ssl_verify_cert_chain(s, sk);
if (i <= 0) {
al = ssl_verify_alarm_type(s->verify_result);
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,
SSL_R_CERTIFICATE_VERIFY_FAILED);
goto f_err;
}
}
if (s->session->peer != NULL) /* This should not be needed */
X509_free(s->session->peer);
s->session->peer = sk_X509_shift(sk);
s->session->verify_result = s->verify_result;
/*
* With the current implementation, sess_cert will always be NULL when we
* arrive here.
*/
if (s->session->sess_cert == NULL) {
s->session->sess_cert = ssl_sess_cert_new();
if (s->session->sess_cert == NULL) {
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, ERR_R_MALLOC_FAILURE);
goto err;
}
}
if (s->session->sess_cert->cert_chain != NULL)
sk_X509_pop_free(s->session->sess_cert->cert_chain, X509_free);
s->session->sess_cert->cert_chain = sk;
/*
* Inconsistency alert: cert_chain does *not* include the peer's own
* certificate, while we do include it in s3_clnt.c
*/
sk = NULL;
ret = 1;
if (0) {
f_err:
ssl3_send_alert(s, SSL3_AL_FATAL, al);
}
err:
if (x != NULL)
X509_free(x);
if (sk != NULL)
sk_X509_pop_free(sk, X509_free);
return (ret);
}
|
DoS
| 0
|
int ssl3_get_client_certificate(SSL *s)
{
int i, ok, al, ret = -1;
X509 *x = NULL;
unsigned long l, nc, llen, n;
const unsigned char *p, *q;
unsigned char *d;
STACK_OF(X509) *sk = NULL;
n = s->method->ssl_get_message(s,
SSL3_ST_SR_CERT_A,
SSL3_ST_SR_CERT_B,
-1, s->max_cert_list, &ok);
if (!ok)
return ((int)n);
if (s->s3->tmp.message_type == SSL3_MT_CLIENT_KEY_EXCHANGE) {
if ((s->verify_mode & SSL_VERIFY_PEER) &&
(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) {
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,
SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE);
al = SSL_AD_HANDSHAKE_FAILURE;
goto f_err;
}
/*
* If tls asked for a client cert, the client must return a 0 list
*/
if ((s->version > SSL3_VERSION) && s->s3->tmp.cert_request) {
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,
SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST);
al = SSL_AD_UNEXPECTED_MESSAGE;
goto f_err;
}
s->s3->tmp.reuse_message = 1;
return (1);
}
if (s->s3->tmp.message_type != SSL3_MT_CERTIFICATE) {
al = SSL_AD_UNEXPECTED_MESSAGE;
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, SSL_R_WRONG_MESSAGE_TYPE);
goto f_err;
}
p = d = (unsigned char *)s->init_msg;
if ((sk = sk_X509_new_null()) == NULL) {
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, ERR_R_MALLOC_FAILURE);
goto err;
}
n2l3(p, llen);
if (llen + 3 != n) {
al = SSL_AD_DECODE_ERROR;
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, SSL_R_LENGTH_MISMATCH);
goto f_err;
}
for (nc = 0; nc < llen;) {
n2l3(p, l);
if ((l + nc + 3) > llen) {
al = SSL_AD_DECODE_ERROR;
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,
SSL_R_CERT_LENGTH_MISMATCH);
goto f_err;
}
q = p;
x = d2i_X509(NULL, &p, l);
if (x == NULL) {
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, ERR_R_ASN1_LIB);
goto err;
}
if (p != (q + l)) {
al = SSL_AD_DECODE_ERROR;
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,
SSL_R_CERT_LENGTH_MISMATCH);
goto f_err;
}
if (!sk_X509_push(sk, x)) {
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, ERR_R_MALLOC_FAILURE);
goto err;
}
x = NULL;
nc += l + 3;
}
if (sk_X509_num(sk) <= 0) {
/* TLS does not mind 0 certs returned */
if (s->version == SSL3_VERSION) {
al = SSL_AD_HANDSHAKE_FAILURE;
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,
SSL_R_NO_CERTIFICATES_RETURNED);
goto f_err;
}
/* Fail for TLS only if we required a certificate */
else if ((s->verify_mode & SSL_VERIFY_PEER) &&
(s->verify_mode & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)) {
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,
SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE);
al = SSL_AD_HANDSHAKE_FAILURE;
goto f_err;
}
/* No client certificate so digest cached records */
if (s->s3->handshake_buffer && !ssl3_digest_cached_records(s)) {
al = SSL_AD_INTERNAL_ERROR;
goto f_err;
}
} else {
i = ssl_verify_cert_chain(s, sk);
if (i <= 0) {
al = ssl_verify_alarm_type(s->verify_result);
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE,
SSL_R_CERTIFICATE_VERIFY_FAILED);
goto f_err;
}
}
if (s->session->peer != NULL) /* This should not be needed */
X509_free(s->session->peer);
s->session->peer = sk_X509_shift(sk);
s->session->verify_result = s->verify_result;
/*
* With the current implementation, sess_cert will always be NULL when we
* arrive here.
*/
if (s->session->sess_cert == NULL) {
s->session->sess_cert = ssl_sess_cert_new();
if (s->session->sess_cert == NULL) {
SSLerr(SSL_F_SSL3_GET_CLIENT_CERTIFICATE, ERR_R_MALLOC_FAILURE);
goto err;
}
}
if (s->session->sess_cert->cert_chain != NULL)
sk_X509_pop_free(s->session->sess_cert->cert_chain, X509_free);
s->session->sess_cert->cert_chain = sk;
/*
* Inconsistency alert: cert_chain does *not* include the peer's own
* certificate, while we do include it in s3_clnt.c
*/
sk = NULL;
ret = 1;
if (0) {
f_err:
ssl3_send_alert(s, SSL3_AL_FATAL, al);
}
err:
if (x != NULL)
X509_free(x);
if (sk != NULL)
sk_X509_pop_free(sk, X509_free);
return (ret);
}
|
@@ -2251,10 +2251,17 @@ int ssl3_get_client_key_exchange(SSL *s)
if (alg_k & (SSL_kEDH | SSL_kDHr | SSL_kDHd)) {
int idx = -1;
EVP_PKEY *skey = NULL;
- if (n)
+ if (n > 1) {
n2s(p, i);
- else
+ } else {
+ if (alg_k & SSL_kDHE) {
+ al = SSL_AD_HANDSHAKE_FAILURE;
+ SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,
+ SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG);
+ goto f_err;
+ }
i = 0;
+ }
if (n && n != i + 2) {
if (!(s->options & SSL_OP_SSLEAY_080_CLIENT_DH_BUG)) {
SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,
|
CWE-20
| null | null |
4,009
|
int ssl3_get_client_hello(SSL *s)
{
int i, j, ok, al = SSL_AD_INTERNAL_ERROR, ret = -1;
unsigned int cookie_len;
long n;
unsigned long id;
unsigned char *p, *d;
SSL_CIPHER *c;
#ifndef OPENSSL_NO_COMP
unsigned char *q;
SSL_COMP *comp = NULL;
#endif
STACK_OF(SSL_CIPHER) *ciphers = NULL;
if (s->state == SSL3_ST_SR_CLNT_HELLO_C && !s->first_packet)
goto retry_cert;
/*
* We do this so that we will respond with our native type. If we are
* TLSv1 and we get SSLv3, we will respond with TLSv1, This down
* switching should be handled by a different method. If we are SSLv3, we
* will respond with SSLv3, even if prompted with TLSv1.
*/
if (s->state == SSL3_ST_SR_CLNT_HELLO_A) {
s->state = SSL3_ST_SR_CLNT_HELLO_B;
}
s->first_packet = 1;
n = s->method->ssl_get_message(s,
SSL3_ST_SR_CLNT_HELLO_B,
SSL3_ST_SR_CLNT_HELLO_C,
SSL3_MT_CLIENT_HELLO,
SSL3_RT_MAX_PLAIN_LENGTH, &ok);
if (!ok)
return ((int)n);
s->first_packet = 0;
d = p = (unsigned char *)s->init_msg;
/*
* use version from inside client hello, not from record header (may
* differ: see RFC 2246, Appendix E, second paragraph)
*/
s->client_version = (((int)p[0]) << 8) | (int)p[1];
p += 2;
if (SSL_IS_DTLS(s) ? (s->client_version > s->version &&
s->method->version != DTLS_ANY_VERSION)
: (s->client_version < s->version)) {
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_WRONG_VERSION_NUMBER);
if ((s->client_version >> 8) == SSL3_VERSION_MAJOR &&
!s->enc_write_ctx && !s->write_hash) {
/*
* similar to ssl3_get_record, send alert using remote version
* number
*/
s->version = s->client_version;
}
al = SSL_AD_PROTOCOL_VERSION;
goto f_err;
}
/*
* If we require cookies and this ClientHello doesn't contain one, just
* return since we do not want to allocate any memory yet. So check
* cookie length...
*/
if (SSL_get_options(s) & SSL_OP_COOKIE_EXCHANGE) {
unsigned int session_length, cookie_length;
session_length = *(p + SSL3_RANDOM_SIZE);
cookie_length = *(p + SSL3_RANDOM_SIZE + session_length + 1);
if (cookie_length == 0)
return 1;
}
/* load the client random */
memcpy(s->s3->client_random, p, SSL3_RANDOM_SIZE);
p += SSL3_RANDOM_SIZE;
/* get the session-id */
j = *(p++);
s->hit = 0;
/*
* Versions before 0.9.7 always allow clients to resume sessions in
* renegotiation. 0.9.7 and later allow this by default, but optionally
* ignore resumption requests with flag
* SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION (it's a new flag rather
* than a change to default behavior so that applications relying on this
* for security won't even compile against older library versions).
* 1.0.1 and later also have a function SSL_renegotiate_abbreviated() to
* request renegotiation but not a new session (s->new_session remains
* unset): for servers, this essentially just means that the
* SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION setting will be ignored.
*/
if ((s->new_session
&& (s->options & SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION))) {
if (!ssl_get_new_session(s, 1))
goto err;
} else {
i = ssl_get_prev_session(s, p, j, d + n);
/*
* Only resume if the session's version matches the negotiated
* version.
* RFC 5246 does not provide much useful advice on resumption
* with a different protocol version. It doesn't forbid it but
* the sanity of such behaviour would be questionable.
* In practice, clients do not accept a version mismatch and
* will abort the handshake with an error.
*/
if (i == 1 && s->version == s->session->ssl_version) { /* previous
* session */
s->hit = 1;
} else if (i == -1)
goto err;
else { /* i == 0 */
if (!ssl_get_new_session(s, 1))
goto err;
}
}
p += j;
if (SSL_IS_DTLS(s)) {
/* cookie stuff */
cookie_len = *(p++);
/*
* The ClientHello may contain a cookie even if the
* HelloVerify message has not been sent--make sure that it
* does not cause an overflow.
*/
if (cookie_len > sizeof(s->d1->rcvd_cookie)) {
/* too much data */
al = SSL_AD_DECODE_ERROR;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_COOKIE_MISMATCH);
goto f_err;
}
/* verify the cookie if appropriate option is set. */
if ((SSL_get_options(s) & SSL_OP_COOKIE_EXCHANGE) && cookie_len > 0) {
memcpy(s->d1->rcvd_cookie, p, cookie_len);
if (s->ctx->app_verify_cookie_cb != NULL) {
if (s->ctx->app_verify_cookie_cb(s, s->d1->rcvd_cookie,
cookie_len) == 0) {
al = SSL_AD_HANDSHAKE_FAILURE;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,
SSL_R_COOKIE_MISMATCH);
goto f_err;
}
/* else cookie verification succeeded */
}
/* default verification */
else if (memcmp(s->d1->rcvd_cookie, s->d1->cookie,
s->d1->cookie_len) != 0) {
al = SSL_AD_HANDSHAKE_FAILURE;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_COOKIE_MISMATCH);
goto f_err;
}
/* Set to -2 so if successful we return 2 */
ret = -2;
}
p += cookie_len;
if (s->method->version == DTLS_ANY_VERSION) {
/* Select version to use */
if (s->client_version <= DTLS1_2_VERSION &&
!(s->options & SSL_OP_NO_DTLSv1_2)) {
s->version = DTLS1_2_VERSION;
s->method = DTLSv1_2_server_method();
} else if (tls1_suiteb(s)) {
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,
SSL_R_ONLY_DTLS_1_2_ALLOWED_IN_SUITEB_MODE);
s->version = s->client_version;
al = SSL_AD_PROTOCOL_VERSION;
goto f_err;
} else if (s->client_version <= DTLS1_VERSION &&
!(s->options & SSL_OP_NO_DTLSv1)) {
s->version = DTLS1_VERSION;
s->method = DTLSv1_server_method();
} else {
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,
SSL_R_WRONG_VERSION_NUMBER);
s->version = s->client_version;
al = SSL_AD_PROTOCOL_VERSION;
goto f_err;
}
s->session->ssl_version = s->version;
}
}
n2s(p, i);
if ((i == 0) && (j != 0)) {
/* we need a cipher if we are not resuming a session */
al = SSL_AD_ILLEGAL_PARAMETER;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_NO_CIPHERS_SPECIFIED);
goto f_err;
}
if ((p + i) >= (d + n)) {
/* not enough data */
al = SSL_AD_DECODE_ERROR;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_MISMATCH);
goto f_err;
}
if ((i > 0) && (ssl_bytes_to_cipher_list(s, p, i, &(ciphers))
== NULL)) {
goto err;
}
p += i;
/* If it is a hit, check that the cipher is in the list */
if ((s->hit) && (i > 0)) {
j = 0;
id = s->session->cipher->id;
#ifdef CIPHER_DEBUG
fprintf(stderr, "client sent %d ciphers\n",
sk_SSL_CIPHER_num(ciphers));
#endif
for (i = 0; i < sk_SSL_CIPHER_num(ciphers); i++) {
c = sk_SSL_CIPHER_value(ciphers, i);
#ifdef CIPHER_DEBUG
fprintf(stderr, "client [%2d of %2d]:%s\n",
i, sk_SSL_CIPHER_num(ciphers), SSL_CIPHER_get_name(c));
#endif
if (c->id == id) {
j = 1;
break;
}
}
/*
* Disabled because it can be used in a ciphersuite downgrade attack:
* CVE-2010-4180.
*/
#if 0
if (j == 0 && (s->options & SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG)
&& (sk_SSL_CIPHER_num(ciphers) == 1)) {
/*
* Special case as client bug workaround: the previously used
* cipher may not be in the current list, the client instead
* might be trying to continue using a cipher that before wasn't
* chosen due to server preferences. We'll have to reject the
* connection if the cipher is not enabled, though.
*/
c = sk_SSL_CIPHER_value(ciphers, 0);
if (sk_SSL_CIPHER_find(SSL_get_ciphers(s), c) >= 0) {
s->session->cipher = c;
j = 1;
}
}
#endif
if (j == 0) {
/*
* we need to have the cipher in the cipher list if we are asked
* to reuse it
*/
al = SSL_AD_ILLEGAL_PARAMETER;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,
SSL_R_REQUIRED_CIPHER_MISSING);
goto f_err;
}
}
/* compression */
i = *(p++);
if ((p + i) > (d + n)) {
/* not enough data */
al = SSL_AD_DECODE_ERROR;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_MISMATCH);
goto f_err;
}
#ifndef OPENSSL_NO_COMP
q = p;
#endif
for (j = 0; j < i; j++) {
if (p[j] == 0)
break;
}
p += i;
if (j >= i) {
/* no compress */
al = SSL_AD_DECODE_ERROR;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_NO_COMPRESSION_SPECIFIED);
goto f_err;
}
#ifndef OPENSSL_NO_TLSEXT
/* TLS extensions */
if (s->version >= SSL3_VERSION) {
if (!ssl_parse_clienthello_tlsext(s, &p, d, n)) {
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_PARSE_TLSEXT);
goto err;
}
}
/*
* Check if we want to use external pre-shared secret for this handshake
* for not reused session only. We need to generate server_random before
* calling tls_session_secret_cb in order to allow SessionTicket
* processing to use it in key derivation.
*/
{
unsigned char *pos;
pos = s->s3->server_random;
if (ssl_fill_hello_random(s, 1, pos, SSL3_RANDOM_SIZE) <= 0) {
goto f_err;
}
}
if (!s->hit && s->version >= TLS1_VERSION && s->tls_session_secret_cb) {
SSL_CIPHER *pref_cipher = NULL;
s->session->master_key_length = sizeof(s->session->master_key);
if (s->tls_session_secret_cb(s, s->session->master_key,
&s->session->master_key_length, ciphers,
&pref_cipher,
s->tls_session_secret_cb_arg)) {
s->hit = 1;
s->session->ciphers = ciphers;
s->session->verify_result = X509_V_OK;
ciphers = NULL;
/* check if some cipher was preferred by call back */
pref_cipher =
pref_cipher ? pref_cipher : ssl3_choose_cipher(s,
s->
session->ciphers,
SSL_get_ciphers
(s));
if (pref_cipher == NULL) {
al = SSL_AD_HANDSHAKE_FAILURE;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_NO_SHARED_CIPHER);
goto f_err;
}
s->session->cipher = pref_cipher;
if (s->cipher_list)
sk_SSL_CIPHER_free(s->cipher_list);
if (s->cipher_list_by_id)
sk_SSL_CIPHER_free(s->cipher_list_by_id);
s->cipher_list = sk_SSL_CIPHER_dup(s->session->ciphers);
s->cipher_list_by_id = sk_SSL_CIPHER_dup(s->session->ciphers);
}
}
#endif
/*
* Worst case, we will use the NULL compression, but if we have other
* options, we will now look for them. We have i-1 compression
* algorithms from the client, starting at q.
*/
s->s3->tmp.new_compression = NULL;
#ifndef OPENSSL_NO_COMP
/* This only happens if we have a cache hit */
if (s->session->compress_meth != 0) {
int m, comp_id = s->session->compress_meth;
/* Perform sanity checks on resumed compression algorithm */
/* Can't disable compression */
if (s->options & SSL_OP_NO_COMPRESSION) {
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,
SSL_R_INCONSISTENT_COMPRESSION);
goto f_err;
}
/* Look for resumed compression method */
for (m = 0; m < sk_SSL_COMP_num(s->ctx->comp_methods); m++) {
comp = sk_SSL_COMP_value(s->ctx->comp_methods, m);
if (comp_id == comp->id) {
s->s3->tmp.new_compression = comp;
break;
}
}
if (s->s3->tmp.new_compression == NULL) {
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,
SSL_R_INVALID_COMPRESSION_ALGORITHM);
goto f_err;
}
/* Look for resumed method in compression list */
for (m = 0; m < i; m++) {
if (q[m] == comp_id)
break;
}
if (m >= i) {
al = SSL_AD_ILLEGAL_PARAMETER;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,
SSL_R_REQUIRED_COMPRESSSION_ALGORITHM_MISSING);
goto f_err;
}
} else if (s->hit)
comp = NULL;
else if (!(s->options & SSL_OP_NO_COMPRESSION) && s->ctx->comp_methods) {
/* See if we have a match */
int m, nn, o, v, done = 0;
nn = sk_SSL_COMP_num(s->ctx->comp_methods);
for (m = 0; m < nn; m++) {
comp = sk_SSL_COMP_value(s->ctx->comp_methods, m);
v = comp->id;
for (o = 0; o < i; o++) {
if (v == q[o]) {
done = 1;
break;
}
}
if (done)
break;
}
if (done)
s->s3->tmp.new_compression = comp;
else
comp = NULL;
}
#else
/*
* If compression is disabled we'd better not try to resume a session
* using compression.
*/
if (s->session->compress_meth != 0) {
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_INCONSISTENT_COMPRESSION);
goto f_err;
}
#endif
/*
* Given s->session->ciphers and SSL_get_ciphers, we must pick a cipher
*/
if (!s->hit) {
#ifdef OPENSSL_NO_COMP
s->session->compress_meth = 0;
#else
s->session->compress_meth = (comp == NULL) ? 0 : comp->id;
#endif
if (s->session->ciphers != NULL)
sk_SSL_CIPHER_free(s->session->ciphers);
s->session->ciphers = ciphers;
if (ciphers == NULL) {
al = SSL_AD_ILLEGAL_PARAMETER;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_NO_CIPHERS_PASSED);
goto f_err;
}
ciphers = NULL;
if (!tls1_set_server_sigalgs(s)) {
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_CLIENTHELLO_TLSEXT);
goto err;
}
/* Let cert callback update server certificates if required */
retry_cert:
if (s->cert->cert_cb) {
int rv = s->cert->cert_cb(s, s->cert->cert_cb_arg);
if (rv == 0) {
al = SSL_AD_INTERNAL_ERROR;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_CERT_CB_ERROR);
goto f_err;
}
if (rv < 0) {
s->rwstate = SSL_X509_LOOKUP;
return -1;
}
s->rwstate = SSL_NOTHING;
}
c = ssl3_choose_cipher(s, s->session->ciphers, SSL_get_ciphers(s));
if (c == NULL) {
al = SSL_AD_HANDSHAKE_FAILURE;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_NO_SHARED_CIPHER);
goto f_err;
}
s->s3->tmp.new_cipher = c;
} else {
/* Session-id reuse */
#ifdef REUSE_CIPHER_BUG
STACK_OF(SSL_CIPHER) *sk;
SSL_CIPHER *nc = NULL;
SSL_CIPHER *ec = NULL;
if (s->options & SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG) {
sk = s->session->ciphers;
for (i = 0; i < sk_SSL_CIPHER_num(sk); i++) {
c = sk_SSL_CIPHER_value(sk, i);
if (c->algorithm_enc & SSL_eNULL)
nc = c;
if (SSL_C_IS_EXPORT(c))
ec = c;
}
if (nc != NULL)
s->s3->tmp.new_cipher = nc;
else if (ec != NULL)
s->s3->tmp.new_cipher = ec;
else
s->s3->tmp.new_cipher = s->session->cipher;
} else
#endif
s->s3->tmp.new_cipher = s->session->cipher;
}
if (!SSL_USE_SIGALGS(s) || !(s->verify_mode & SSL_VERIFY_PEER)) {
if (!ssl3_digest_cached_records(s))
goto f_err;
}
/*-
* we now have the following setup.
* client_random
* cipher_list - our prefered list of ciphers
* ciphers - the clients prefered list of ciphers
* compression - basically ignored right now
* ssl version is set - sslv3
* s->session - The ssl session has been setup.
* s->hit - session reuse flag
* s->tmp.new_cipher - the new cipher to use.
*/
/* Handles TLS extensions that we couldn't check earlier */
if (s->version >= SSL3_VERSION) {
if (ssl_check_clienthello_tlsext_late(s) <= 0) {
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_CLIENTHELLO_TLSEXT);
goto err;
}
}
if (ret < 0)
ret = -ret;
if (0) {
f_err:
ssl3_send_alert(s, SSL3_AL_FATAL, al);
}
err:
if (ciphers != NULL)
sk_SSL_CIPHER_free(ciphers);
return ret < 0 ? -1 : ret;
}
|
DoS
| 0
|
int ssl3_get_client_hello(SSL *s)
{
int i, j, ok, al = SSL_AD_INTERNAL_ERROR, ret = -1;
unsigned int cookie_len;
long n;
unsigned long id;
unsigned char *p, *d;
SSL_CIPHER *c;
#ifndef OPENSSL_NO_COMP
unsigned char *q;
SSL_COMP *comp = NULL;
#endif
STACK_OF(SSL_CIPHER) *ciphers = NULL;
if (s->state == SSL3_ST_SR_CLNT_HELLO_C && !s->first_packet)
goto retry_cert;
/*
* We do this so that we will respond with our native type. If we are
* TLSv1 and we get SSLv3, we will respond with TLSv1, This down
* switching should be handled by a different method. If we are SSLv3, we
* will respond with SSLv3, even if prompted with TLSv1.
*/
if (s->state == SSL3_ST_SR_CLNT_HELLO_A) {
s->state = SSL3_ST_SR_CLNT_HELLO_B;
}
s->first_packet = 1;
n = s->method->ssl_get_message(s,
SSL3_ST_SR_CLNT_HELLO_B,
SSL3_ST_SR_CLNT_HELLO_C,
SSL3_MT_CLIENT_HELLO,
SSL3_RT_MAX_PLAIN_LENGTH, &ok);
if (!ok)
return ((int)n);
s->first_packet = 0;
d = p = (unsigned char *)s->init_msg;
/*
* use version from inside client hello, not from record header (may
* differ: see RFC 2246, Appendix E, second paragraph)
*/
s->client_version = (((int)p[0]) << 8) | (int)p[1];
p += 2;
if (SSL_IS_DTLS(s) ? (s->client_version > s->version &&
s->method->version != DTLS_ANY_VERSION)
: (s->client_version < s->version)) {
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_WRONG_VERSION_NUMBER);
if ((s->client_version >> 8) == SSL3_VERSION_MAJOR &&
!s->enc_write_ctx && !s->write_hash) {
/*
* similar to ssl3_get_record, send alert using remote version
* number
*/
s->version = s->client_version;
}
al = SSL_AD_PROTOCOL_VERSION;
goto f_err;
}
/*
* If we require cookies and this ClientHello doesn't contain one, just
* return since we do not want to allocate any memory yet. So check
* cookie length...
*/
if (SSL_get_options(s) & SSL_OP_COOKIE_EXCHANGE) {
unsigned int session_length, cookie_length;
session_length = *(p + SSL3_RANDOM_SIZE);
cookie_length = *(p + SSL3_RANDOM_SIZE + session_length + 1);
if (cookie_length == 0)
return 1;
}
/* load the client random */
memcpy(s->s3->client_random, p, SSL3_RANDOM_SIZE);
p += SSL3_RANDOM_SIZE;
/* get the session-id */
j = *(p++);
s->hit = 0;
/*
* Versions before 0.9.7 always allow clients to resume sessions in
* renegotiation. 0.9.7 and later allow this by default, but optionally
* ignore resumption requests with flag
* SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION (it's a new flag rather
* than a change to default behavior so that applications relying on this
* for security won't even compile against older library versions).
* 1.0.1 and later also have a function SSL_renegotiate_abbreviated() to
* request renegotiation but not a new session (s->new_session remains
* unset): for servers, this essentially just means that the
* SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION setting will be ignored.
*/
if ((s->new_session
&& (s->options & SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION))) {
if (!ssl_get_new_session(s, 1))
goto err;
} else {
i = ssl_get_prev_session(s, p, j, d + n);
/*
* Only resume if the session's version matches the negotiated
* version.
* RFC 5246 does not provide much useful advice on resumption
* with a different protocol version. It doesn't forbid it but
* the sanity of such behaviour would be questionable.
* In practice, clients do not accept a version mismatch and
* will abort the handshake with an error.
*/
if (i == 1 && s->version == s->session->ssl_version) { /* previous
* session */
s->hit = 1;
} else if (i == -1)
goto err;
else { /* i == 0 */
if (!ssl_get_new_session(s, 1))
goto err;
}
}
p += j;
if (SSL_IS_DTLS(s)) {
/* cookie stuff */
cookie_len = *(p++);
/*
* The ClientHello may contain a cookie even if the
* HelloVerify message has not been sent--make sure that it
* does not cause an overflow.
*/
if (cookie_len > sizeof(s->d1->rcvd_cookie)) {
/* too much data */
al = SSL_AD_DECODE_ERROR;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_COOKIE_MISMATCH);
goto f_err;
}
/* verify the cookie if appropriate option is set. */
if ((SSL_get_options(s) & SSL_OP_COOKIE_EXCHANGE) && cookie_len > 0) {
memcpy(s->d1->rcvd_cookie, p, cookie_len);
if (s->ctx->app_verify_cookie_cb != NULL) {
if (s->ctx->app_verify_cookie_cb(s, s->d1->rcvd_cookie,
cookie_len) == 0) {
al = SSL_AD_HANDSHAKE_FAILURE;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,
SSL_R_COOKIE_MISMATCH);
goto f_err;
}
/* else cookie verification succeeded */
}
/* default verification */
else if (memcmp(s->d1->rcvd_cookie, s->d1->cookie,
s->d1->cookie_len) != 0) {
al = SSL_AD_HANDSHAKE_FAILURE;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_COOKIE_MISMATCH);
goto f_err;
}
/* Set to -2 so if successful we return 2 */
ret = -2;
}
p += cookie_len;
if (s->method->version == DTLS_ANY_VERSION) {
/* Select version to use */
if (s->client_version <= DTLS1_2_VERSION &&
!(s->options & SSL_OP_NO_DTLSv1_2)) {
s->version = DTLS1_2_VERSION;
s->method = DTLSv1_2_server_method();
} else if (tls1_suiteb(s)) {
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,
SSL_R_ONLY_DTLS_1_2_ALLOWED_IN_SUITEB_MODE);
s->version = s->client_version;
al = SSL_AD_PROTOCOL_VERSION;
goto f_err;
} else if (s->client_version <= DTLS1_VERSION &&
!(s->options & SSL_OP_NO_DTLSv1)) {
s->version = DTLS1_VERSION;
s->method = DTLSv1_server_method();
} else {
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,
SSL_R_WRONG_VERSION_NUMBER);
s->version = s->client_version;
al = SSL_AD_PROTOCOL_VERSION;
goto f_err;
}
s->session->ssl_version = s->version;
}
}
n2s(p, i);
if ((i == 0) && (j != 0)) {
/* we need a cipher if we are not resuming a session */
al = SSL_AD_ILLEGAL_PARAMETER;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_NO_CIPHERS_SPECIFIED);
goto f_err;
}
if ((p + i) >= (d + n)) {
/* not enough data */
al = SSL_AD_DECODE_ERROR;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_MISMATCH);
goto f_err;
}
if ((i > 0) && (ssl_bytes_to_cipher_list(s, p, i, &(ciphers))
== NULL)) {
goto err;
}
p += i;
/* If it is a hit, check that the cipher is in the list */
if ((s->hit) && (i > 0)) {
j = 0;
id = s->session->cipher->id;
#ifdef CIPHER_DEBUG
fprintf(stderr, "client sent %d ciphers\n",
sk_SSL_CIPHER_num(ciphers));
#endif
for (i = 0; i < sk_SSL_CIPHER_num(ciphers); i++) {
c = sk_SSL_CIPHER_value(ciphers, i);
#ifdef CIPHER_DEBUG
fprintf(stderr, "client [%2d of %2d]:%s\n",
i, sk_SSL_CIPHER_num(ciphers), SSL_CIPHER_get_name(c));
#endif
if (c->id == id) {
j = 1;
break;
}
}
/*
* Disabled because it can be used in a ciphersuite downgrade attack:
* CVE-2010-4180.
*/
#if 0
if (j == 0 && (s->options & SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG)
&& (sk_SSL_CIPHER_num(ciphers) == 1)) {
/*
* Special case as client bug workaround: the previously used
* cipher may not be in the current list, the client instead
* might be trying to continue using a cipher that before wasn't
* chosen due to server preferences. We'll have to reject the
* connection if the cipher is not enabled, though.
*/
c = sk_SSL_CIPHER_value(ciphers, 0);
if (sk_SSL_CIPHER_find(SSL_get_ciphers(s), c) >= 0) {
s->session->cipher = c;
j = 1;
}
}
#endif
if (j == 0) {
/*
* we need to have the cipher in the cipher list if we are asked
* to reuse it
*/
al = SSL_AD_ILLEGAL_PARAMETER;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,
SSL_R_REQUIRED_CIPHER_MISSING);
goto f_err;
}
}
/* compression */
i = *(p++);
if ((p + i) > (d + n)) {
/* not enough data */
al = SSL_AD_DECODE_ERROR;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_LENGTH_MISMATCH);
goto f_err;
}
#ifndef OPENSSL_NO_COMP
q = p;
#endif
for (j = 0; j < i; j++) {
if (p[j] == 0)
break;
}
p += i;
if (j >= i) {
/* no compress */
al = SSL_AD_DECODE_ERROR;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_NO_COMPRESSION_SPECIFIED);
goto f_err;
}
#ifndef OPENSSL_NO_TLSEXT
/* TLS extensions */
if (s->version >= SSL3_VERSION) {
if (!ssl_parse_clienthello_tlsext(s, &p, d, n)) {
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_PARSE_TLSEXT);
goto err;
}
}
/*
* Check if we want to use external pre-shared secret for this handshake
* for not reused session only. We need to generate server_random before
* calling tls_session_secret_cb in order to allow SessionTicket
* processing to use it in key derivation.
*/
{
unsigned char *pos;
pos = s->s3->server_random;
if (ssl_fill_hello_random(s, 1, pos, SSL3_RANDOM_SIZE) <= 0) {
goto f_err;
}
}
if (!s->hit && s->version >= TLS1_VERSION && s->tls_session_secret_cb) {
SSL_CIPHER *pref_cipher = NULL;
s->session->master_key_length = sizeof(s->session->master_key);
if (s->tls_session_secret_cb(s, s->session->master_key,
&s->session->master_key_length, ciphers,
&pref_cipher,
s->tls_session_secret_cb_arg)) {
s->hit = 1;
s->session->ciphers = ciphers;
s->session->verify_result = X509_V_OK;
ciphers = NULL;
/* check if some cipher was preferred by call back */
pref_cipher =
pref_cipher ? pref_cipher : ssl3_choose_cipher(s,
s->
session->ciphers,
SSL_get_ciphers
(s));
if (pref_cipher == NULL) {
al = SSL_AD_HANDSHAKE_FAILURE;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_NO_SHARED_CIPHER);
goto f_err;
}
s->session->cipher = pref_cipher;
if (s->cipher_list)
sk_SSL_CIPHER_free(s->cipher_list);
if (s->cipher_list_by_id)
sk_SSL_CIPHER_free(s->cipher_list_by_id);
s->cipher_list = sk_SSL_CIPHER_dup(s->session->ciphers);
s->cipher_list_by_id = sk_SSL_CIPHER_dup(s->session->ciphers);
}
}
#endif
/*
* Worst case, we will use the NULL compression, but if we have other
* options, we will now look for them. We have i-1 compression
* algorithms from the client, starting at q.
*/
s->s3->tmp.new_compression = NULL;
#ifndef OPENSSL_NO_COMP
/* This only happens if we have a cache hit */
if (s->session->compress_meth != 0) {
int m, comp_id = s->session->compress_meth;
/* Perform sanity checks on resumed compression algorithm */
/* Can't disable compression */
if (s->options & SSL_OP_NO_COMPRESSION) {
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,
SSL_R_INCONSISTENT_COMPRESSION);
goto f_err;
}
/* Look for resumed compression method */
for (m = 0; m < sk_SSL_COMP_num(s->ctx->comp_methods); m++) {
comp = sk_SSL_COMP_value(s->ctx->comp_methods, m);
if (comp_id == comp->id) {
s->s3->tmp.new_compression = comp;
break;
}
}
if (s->s3->tmp.new_compression == NULL) {
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,
SSL_R_INVALID_COMPRESSION_ALGORITHM);
goto f_err;
}
/* Look for resumed method in compression list */
for (m = 0; m < i; m++) {
if (q[m] == comp_id)
break;
}
if (m >= i) {
al = SSL_AD_ILLEGAL_PARAMETER;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO,
SSL_R_REQUIRED_COMPRESSSION_ALGORITHM_MISSING);
goto f_err;
}
} else if (s->hit)
comp = NULL;
else if (!(s->options & SSL_OP_NO_COMPRESSION) && s->ctx->comp_methods) {
/* See if we have a match */
int m, nn, o, v, done = 0;
nn = sk_SSL_COMP_num(s->ctx->comp_methods);
for (m = 0; m < nn; m++) {
comp = sk_SSL_COMP_value(s->ctx->comp_methods, m);
v = comp->id;
for (o = 0; o < i; o++) {
if (v == q[o]) {
done = 1;
break;
}
}
if (done)
break;
}
if (done)
s->s3->tmp.new_compression = comp;
else
comp = NULL;
}
#else
/*
* If compression is disabled we'd better not try to resume a session
* using compression.
*/
if (s->session->compress_meth != 0) {
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_INCONSISTENT_COMPRESSION);
goto f_err;
}
#endif
/*
* Given s->session->ciphers and SSL_get_ciphers, we must pick a cipher
*/
if (!s->hit) {
#ifdef OPENSSL_NO_COMP
s->session->compress_meth = 0;
#else
s->session->compress_meth = (comp == NULL) ? 0 : comp->id;
#endif
if (s->session->ciphers != NULL)
sk_SSL_CIPHER_free(s->session->ciphers);
s->session->ciphers = ciphers;
if (ciphers == NULL) {
al = SSL_AD_ILLEGAL_PARAMETER;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_NO_CIPHERS_PASSED);
goto f_err;
}
ciphers = NULL;
if (!tls1_set_server_sigalgs(s)) {
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_CLIENTHELLO_TLSEXT);
goto err;
}
/* Let cert callback update server certificates if required */
retry_cert:
if (s->cert->cert_cb) {
int rv = s->cert->cert_cb(s, s->cert->cert_cb_arg);
if (rv == 0) {
al = SSL_AD_INTERNAL_ERROR;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_CERT_CB_ERROR);
goto f_err;
}
if (rv < 0) {
s->rwstate = SSL_X509_LOOKUP;
return -1;
}
s->rwstate = SSL_NOTHING;
}
c = ssl3_choose_cipher(s, s->session->ciphers, SSL_get_ciphers(s));
if (c == NULL) {
al = SSL_AD_HANDSHAKE_FAILURE;
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_NO_SHARED_CIPHER);
goto f_err;
}
s->s3->tmp.new_cipher = c;
} else {
/* Session-id reuse */
#ifdef REUSE_CIPHER_BUG
STACK_OF(SSL_CIPHER) *sk;
SSL_CIPHER *nc = NULL;
SSL_CIPHER *ec = NULL;
if (s->options & SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG) {
sk = s->session->ciphers;
for (i = 0; i < sk_SSL_CIPHER_num(sk); i++) {
c = sk_SSL_CIPHER_value(sk, i);
if (c->algorithm_enc & SSL_eNULL)
nc = c;
if (SSL_C_IS_EXPORT(c))
ec = c;
}
if (nc != NULL)
s->s3->tmp.new_cipher = nc;
else if (ec != NULL)
s->s3->tmp.new_cipher = ec;
else
s->s3->tmp.new_cipher = s->session->cipher;
} else
#endif
s->s3->tmp.new_cipher = s->session->cipher;
}
if (!SSL_USE_SIGALGS(s) || !(s->verify_mode & SSL_VERIFY_PEER)) {
if (!ssl3_digest_cached_records(s))
goto f_err;
}
/*-
* we now have the following setup.
* client_random
* cipher_list - our prefered list of ciphers
* ciphers - the clients prefered list of ciphers
* compression - basically ignored right now
* ssl version is set - sslv3
* s->session - The ssl session has been setup.
* s->hit - session reuse flag
* s->tmp.new_cipher - the new cipher to use.
*/
/* Handles TLS extensions that we couldn't check earlier */
if (s->version >= SSL3_VERSION) {
if (ssl_check_clienthello_tlsext_late(s) <= 0) {
SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_CLIENTHELLO_TLSEXT);
goto err;
}
}
if (ret < 0)
ret = -ret;
if (0) {
f_err:
ssl3_send_alert(s, SSL3_AL_FATAL, al);
}
err:
if (ciphers != NULL)
sk_SSL_CIPHER_free(ciphers);
return ret < 0 ? -1 : ret;
}
|
@@ -2251,10 +2251,17 @@ int ssl3_get_client_key_exchange(SSL *s)
if (alg_k & (SSL_kEDH | SSL_kDHr | SSL_kDHd)) {
int idx = -1;
EVP_PKEY *skey = NULL;
- if (n)
+ if (n > 1) {
n2s(p, i);
- else
+ } else {
+ if (alg_k & SSL_kDHE) {
+ al = SSL_AD_HANDSHAKE_FAILURE;
+ SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,
+ SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG);
+ goto f_err;
+ }
i = 0;
+ }
if (n && n != i + 2) {
if (!(s->options & SSL_OP_SSLEAY_080_CLIENT_DH_BUG)) {
SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,
|
CWE-20
| null | null |
4,010
|
AddDef(String *buff, char *title, char *value)
{
#ifdef PATHETICCPP
if (need_real_defines) {
addstring(buff, "\n#define ");
addstring(buff, title);
if (value && (value[0] != '\0')) {
addstring(buff, " ");
addstring(buff, value);
}
return;
}
#endif
if (buff->used) {
if (oper == OPSYMBOLS)
addstring(buff, "\n-D");
else
addstring(buff, " -D");
} else
addstring(buff, " -D");
} else
|
Exec Code
| 0
|
AddDef(String *buff, char *title, char *value)
{
#ifdef PATHETICCPP
if (need_real_defines) {
addstring(buff, "\n#define ");
addstring(buff, title);
if (value && (value[0] != '\0')) {
addstring(buff, " ");
addstring(buff, value);
}
return;
}
#endif
if (buff->used) {
if (oper == OPSYMBOLS)
addstring(buff, "\n-D");
else
addstring(buff, " -D");
} else
addstring(buff, " -D");
} else
|
@@ -142,6 +142,8 @@ static Entries newDB;
static void fatal(char *, ...);
static void addstring ( String *arg, const char *s );
+static void addescapedstring ( String *arg, const char *s );
+static void addtokstring ( String *arg, const char *s );
static void FormatEntries ( Buffer *buffer, Entries *entries );
static void StoreProperty ( Display *dpy, Window root, Atom res_prop );
static void Process ( int scrno, Bool doScreen, Bool execute );
@@ -433,14 +435,20 @@ AddDef(String *buff, char *title, char *value)
addstring(buff, " -D");
} else
addstring(buff, "-D");
- addstring(buff, title);
+ addtokstring(buff, title);
if (value && (value[0] != '\0')) {
addstring(buff, "=");
- addstring(buff, value);
+ addescapedstring(buff, value);
}
}
static void
+AddSimpleDef(String *buff, char *title)
+{
+ AddDef(buff, title, (char *)NULL);
+}
+
+static void
AddDefQ(String *buff, char *title, char *value)
{
#ifdef PATHETICCPP
@@ -449,8 +457,9 @@ AddDefQ(String *buff, char *title, char *value)
else
#endif
if (value && (value[0] != '\0')) {
- AddDef(buff, title, "\"");
- addstring(buff, value);
+ AddSimpleDef(buff, title);
+ addstring(buff, "=\"");
+ addescapedstring(buff, value);
addstring(buff, "\"");
} else
AddDef(buff, title, NULL);
@@ -465,24 +474,28 @@ AddNum(String *buff, char *title, int value)
}
static void
-AddSimpleDef(String *buff, char *title)
+AddDefTok(String *buff, char *prefix, char *title)
{
- AddDef(buff, title, (char *)NULL);
+ char name[512];
+
+ snprintf(name, sizeof(name), "%s%s", prefix, title);
+ AddSimpleDef(buff, name);
}
static void
-AddDefTok(String *buff, char *prefix, char *title)
+AddDefHostname(String *buff, char *title, char *value)
{
char *s;
char name[512];
char c;
- snprintf(name, sizeof(name), "%s%s", prefix, title);
+ strncpy (name, value, sizeof(name)-1);
+ name[sizeof(name)-1] = '\0';
for (s = name; (c = *s); s++) {
- if (!isalpha(c) && !isdigit(c) && c != '_')
+ if (!isalpha(c) && !isdigit(c) && c != '_' && c != '.' && c != ':' && c != '-')
*s = '_';
}
- AddSimpleDef(buff, name);
+ AddDef(buff, title, name);
}
static void
@@ -502,7 +515,7 @@ AddUndef(String *buff, char *title)
addstring(buff, " -U");
} else
addstring(buff, "-U");
- addstring(buff, title);
+ addtokstring(buff, title);
}
static void
@@ -565,11 +578,11 @@ DoDisplayDefines(Display *display, String *defs, char *host)
}
if (!*server || !strcmp(server, "unix") || !strcmp(server, "localhost"))
strcpy(server, client);
- AddDef(defs, "HOST", server); /* R3 compatibility */
- AddDef(defs, "SERVERHOST", server);
+ AddDefHostname(defs, "HOST", server); /* R3 compatibility */
+ AddDefHostname(defs, "SERVERHOST", server);
AddDefTok(defs, "SRVR_", server);
AddNum(defs, "DISPLAY_NUM", n);
- AddDef(defs, "CLIENTHOST", client);
+ AddDefHostname(defs, "CLIENTHOST", client);
AddDefTok(defs, "CLNT_", client);
AddNum(defs, "VERSION", ProtocolVersion(display));
AddNum(defs, "REVISION", ProtocolRevision(display));
@@ -612,7 +625,7 @@ DoScreenDefines(Display *display, int scrno, String *defs)
AddNum(defs, "Y_RESOLUTION", Resolution(screen->height,screen->mheight));
AddNum(defs, "PLANES", DisplayPlanes(display, scrno));
AddNum(defs, "BITS_PER_RGB", visual->bits_per_rgb);
- AddDef(defs, "CLASS", ClassNames[visual->class]);
+ AddDefQ(defs, "CLASS", ClassNames[visual->class]);
snprintf(name, sizeof(name), "CLASS_%s", ClassNames[visual->class]);
AddNum(defs, name, (int)visual->visualid);
switch(visual->class) {
@@ -780,6 +793,40 @@ addstring(String *arg, const char *s)
arg->used += strlen(s);
}
+static void
+addescapedstring(String *arg, const char *s)
+{
+ char copy[512], *c;
+
+ for (c = copy; *s && c < ©[sizeof(copy)-1]; s++) {
+ switch (*s) {
+ case '"': case '\'': case '`':
+ case '$': case '\\':
+ *c++ = '_';
+ break;
+ default:
+ *c++ = *s;
+ }
+ }
+ *c = 0;
+ addstring (arg, copy);
+}
+
+static void
+addtokstring(String *arg, const char *s)
+{
+ char copy[512], *c;
+
+ for (c = copy; *s && c < ©[sizeof(copy)-1]; s++) {
+ if (!isalpha(*s) && !isdigit(*s) && *s != '_')
+ *c++ = '_';
+ else
+ *c++ = *s;
+ }
+ *c = 0;
+ addstring (arg, copy);
+}
+
int
main(int argc, char *argv[])
@@ -892,7 +939,7 @@ main(int argc, char *argv[])
continue;
} else if (arg[1] == 'I') {
addstring(&includes, " ");
- addstring(&includes, arg);
+ addescapedstring(&includes, arg);
continue;
} else if (arg[1] == 'U' || arg[1] == 'D') {
if (num_cmd_defines < MAX_CMD_DEFINES) {
|
CWE-20
| null | null |
4,011
|
AppendEntryToBuffer(Buffer *buffer, Entry *entry)
{
AppendToBuffer(buffer, entry->tag, strlen(entry->tag));
AppendToBuffer(buffer, ":\t", 2);
AppendToBuffer(buffer, entry->value, strlen(entry->value));
AppendToBuffer(buffer, "\n", 1);
}
|
Exec Code
| 0
|
AppendEntryToBuffer(Buffer *buffer, Entry *entry)
{
AppendToBuffer(buffer, entry->tag, strlen(entry->tag));
AppendToBuffer(buffer, ":\t", 2);
AppendToBuffer(buffer, entry->value, strlen(entry->value));
AppendToBuffer(buffer, "\n", 1);
}
|
@@ -142,6 +142,8 @@ static Entries newDB;
static void fatal(char *, ...);
static void addstring ( String *arg, const char *s );
+static void addescapedstring ( String *arg, const char *s );
+static void addtokstring ( String *arg, const char *s );
static void FormatEntries ( Buffer *buffer, Entries *entries );
static void StoreProperty ( Display *dpy, Window root, Atom res_prop );
static void Process ( int scrno, Bool doScreen, Bool execute );
@@ -433,14 +435,20 @@ AddDef(String *buff, char *title, char *value)
addstring(buff, " -D");
} else
addstring(buff, "-D");
- addstring(buff, title);
+ addtokstring(buff, title);
if (value && (value[0] != '\0')) {
addstring(buff, "=");
- addstring(buff, value);
+ addescapedstring(buff, value);
}
}
static void
+AddSimpleDef(String *buff, char *title)
+{
+ AddDef(buff, title, (char *)NULL);
+}
+
+static void
AddDefQ(String *buff, char *title, char *value)
{
#ifdef PATHETICCPP
@@ -449,8 +457,9 @@ AddDefQ(String *buff, char *title, char *value)
else
#endif
if (value && (value[0] != '\0')) {
- AddDef(buff, title, "\"");
- addstring(buff, value);
+ AddSimpleDef(buff, title);
+ addstring(buff, "=\"");
+ addescapedstring(buff, value);
addstring(buff, "\"");
} else
AddDef(buff, title, NULL);
@@ -465,24 +474,28 @@ AddNum(String *buff, char *title, int value)
}
static void
-AddSimpleDef(String *buff, char *title)
+AddDefTok(String *buff, char *prefix, char *title)
{
- AddDef(buff, title, (char *)NULL);
+ char name[512];
+
+ snprintf(name, sizeof(name), "%s%s", prefix, title);
+ AddSimpleDef(buff, name);
}
static void
-AddDefTok(String *buff, char *prefix, char *title)
+AddDefHostname(String *buff, char *title, char *value)
{
char *s;
char name[512];
char c;
- snprintf(name, sizeof(name), "%s%s", prefix, title);
+ strncpy (name, value, sizeof(name)-1);
+ name[sizeof(name)-1] = '\0';
for (s = name; (c = *s); s++) {
- if (!isalpha(c) && !isdigit(c) && c != '_')
+ if (!isalpha(c) && !isdigit(c) && c != '_' && c != '.' && c != ':' && c != '-')
*s = '_';
}
- AddSimpleDef(buff, name);
+ AddDef(buff, title, name);
}
static void
@@ -502,7 +515,7 @@ AddUndef(String *buff, char *title)
addstring(buff, " -U");
} else
addstring(buff, "-U");
- addstring(buff, title);
+ addtokstring(buff, title);
}
static void
@@ -565,11 +578,11 @@ DoDisplayDefines(Display *display, String *defs, char *host)
}
if (!*server || !strcmp(server, "unix") || !strcmp(server, "localhost"))
strcpy(server, client);
- AddDef(defs, "HOST", server); /* R3 compatibility */
- AddDef(defs, "SERVERHOST", server);
+ AddDefHostname(defs, "HOST", server); /* R3 compatibility */
+ AddDefHostname(defs, "SERVERHOST", server);
AddDefTok(defs, "SRVR_", server);
AddNum(defs, "DISPLAY_NUM", n);
- AddDef(defs, "CLIENTHOST", client);
+ AddDefHostname(defs, "CLIENTHOST", client);
AddDefTok(defs, "CLNT_", client);
AddNum(defs, "VERSION", ProtocolVersion(display));
AddNum(defs, "REVISION", ProtocolRevision(display));
@@ -612,7 +625,7 @@ DoScreenDefines(Display *display, int scrno, String *defs)
AddNum(defs, "Y_RESOLUTION", Resolution(screen->height,screen->mheight));
AddNum(defs, "PLANES", DisplayPlanes(display, scrno));
AddNum(defs, "BITS_PER_RGB", visual->bits_per_rgb);
- AddDef(defs, "CLASS", ClassNames[visual->class]);
+ AddDefQ(defs, "CLASS", ClassNames[visual->class]);
snprintf(name, sizeof(name), "CLASS_%s", ClassNames[visual->class]);
AddNum(defs, name, (int)visual->visualid);
switch(visual->class) {
@@ -780,6 +793,40 @@ addstring(String *arg, const char *s)
arg->used += strlen(s);
}
+static void
+addescapedstring(String *arg, const char *s)
+{
+ char copy[512], *c;
+
+ for (c = copy; *s && c < ©[sizeof(copy)-1]; s++) {
+ switch (*s) {
+ case '"': case '\'': case '`':
+ case '$': case '\\':
+ *c++ = '_';
+ break;
+ default:
+ *c++ = *s;
+ }
+ }
+ *c = 0;
+ addstring (arg, copy);
+}
+
+static void
+addtokstring(String *arg, const char *s)
+{
+ char copy[512], *c;
+
+ for (c = copy; *s && c < ©[sizeof(copy)-1]; s++) {
+ if (!isalpha(*s) && !isdigit(*s) && *s != '_')
+ *c++ = '_';
+ else
+ *c++ = *s;
+ }
+ *c = 0;
+ addstring (arg, copy);
+}
+
int
main(int argc, char *argv[])
@@ -892,7 +939,7 @@ main(int argc, char *argv[])
continue;
} else if (arg[1] == 'I') {
addstring(&includes, " ");
- addstring(&includes, arg);
+ addescapedstring(&includes, arg);
continue;
} else if (arg[1] == 'U' || arg[1] == 'D') {
if (num_cmd_defines < MAX_CMD_DEFINES) {
|
CWE-20
| null | null |
4,012
|
AppendToBuffer(Buffer *b, char *str, int len)
{
while (b->used + len > b->room) {
b->buff = (char *)realloc(b->buff, 2*b->room*(sizeof(char)));
b->room *= 2;
}
strncpy(b->buff + b->used, str, len);
b->used += len;
}
|
Exec Code
| 0
|
AppendToBuffer(Buffer *b, char *str, int len)
{
while (b->used + len > b->room) {
b->buff = (char *)realloc(b->buff, 2*b->room*(sizeof(char)));
b->room *= 2;
}
strncpy(b->buff + b->used, str, len);
b->used += len;
}
|
@@ -142,6 +142,8 @@ static Entries newDB;
static void fatal(char *, ...);
static void addstring ( String *arg, const char *s );
+static void addescapedstring ( String *arg, const char *s );
+static void addtokstring ( String *arg, const char *s );
static void FormatEntries ( Buffer *buffer, Entries *entries );
static void StoreProperty ( Display *dpy, Window root, Atom res_prop );
static void Process ( int scrno, Bool doScreen, Bool execute );
@@ -433,14 +435,20 @@ AddDef(String *buff, char *title, char *value)
addstring(buff, " -D");
} else
addstring(buff, "-D");
- addstring(buff, title);
+ addtokstring(buff, title);
if (value && (value[0] != '\0')) {
addstring(buff, "=");
- addstring(buff, value);
+ addescapedstring(buff, value);
}
}
static void
+AddSimpleDef(String *buff, char *title)
+{
+ AddDef(buff, title, (char *)NULL);
+}
+
+static void
AddDefQ(String *buff, char *title, char *value)
{
#ifdef PATHETICCPP
@@ -449,8 +457,9 @@ AddDefQ(String *buff, char *title, char *value)
else
#endif
if (value && (value[0] != '\0')) {
- AddDef(buff, title, "\"");
- addstring(buff, value);
+ AddSimpleDef(buff, title);
+ addstring(buff, "=\"");
+ addescapedstring(buff, value);
addstring(buff, "\"");
} else
AddDef(buff, title, NULL);
@@ -465,24 +474,28 @@ AddNum(String *buff, char *title, int value)
}
static void
-AddSimpleDef(String *buff, char *title)
+AddDefTok(String *buff, char *prefix, char *title)
{
- AddDef(buff, title, (char *)NULL);
+ char name[512];
+
+ snprintf(name, sizeof(name), "%s%s", prefix, title);
+ AddSimpleDef(buff, name);
}
static void
-AddDefTok(String *buff, char *prefix, char *title)
+AddDefHostname(String *buff, char *title, char *value)
{
char *s;
char name[512];
char c;
- snprintf(name, sizeof(name), "%s%s", prefix, title);
+ strncpy (name, value, sizeof(name)-1);
+ name[sizeof(name)-1] = '\0';
for (s = name; (c = *s); s++) {
- if (!isalpha(c) && !isdigit(c) && c != '_')
+ if (!isalpha(c) && !isdigit(c) && c != '_' && c != '.' && c != ':' && c != '-')
*s = '_';
}
- AddSimpleDef(buff, name);
+ AddDef(buff, title, name);
}
static void
@@ -502,7 +515,7 @@ AddUndef(String *buff, char *title)
addstring(buff, " -U");
} else
addstring(buff, "-U");
- addstring(buff, title);
+ addtokstring(buff, title);
}
static void
@@ -565,11 +578,11 @@ DoDisplayDefines(Display *display, String *defs, char *host)
}
if (!*server || !strcmp(server, "unix") || !strcmp(server, "localhost"))
strcpy(server, client);
- AddDef(defs, "HOST", server); /* R3 compatibility */
- AddDef(defs, "SERVERHOST", server);
+ AddDefHostname(defs, "HOST", server); /* R3 compatibility */
+ AddDefHostname(defs, "SERVERHOST", server);
AddDefTok(defs, "SRVR_", server);
AddNum(defs, "DISPLAY_NUM", n);
- AddDef(defs, "CLIENTHOST", client);
+ AddDefHostname(defs, "CLIENTHOST", client);
AddDefTok(defs, "CLNT_", client);
AddNum(defs, "VERSION", ProtocolVersion(display));
AddNum(defs, "REVISION", ProtocolRevision(display));
@@ -612,7 +625,7 @@ DoScreenDefines(Display *display, int scrno, String *defs)
AddNum(defs, "Y_RESOLUTION", Resolution(screen->height,screen->mheight));
AddNum(defs, "PLANES", DisplayPlanes(display, scrno));
AddNum(defs, "BITS_PER_RGB", visual->bits_per_rgb);
- AddDef(defs, "CLASS", ClassNames[visual->class]);
+ AddDefQ(defs, "CLASS", ClassNames[visual->class]);
snprintf(name, sizeof(name), "CLASS_%s", ClassNames[visual->class]);
AddNum(defs, name, (int)visual->visualid);
switch(visual->class) {
@@ -780,6 +793,40 @@ addstring(String *arg, const char *s)
arg->used += strlen(s);
}
+static void
+addescapedstring(String *arg, const char *s)
+{
+ char copy[512], *c;
+
+ for (c = copy; *s && c < ©[sizeof(copy)-1]; s++) {
+ switch (*s) {
+ case '"': case '\'': case '`':
+ case '$': case '\\':
+ *c++ = '_';
+ break;
+ default:
+ *c++ = *s;
+ }
+ }
+ *c = 0;
+ addstring (arg, copy);
+}
+
+static void
+addtokstring(String *arg, const char *s)
+{
+ char copy[512], *c;
+
+ for (c = copy; *s && c < ©[sizeof(copy)-1]; s++) {
+ if (!isalpha(*s) && !isdigit(*s) && *s != '_')
+ *c++ = '_';
+ else
+ *c++ = *s;
+ }
+ *c = 0;
+ addstring (arg, copy);
+}
+
int
main(int argc, char *argv[])
@@ -892,7 +939,7 @@ main(int argc, char *argv[])
continue;
} else if (arg[1] == 'I') {
addstring(&includes, " ");
- addstring(&includes, arg);
+ addescapedstring(&includes, arg);
continue;
} else if (arg[1] == 'U' || arg[1] == 'D') {
if (num_cmd_defines < MAX_CMD_DEFINES) {
|
CWE-20
| null | null |
4,013
|
FindFirst(char *string, char dest, int *lines)
{
if (lines)
*lines = 0;
for (;;) {
if (*string == '\0')
return NULL;
if (*string == '\\') {
if (*++string == '\0')
return NULL;
} else if (*string == dest)
return string;
if (*string == '\n' && lines)
(*lines)++;
string++;
}
}
|
Exec Code
| 0
|
FindFirst(char *string, char dest, int *lines)
{
if (lines)
*lines = 0;
for (;;) {
if (*string == '\0')
return NULL;
if (*string == '\\') {
if (*++string == '\0')
return NULL;
} else if (*string == dest)
return string;
if (*string == '\n' && lines)
(*lines)++;
string++;
}
}
|
@@ -142,6 +142,8 @@ static Entries newDB;
static void fatal(char *, ...);
static void addstring ( String *arg, const char *s );
+static void addescapedstring ( String *arg, const char *s );
+static void addtokstring ( String *arg, const char *s );
static void FormatEntries ( Buffer *buffer, Entries *entries );
static void StoreProperty ( Display *dpy, Window root, Atom res_prop );
static void Process ( int scrno, Bool doScreen, Bool execute );
@@ -433,14 +435,20 @@ AddDef(String *buff, char *title, char *value)
addstring(buff, " -D");
} else
addstring(buff, "-D");
- addstring(buff, title);
+ addtokstring(buff, title);
if (value && (value[0] != '\0')) {
addstring(buff, "=");
- addstring(buff, value);
+ addescapedstring(buff, value);
}
}
static void
+AddSimpleDef(String *buff, char *title)
+{
+ AddDef(buff, title, (char *)NULL);
+}
+
+static void
AddDefQ(String *buff, char *title, char *value)
{
#ifdef PATHETICCPP
@@ -449,8 +457,9 @@ AddDefQ(String *buff, char *title, char *value)
else
#endif
if (value && (value[0] != '\0')) {
- AddDef(buff, title, "\"");
- addstring(buff, value);
+ AddSimpleDef(buff, title);
+ addstring(buff, "=\"");
+ addescapedstring(buff, value);
addstring(buff, "\"");
} else
AddDef(buff, title, NULL);
@@ -465,24 +474,28 @@ AddNum(String *buff, char *title, int value)
}
static void
-AddSimpleDef(String *buff, char *title)
+AddDefTok(String *buff, char *prefix, char *title)
{
- AddDef(buff, title, (char *)NULL);
+ char name[512];
+
+ snprintf(name, sizeof(name), "%s%s", prefix, title);
+ AddSimpleDef(buff, name);
}
static void
-AddDefTok(String *buff, char *prefix, char *title)
+AddDefHostname(String *buff, char *title, char *value)
{
char *s;
char name[512];
char c;
- snprintf(name, sizeof(name), "%s%s", prefix, title);
+ strncpy (name, value, sizeof(name)-1);
+ name[sizeof(name)-1] = '\0';
for (s = name; (c = *s); s++) {
- if (!isalpha(c) && !isdigit(c) && c != '_')
+ if (!isalpha(c) && !isdigit(c) && c != '_' && c != '.' && c != ':' && c != '-')
*s = '_';
}
- AddSimpleDef(buff, name);
+ AddDef(buff, title, name);
}
static void
@@ -502,7 +515,7 @@ AddUndef(String *buff, char *title)
addstring(buff, " -U");
} else
addstring(buff, "-U");
- addstring(buff, title);
+ addtokstring(buff, title);
}
static void
@@ -565,11 +578,11 @@ DoDisplayDefines(Display *display, String *defs, char *host)
}
if (!*server || !strcmp(server, "unix") || !strcmp(server, "localhost"))
strcpy(server, client);
- AddDef(defs, "HOST", server); /* R3 compatibility */
- AddDef(defs, "SERVERHOST", server);
+ AddDefHostname(defs, "HOST", server); /* R3 compatibility */
+ AddDefHostname(defs, "SERVERHOST", server);
AddDefTok(defs, "SRVR_", server);
AddNum(defs, "DISPLAY_NUM", n);
- AddDef(defs, "CLIENTHOST", client);
+ AddDefHostname(defs, "CLIENTHOST", client);
AddDefTok(defs, "CLNT_", client);
AddNum(defs, "VERSION", ProtocolVersion(display));
AddNum(defs, "REVISION", ProtocolRevision(display));
@@ -612,7 +625,7 @@ DoScreenDefines(Display *display, int scrno, String *defs)
AddNum(defs, "Y_RESOLUTION", Resolution(screen->height,screen->mheight));
AddNum(defs, "PLANES", DisplayPlanes(display, scrno));
AddNum(defs, "BITS_PER_RGB", visual->bits_per_rgb);
- AddDef(defs, "CLASS", ClassNames[visual->class]);
+ AddDefQ(defs, "CLASS", ClassNames[visual->class]);
snprintf(name, sizeof(name), "CLASS_%s", ClassNames[visual->class]);
AddNum(defs, name, (int)visual->visualid);
switch(visual->class) {
@@ -780,6 +793,40 @@ addstring(String *arg, const char *s)
arg->used += strlen(s);
}
+static void
+addescapedstring(String *arg, const char *s)
+{
+ char copy[512], *c;
+
+ for (c = copy; *s && c < ©[sizeof(copy)-1]; s++) {
+ switch (*s) {
+ case '"': case '\'': case '`':
+ case '$': case '\\':
+ *c++ = '_';
+ break;
+ default:
+ *c++ = *s;
+ }
+ }
+ *c = 0;
+ addstring (arg, copy);
+}
+
+static void
+addtokstring(String *arg, const char *s)
+{
+ char copy[512], *c;
+
+ for (c = copy; *s && c < ©[sizeof(copy)-1]; s++) {
+ if (!isalpha(*s) && !isdigit(*s) && *s != '_')
+ *c++ = '_';
+ else
+ *c++ = *s;
+ }
+ *c = 0;
+ addstring (arg, copy);
+}
+
int
main(int argc, char *argv[])
@@ -892,7 +939,7 @@ main(int argc, char *argv[])
continue;
} else if (arg[1] == 'I') {
addstring(&includes, " ");
- addstring(&includes, arg);
+ addescapedstring(&includes, arg);
continue;
} else if (arg[1] == 'U' || arg[1] == 'D') {
if (num_cmd_defines < MAX_CMD_DEFINES) {
|
CWE-20
| null | null |
4,014
|
FreeEntries(Entries *e)
{
register int i;
for (i = 0; i < e->used; i++) {
if (e->entry[i].usable) {
free(e->entry[i].tag);
free(e->entry[i].value);
}
}
free((char *)e->entry);
}
|
Exec Code
| 0
|
FreeEntries(Entries *e)
{
register int i;
for (i = 0; i < e->used; i++) {
if (e->entry[i].usable) {
free(e->entry[i].tag);
free(e->entry[i].value);
}
}
free((char *)e->entry);
}
|
@@ -142,6 +142,8 @@ static Entries newDB;
static void fatal(char *, ...);
static void addstring ( String *arg, const char *s );
+static void addescapedstring ( String *arg, const char *s );
+static void addtokstring ( String *arg, const char *s );
static void FormatEntries ( Buffer *buffer, Entries *entries );
static void StoreProperty ( Display *dpy, Window root, Atom res_prop );
static void Process ( int scrno, Bool doScreen, Bool execute );
@@ -433,14 +435,20 @@ AddDef(String *buff, char *title, char *value)
addstring(buff, " -D");
} else
addstring(buff, "-D");
- addstring(buff, title);
+ addtokstring(buff, title);
if (value && (value[0] != '\0')) {
addstring(buff, "=");
- addstring(buff, value);
+ addescapedstring(buff, value);
}
}
static void
+AddSimpleDef(String *buff, char *title)
+{
+ AddDef(buff, title, (char *)NULL);
+}
+
+static void
AddDefQ(String *buff, char *title, char *value)
{
#ifdef PATHETICCPP
@@ -449,8 +457,9 @@ AddDefQ(String *buff, char *title, char *value)
else
#endif
if (value && (value[0] != '\0')) {
- AddDef(buff, title, "\"");
- addstring(buff, value);
+ AddSimpleDef(buff, title);
+ addstring(buff, "=\"");
+ addescapedstring(buff, value);
addstring(buff, "\"");
} else
AddDef(buff, title, NULL);
@@ -465,24 +474,28 @@ AddNum(String *buff, char *title, int value)
}
static void
-AddSimpleDef(String *buff, char *title)
+AddDefTok(String *buff, char *prefix, char *title)
{
- AddDef(buff, title, (char *)NULL);
+ char name[512];
+
+ snprintf(name, sizeof(name), "%s%s", prefix, title);
+ AddSimpleDef(buff, name);
}
static void
-AddDefTok(String *buff, char *prefix, char *title)
+AddDefHostname(String *buff, char *title, char *value)
{
char *s;
char name[512];
char c;
- snprintf(name, sizeof(name), "%s%s", prefix, title);
+ strncpy (name, value, sizeof(name)-1);
+ name[sizeof(name)-1] = '\0';
for (s = name; (c = *s); s++) {
- if (!isalpha(c) && !isdigit(c) && c != '_')
+ if (!isalpha(c) && !isdigit(c) && c != '_' && c != '.' && c != ':' && c != '-')
*s = '_';
}
- AddSimpleDef(buff, name);
+ AddDef(buff, title, name);
}
static void
@@ -502,7 +515,7 @@ AddUndef(String *buff, char *title)
addstring(buff, " -U");
} else
addstring(buff, "-U");
- addstring(buff, title);
+ addtokstring(buff, title);
}
static void
@@ -565,11 +578,11 @@ DoDisplayDefines(Display *display, String *defs, char *host)
}
if (!*server || !strcmp(server, "unix") || !strcmp(server, "localhost"))
strcpy(server, client);
- AddDef(defs, "HOST", server); /* R3 compatibility */
- AddDef(defs, "SERVERHOST", server);
+ AddDefHostname(defs, "HOST", server); /* R3 compatibility */
+ AddDefHostname(defs, "SERVERHOST", server);
AddDefTok(defs, "SRVR_", server);
AddNum(defs, "DISPLAY_NUM", n);
- AddDef(defs, "CLIENTHOST", client);
+ AddDefHostname(defs, "CLIENTHOST", client);
AddDefTok(defs, "CLNT_", client);
AddNum(defs, "VERSION", ProtocolVersion(display));
AddNum(defs, "REVISION", ProtocolRevision(display));
@@ -612,7 +625,7 @@ DoScreenDefines(Display *display, int scrno, String *defs)
AddNum(defs, "Y_RESOLUTION", Resolution(screen->height,screen->mheight));
AddNum(defs, "PLANES", DisplayPlanes(display, scrno));
AddNum(defs, "BITS_PER_RGB", visual->bits_per_rgb);
- AddDef(defs, "CLASS", ClassNames[visual->class]);
+ AddDefQ(defs, "CLASS", ClassNames[visual->class]);
snprintf(name, sizeof(name), "CLASS_%s", ClassNames[visual->class]);
AddNum(defs, name, (int)visual->visualid);
switch(visual->class) {
@@ -780,6 +793,40 @@ addstring(String *arg, const char *s)
arg->used += strlen(s);
}
+static void
+addescapedstring(String *arg, const char *s)
+{
+ char copy[512], *c;
+
+ for (c = copy; *s && c < ©[sizeof(copy)-1]; s++) {
+ switch (*s) {
+ case '"': case '\'': case '`':
+ case '$': case '\\':
+ *c++ = '_';
+ break;
+ default:
+ *c++ = *s;
+ }
+ }
+ *c = 0;
+ addstring (arg, copy);
+}
+
+static void
+addtokstring(String *arg, const char *s)
+{
+ char copy[512], *c;
+
+ for (c = copy; *s && c < ©[sizeof(copy)-1]; s++) {
+ if (!isalpha(*s) && !isdigit(*s) && *s != '_')
+ *c++ = '_';
+ else
+ *c++ = *s;
+ }
+ *c = 0;
+ addstring (arg, copy);
+}
+
int
main(int argc, char *argv[])
@@ -892,7 +939,7 @@ main(int argc, char *argv[])
continue;
} else if (arg[1] == 'I') {
addstring(&includes, " ");
- addstring(&includes, arg);
+ addescapedstring(&includes, arg);
continue;
} else if (arg[1] == 'U' || arg[1] == 'D') {
if (num_cmd_defines < MAX_CMD_DEFINES) {
|
CWE-20
| null | null |
4,015
|
GetEntries(Entries *entries, Buffer *buff, int bequiet)
{
register char *line, *colon, *temp, *str;
Entry entry;
register int length;
int lineno = 0;
int lines_skipped;
str = buff->buff;
if (!str) return;
for ( ; str < buff->buff + buff->used;
str = line + 1, lineno += lines_skipped) {
line = FindFirst(str, '\n', &lines_skipped);
lineno++;
if (!line)
line = buff->buff + buff->used;
if (*str == '!')
continue;
if (*str == '\n')
continue;
if (!bequiet && *str == '#') {
int dummy;
if (sscanf (str, "# %d", &dummy) == 1 ||
sscanf (str, "# line %d", &dummy) == 1)
lineno = dummy - 1;
continue;
}
for (temp = str;
*temp && *temp != '\n' && isascii(*temp) && isspace(*temp);
temp++) ;
if (!*temp || *temp == '\n') continue;
colon = FindFirst(str, ':', NULL);
if (!colon || colon > line) {
if (!bequiet && !quiet)
fprintf (stderr,
"%s: colon missing on line %d, ignoring line\n",
ProgramName, lineno);
continue;
}
/* strip leading and trailing blanks from name and store result */
while (*str == ' ' || *str == '\t')
str++;
length = colon - str;
while (length && (str[length-1] == ' ' || str[length-1] == '\t'))
length--;
temp = (char *)malloc(length + 1);
strncpy(temp, str, length);
temp[length] = '\0';
entry.tag = temp;
/* strip leading and trailing blanks from value and store result */
colon++;
while (*colon == ' ' || *colon == '\t')
colon++;
length = line - colon;
temp = (char *)malloc(length + 1);
strncpy(temp, colon, length);
temp[length] = '\0';
entry.value = temp;
entry.lineno = bequiet ? 0 : lineno;
AddEntry(entries, &entry);
}
}
|
Exec Code
| 0
|
GetEntries(Entries *entries, Buffer *buff, int bequiet)
{
register char *line, *colon, *temp, *str;
Entry entry;
register int length;
int lineno = 0;
int lines_skipped;
str = buff->buff;
if (!str) return;
for ( ; str < buff->buff + buff->used;
str = line + 1, lineno += lines_skipped) {
line = FindFirst(str, '\n', &lines_skipped);
lineno++;
if (!line)
line = buff->buff + buff->used;
if (*str == '!')
continue;
if (*str == '\n')
continue;
if (!bequiet && *str == '#') {
int dummy;
if (sscanf (str, "# %d", &dummy) == 1 ||
sscanf (str, "# line %d", &dummy) == 1)
lineno = dummy - 1;
continue;
}
for (temp = str;
*temp && *temp != '\n' && isascii(*temp) && isspace(*temp);
temp++) ;
if (!*temp || *temp == '\n') continue;
colon = FindFirst(str, ':', NULL);
if (!colon || colon > line) {
if (!bequiet && !quiet)
fprintf (stderr,
"%s: colon missing on line %d, ignoring line\n",
ProgramName, lineno);
continue;
}
/* strip leading and trailing blanks from name and store result */
while (*str == ' ' || *str == '\t')
str++;
length = colon - str;
while (length && (str[length-1] == ' ' || str[length-1] == '\t'))
length--;
temp = (char *)malloc(length + 1);
strncpy(temp, str, length);
temp[length] = '\0';
entry.tag = temp;
/* strip leading and trailing blanks from value and store result */
colon++;
while (*colon == ' ' || *colon == '\t')
colon++;
length = line - colon;
temp = (char *)malloc(length + 1);
strncpy(temp, colon, length);
temp[length] = '\0';
entry.value = temp;
entry.lineno = bequiet ? 0 : lineno;
AddEntry(entries, &entry);
}
}
|
@@ -142,6 +142,8 @@ static Entries newDB;
static void fatal(char *, ...);
static void addstring ( String *arg, const char *s );
+static void addescapedstring ( String *arg, const char *s );
+static void addtokstring ( String *arg, const char *s );
static void FormatEntries ( Buffer *buffer, Entries *entries );
static void StoreProperty ( Display *dpy, Window root, Atom res_prop );
static void Process ( int scrno, Bool doScreen, Bool execute );
@@ -433,14 +435,20 @@ AddDef(String *buff, char *title, char *value)
addstring(buff, " -D");
} else
addstring(buff, "-D");
- addstring(buff, title);
+ addtokstring(buff, title);
if (value && (value[0] != '\0')) {
addstring(buff, "=");
- addstring(buff, value);
+ addescapedstring(buff, value);
}
}
static void
+AddSimpleDef(String *buff, char *title)
+{
+ AddDef(buff, title, (char *)NULL);
+}
+
+static void
AddDefQ(String *buff, char *title, char *value)
{
#ifdef PATHETICCPP
@@ -449,8 +457,9 @@ AddDefQ(String *buff, char *title, char *value)
else
#endif
if (value && (value[0] != '\0')) {
- AddDef(buff, title, "\"");
- addstring(buff, value);
+ AddSimpleDef(buff, title);
+ addstring(buff, "=\"");
+ addescapedstring(buff, value);
addstring(buff, "\"");
} else
AddDef(buff, title, NULL);
@@ -465,24 +474,28 @@ AddNum(String *buff, char *title, int value)
}
static void
-AddSimpleDef(String *buff, char *title)
+AddDefTok(String *buff, char *prefix, char *title)
{
- AddDef(buff, title, (char *)NULL);
+ char name[512];
+
+ snprintf(name, sizeof(name), "%s%s", prefix, title);
+ AddSimpleDef(buff, name);
}
static void
-AddDefTok(String *buff, char *prefix, char *title)
+AddDefHostname(String *buff, char *title, char *value)
{
char *s;
char name[512];
char c;
- snprintf(name, sizeof(name), "%s%s", prefix, title);
+ strncpy (name, value, sizeof(name)-1);
+ name[sizeof(name)-1] = '\0';
for (s = name; (c = *s); s++) {
- if (!isalpha(c) && !isdigit(c) && c != '_')
+ if (!isalpha(c) && !isdigit(c) && c != '_' && c != '.' && c != ':' && c != '-')
*s = '_';
}
- AddSimpleDef(buff, name);
+ AddDef(buff, title, name);
}
static void
@@ -502,7 +515,7 @@ AddUndef(String *buff, char *title)
addstring(buff, " -U");
} else
addstring(buff, "-U");
- addstring(buff, title);
+ addtokstring(buff, title);
}
static void
@@ -565,11 +578,11 @@ DoDisplayDefines(Display *display, String *defs, char *host)
}
if (!*server || !strcmp(server, "unix") || !strcmp(server, "localhost"))
strcpy(server, client);
- AddDef(defs, "HOST", server); /* R3 compatibility */
- AddDef(defs, "SERVERHOST", server);
+ AddDefHostname(defs, "HOST", server); /* R3 compatibility */
+ AddDefHostname(defs, "SERVERHOST", server);
AddDefTok(defs, "SRVR_", server);
AddNum(defs, "DISPLAY_NUM", n);
- AddDef(defs, "CLIENTHOST", client);
+ AddDefHostname(defs, "CLIENTHOST", client);
AddDefTok(defs, "CLNT_", client);
AddNum(defs, "VERSION", ProtocolVersion(display));
AddNum(defs, "REVISION", ProtocolRevision(display));
@@ -612,7 +625,7 @@ DoScreenDefines(Display *display, int scrno, String *defs)
AddNum(defs, "Y_RESOLUTION", Resolution(screen->height,screen->mheight));
AddNum(defs, "PLANES", DisplayPlanes(display, scrno));
AddNum(defs, "BITS_PER_RGB", visual->bits_per_rgb);
- AddDef(defs, "CLASS", ClassNames[visual->class]);
+ AddDefQ(defs, "CLASS", ClassNames[visual->class]);
snprintf(name, sizeof(name), "CLASS_%s", ClassNames[visual->class]);
AddNum(defs, name, (int)visual->visualid);
switch(visual->class) {
@@ -780,6 +793,40 @@ addstring(String *arg, const char *s)
arg->used += strlen(s);
}
+static void
+addescapedstring(String *arg, const char *s)
+{
+ char copy[512], *c;
+
+ for (c = copy; *s && c < ©[sizeof(copy)-1]; s++) {
+ switch (*s) {
+ case '"': case '\'': case '`':
+ case '$': case '\\':
+ *c++ = '_';
+ break;
+ default:
+ *c++ = *s;
+ }
+ }
+ *c = 0;
+ addstring (arg, copy);
+}
+
+static void
+addtokstring(String *arg, const char *s)
+{
+ char copy[512], *c;
+
+ for (c = copy; *s && c < ©[sizeof(copy)-1]; s++) {
+ if (!isalpha(*s) && !isdigit(*s) && *s != '_')
+ *c++ = '_';
+ else
+ *c++ = *s;
+ }
+ *c = 0;
+ addstring (arg, copy);
+}
+
int
main(int argc, char *argv[])
@@ -892,7 +939,7 @@ main(int argc, char *argv[])
continue;
} else if (arg[1] == 'I') {
addstring(&includes, " ");
- addstring(&includes, arg);
+ addescapedstring(&includes, arg);
continue;
} else if (arg[1] == 'U' || arg[1] == 'D') {
if (num_cmd_defines < MAX_CMD_DEFINES) {
|
CWE-20
| null | null |
4,016
|
GetEntriesString(Entries *entries, char *str)
{
Buffer buff;
if (str && *str) {
buff.buff = str;
buff.used = strlen(str);
GetEntries(entries, &buff, 1);
}
}
|
Exec Code
| 0
|
GetEntriesString(Entries *entries, char *str)
{
Buffer buff;
if (str && *str) {
buff.buff = str;
buff.used = strlen(str);
GetEntries(entries, &buff, 1);
}
}
|
@@ -142,6 +142,8 @@ static Entries newDB;
static void fatal(char *, ...);
static void addstring ( String *arg, const char *s );
+static void addescapedstring ( String *arg, const char *s );
+static void addtokstring ( String *arg, const char *s );
static void FormatEntries ( Buffer *buffer, Entries *entries );
static void StoreProperty ( Display *dpy, Window root, Atom res_prop );
static void Process ( int scrno, Bool doScreen, Bool execute );
@@ -433,14 +435,20 @@ AddDef(String *buff, char *title, char *value)
addstring(buff, " -D");
} else
addstring(buff, "-D");
- addstring(buff, title);
+ addtokstring(buff, title);
if (value && (value[0] != '\0')) {
addstring(buff, "=");
- addstring(buff, value);
+ addescapedstring(buff, value);
}
}
static void
+AddSimpleDef(String *buff, char *title)
+{
+ AddDef(buff, title, (char *)NULL);
+}
+
+static void
AddDefQ(String *buff, char *title, char *value)
{
#ifdef PATHETICCPP
@@ -449,8 +457,9 @@ AddDefQ(String *buff, char *title, char *value)
else
#endif
if (value && (value[0] != '\0')) {
- AddDef(buff, title, "\"");
- addstring(buff, value);
+ AddSimpleDef(buff, title);
+ addstring(buff, "=\"");
+ addescapedstring(buff, value);
addstring(buff, "\"");
} else
AddDef(buff, title, NULL);
@@ -465,24 +474,28 @@ AddNum(String *buff, char *title, int value)
}
static void
-AddSimpleDef(String *buff, char *title)
+AddDefTok(String *buff, char *prefix, char *title)
{
- AddDef(buff, title, (char *)NULL);
+ char name[512];
+
+ snprintf(name, sizeof(name), "%s%s", prefix, title);
+ AddSimpleDef(buff, name);
}
static void
-AddDefTok(String *buff, char *prefix, char *title)
+AddDefHostname(String *buff, char *title, char *value)
{
char *s;
char name[512];
char c;
- snprintf(name, sizeof(name), "%s%s", prefix, title);
+ strncpy (name, value, sizeof(name)-1);
+ name[sizeof(name)-1] = '\0';
for (s = name; (c = *s); s++) {
- if (!isalpha(c) && !isdigit(c) && c != '_')
+ if (!isalpha(c) && !isdigit(c) && c != '_' && c != '.' && c != ':' && c != '-')
*s = '_';
}
- AddSimpleDef(buff, name);
+ AddDef(buff, title, name);
}
static void
@@ -502,7 +515,7 @@ AddUndef(String *buff, char *title)
addstring(buff, " -U");
} else
addstring(buff, "-U");
- addstring(buff, title);
+ addtokstring(buff, title);
}
static void
@@ -565,11 +578,11 @@ DoDisplayDefines(Display *display, String *defs, char *host)
}
if (!*server || !strcmp(server, "unix") || !strcmp(server, "localhost"))
strcpy(server, client);
- AddDef(defs, "HOST", server); /* R3 compatibility */
- AddDef(defs, "SERVERHOST", server);
+ AddDefHostname(defs, "HOST", server); /* R3 compatibility */
+ AddDefHostname(defs, "SERVERHOST", server);
AddDefTok(defs, "SRVR_", server);
AddNum(defs, "DISPLAY_NUM", n);
- AddDef(defs, "CLIENTHOST", client);
+ AddDefHostname(defs, "CLIENTHOST", client);
AddDefTok(defs, "CLNT_", client);
AddNum(defs, "VERSION", ProtocolVersion(display));
AddNum(defs, "REVISION", ProtocolRevision(display));
@@ -612,7 +625,7 @@ DoScreenDefines(Display *display, int scrno, String *defs)
AddNum(defs, "Y_RESOLUTION", Resolution(screen->height,screen->mheight));
AddNum(defs, "PLANES", DisplayPlanes(display, scrno));
AddNum(defs, "BITS_PER_RGB", visual->bits_per_rgb);
- AddDef(defs, "CLASS", ClassNames[visual->class]);
+ AddDefQ(defs, "CLASS", ClassNames[visual->class]);
snprintf(name, sizeof(name), "CLASS_%s", ClassNames[visual->class]);
AddNum(defs, name, (int)visual->visualid);
switch(visual->class) {
@@ -780,6 +793,40 @@ addstring(String *arg, const char *s)
arg->used += strlen(s);
}
+static void
+addescapedstring(String *arg, const char *s)
+{
+ char copy[512], *c;
+
+ for (c = copy; *s && c < ©[sizeof(copy)-1]; s++) {
+ switch (*s) {
+ case '"': case '\'': case '`':
+ case '$': case '\\':
+ *c++ = '_';
+ break;
+ default:
+ *c++ = *s;
+ }
+ }
+ *c = 0;
+ addstring (arg, copy);
+}
+
+static void
+addtokstring(String *arg, const char *s)
+{
+ char copy[512], *c;
+
+ for (c = copy; *s && c < ©[sizeof(copy)-1]; s++) {
+ if (!isalpha(*s) && !isdigit(*s) && *s != '_')
+ *c++ = '_';
+ else
+ *c++ = *s;
+ }
+ *c = 0;
+ addstring (arg, copy);
+}
+
int
main(int argc, char *argv[])
@@ -892,7 +939,7 @@ main(int argc, char *argv[])
continue;
} else if (arg[1] == 'I') {
addstring(&includes, " ");
- addstring(&includes, arg);
+ addescapedstring(&includes, arg);
continue;
} else if (arg[1] == 'U' || arg[1] == 'D') {
if (num_cmd_defines < MAX_CMD_DEFINES) {
|
CWE-20
| null | null |
4,017
|
InitBuffer(Buffer *b)
{
b->room = INIT_BUFFER_SIZE;
b->used = 0;
b->buff = (char *)malloc(INIT_BUFFER_SIZE*sizeof(char));
}
|
Exec Code
| 0
|
InitBuffer(Buffer *b)
{
b->room = INIT_BUFFER_SIZE;
b->used = 0;
b->buff = (char *)malloc(INIT_BUFFER_SIZE*sizeof(char));
}
|
@@ -142,6 +142,8 @@ static Entries newDB;
static void fatal(char *, ...);
static void addstring ( String *arg, const char *s );
+static void addescapedstring ( String *arg, const char *s );
+static void addtokstring ( String *arg, const char *s );
static void FormatEntries ( Buffer *buffer, Entries *entries );
static void StoreProperty ( Display *dpy, Window root, Atom res_prop );
static void Process ( int scrno, Bool doScreen, Bool execute );
@@ -433,14 +435,20 @@ AddDef(String *buff, char *title, char *value)
addstring(buff, " -D");
} else
addstring(buff, "-D");
- addstring(buff, title);
+ addtokstring(buff, title);
if (value && (value[0] != '\0')) {
addstring(buff, "=");
- addstring(buff, value);
+ addescapedstring(buff, value);
}
}
static void
+AddSimpleDef(String *buff, char *title)
+{
+ AddDef(buff, title, (char *)NULL);
+}
+
+static void
AddDefQ(String *buff, char *title, char *value)
{
#ifdef PATHETICCPP
@@ -449,8 +457,9 @@ AddDefQ(String *buff, char *title, char *value)
else
#endif
if (value && (value[0] != '\0')) {
- AddDef(buff, title, "\"");
- addstring(buff, value);
+ AddSimpleDef(buff, title);
+ addstring(buff, "=\"");
+ addescapedstring(buff, value);
addstring(buff, "\"");
} else
AddDef(buff, title, NULL);
@@ -465,24 +474,28 @@ AddNum(String *buff, char *title, int value)
}
static void
-AddSimpleDef(String *buff, char *title)
+AddDefTok(String *buff, char *prefix, char *title)
{
- AddDef(buff, title, (char *)NULL);
+ char name[512];
+
+ snprintf(name, sizeof(name), "%s%s", prefix, title);
+ AddSimpleDef(buff, name);
}
static void
-AddDefTok(String *buff, char *prefix, char *title)
+AddDefHostname(String *buff, char *title, char *value)
{
char *s;
char name[512];
char c;
- snprintf(name, sizeof(name), "%s%s", prefix, title);
+ strncpy (name, value, sizeof(name)-1);
+ name[sizeof(name)-1] = '\0';
for (s = name; (c = *s); s++) {
- if (!isalpha(c) && !isdigit(c) && c != '_')
+ if (!isalpha(c) && !isdigit(c) && c != '_' && c != '.' && c != ':' && c != '-')
*s = '_';
}
- AddSimpleDef(buff, name);
+ AddDef(buff, title, name);
}
static void
@@ -502,7 +515,7 @@ AddUndef(String *buff, char *title)
addstring(buff, " -U");
} else
addstring(buff, "-U");
- addstring(buff, title);
+ addtokstring(buff, title);
}
static void
@@ -565,11 +578,11 @@ DoDisplayDefines(Display *display, String *defs, char *host)
}
if (!*server || !strcmp(server, "unix") || !strcmp(server, "localhost"))
strcpy(server, client);
- AddDef(defs, "HOST", server); /* R3 compatibility */
- AddDef(defs, "SERVERHOST", server);
+ AddDefHostname(defs, "HOST", server); /* R3 compatibility */
+ AddDefHostname(defs, "SERVERHOST", server);
AddDefTok(defs, "SRVR_", server);
AddNum(defs, "DISPLAY_NUM", n);
- AddDef(defs, "CLIENTHOST", client);
+ AddDefHostname(defs, "CLIENTHOST", client);
AddDefTok(defs, "CLNT_", client);
AddNum(defs, "VERSION", ProtocolVersion(display));
AddNum(defs, "REVISION", ProtocolRevision(display));
@@ -612,7 +625,7 @@ DoScreenDefines(Display *display, int scrno, String *defs)
AddNum(defs, "Y_RESOLUTION", Resolution(screen->height,screen->mheight));
AddNum(defs, "PLANES", DisplayPlanes(display, scrno));
AddNum(defs, "BITS_PER_RGB", visual->bits_per_rgb);
- AddDef(defs, "CLASS", ClassNames[visual->class]);
+ AddDefQ(defs, "CLASS", ClassNames[visual->class]);
snprintf(name, sizeof(name), "CLASS_%s", ClassNames[visual->class]);
AddNum(defs, name, (int)visual->visualid);
switch(visual->class) {
@@ -780,6 +793,40 @@ addstring(String *arg, const char *s)
arg->used += strlen(s);
}
+static void
+addescapedstring(String *arg, const char *s)
+{
+ char copy[512], *c;
+
+ for (c = copy; *s && c < ©[sizeof(copy)-1]; s++) {
+ switch (*s) {
+ case '"': case '\'': case '`':
+ case '$': case '\\':
+ *c++ = '_';
+ break;
+ default:
+ *c++ = *s;
+ }
+ }
+ *c = 0;
+ addstring (arg, copy);
+}
+
+static void
+addtokstring(String *arg, const char *s)
+{
+ char copy[512], *c;
+
+ for (c = copy; *s && c < ©[sizeof(copy)-1]; s++) {
+ if (!isalpha(*s) && !isdigit(*s) && *s != '_')
+ *c++ = '_';
+ else
+ *c++ = *s;
+ }
+ *c = 0;
+ addstring (arg, copy);
+}
+
int
main(int argc, char *argv[])
@@ -892,7 +939,7 @@ main(int argc, char *argv[])
continue;
} else if (arg[1] == 'I') {
addstring(&includes, " ");
- addstring(&includes, arg);
+ addescapedstring(&includes, arg);
continue;
} else if (arg[1] == 'U' || arg[1] == 'D') {
if (num_cmd_defines < MAX_CMD_DEFINES) {
|
CWE-20
| null | null |
4,018
|
InitEntries(Entries *e)
{
e->room = INIT_ENTRY_SIZE;
e->used = 0;
e->entry = (Entry *)malloc(INIT_ENTRY_SIZE*sizeof(Entry));
}
|
Exec Code
| 0
|
InitEntries(Entries *e)
{
e->room = INIT_ENTRY_SIZE;
e->used = 0;
e->entry = (Entry *)malloc(INIT_ENTRY_SIZE*sizeof(Entry));
}
|
@@ -142,6 +142,8 @@ static Entries newDB;
static void fatal(char *, ...);
static void addstring ( String *arg, const char *s );
+static void addescapedstring ( String *arg, const char *s );
+static void addtokstring ( String *arg, const char *s );
static void FormatEntries ( Buffer *buffer, Entries *entries );
static void StoreProperty ( Display *dpy, Window root, Atom res_prop );
static void Process ( int scrno, Bool doScreen, Bool execute );
@@ -433,14 +435,20 @@ AddDef(String *buff, char *title, char *value)
addstring(buff, " -D");
} else
addstring(buff, "-D");
- addstring(buff, title);
+ addtokstring(buff, title);
if (value && (value[0] != '\0')) {
addstring(buff, "=");
- addstring(buff, value);
+ addescapedstring(buff, value);
}
}
static void
+AddSimpleDef(String *buff, char *title)
+{
+ AddDef(buff, title, (char *)NULL);
+}
+
+static void
AddDefQ(String *buff, char *title, char *value)
{
#ifdef PATHETICCPP
@@ -449,8 +457,9 @@ AddDefQ(String *buff, char *title, char *value)
else
#endif
if (value && (value[0] != '\0')) {
- AddDef(buff, title, "\"");
- addstring(buff, value);
+ AddSimpleDef(buff, title);
+ addstring(buff, "=\"");
+ addescapedstring(buff, value);
addstring(buff, "\"");
} else
AddDef(buff, title, NULL);
@@ -465,24 +474,28 @@ AddNum(String *buff, char *title, int value)
}
static void
-AddSimpleDef(String *buff, char *title)
+AddDefTok(String *buff, char *prefix, char *title)
{
- AddDef(buff, title, (char *)NULL);
+ char name[512];
+
+ snprintf(name, sizeof(name), "%s%s", prefix, title);
+ AddSimpleDef(buff, name);
}
static void
-AddDefTok(String *buff, char *prefix, char *title)
+AddDefHostname(String *buff, char *title, char *value)
{
char *s;
char name[512];
char c;
- snprintf(name, sizeof(name), "%s%s", prefix, title);
+ strncpy (name, value, sizeof(name)-1);
+ name[sizeof(name)-1] = '\0';
for (s = name; (c = *s); s++) {
- if (!isalpha(c) && !isdigit(c) && c != '_')
+ if (!isalpha(c) && !isdigit(c) && c != '_' && c != '.' && c != ':' && c != '-')
*s = '_';
}
- AddSimpleDef(buff, name);
+ AddDef(buff, title, name);
}
static void
@@ -502,7 +515,7 @@ AddUndef(String *buff, char *title)
addstring(buff, " -U");
} else
addstring(buff, "-U");
- addstring(buff, title);
+ addtokstring(buff, title);
}
static void
@@ -565,11 +578,11 @@ DoDisplayDefines(Display *display, String *defs, char *host)
}
if (!*server || !strcmp(server, "unix") || !strcmp(server, "localhost"))
strcpy(server, client);
- AddDef(defs, "HOST", server); /* R3 compatibility */
- AddDef(defs, "SERVERHOST", server);
+ AddDefHostname(defs, "HOST", server); /* R3 compatibility */
+ AddDefHostname(defs, "SERVERHOST", server);
AddDefTok(defs, "SRVR_", server);
AddNum(defs, "DISPLAY_NUM", n);
- AddDef(defs, "CLIENTHOST", client);
+ AddDefHostname(defs, "CLIENTHOST", client);
AddDefTok(defs, "CLNT_", client);
AddNum(defs, "VERSION", ProtocolVersion(display));
AddNum(defs, "REVISION", ProtocolRevision(display));
@@ -612,7 +625,7 @@ DoScreenDefines(Display *display, int scrno, String *defs)
AddNum(defs, "Y_RESOLUTION", Resolution(screen->height,screen->mheight));
AddNum(defs, "PLANES", DisplayPlanes(display, scrno));
AddNum(defs, "BITS_PER_RGB", visual->bits_per_rgb);
- AddDef(defs, "CLASS", ClassNames[visual->class]);
+ AddDefQ(defs, "CLASS", ClassNames[visual->class]);
snprintf(name, sizeof(name), "CLASS_%s", ClassNames[visual->class]);
AddNum(defs, name, (int)visual->visualid);
switch(visual->class) {
@@ -780,6 +793,40 @@ addstring(String *arg, const char *s)
arg->used += strlen(s);
}
+static void
+addescapedstring(String *arg, const char *s)
+{
+ char copy[512], *c;
+
+ for (c = copy; *s && c < ©[sizeof(copy)-1]; s++) {
+ switch (*s) {
+ case '"': case '\'': case '`':
+ case '$': case '\\':
+ *c++ = '_';
+ break;
+ default:
+ *c++ = *s;
+ }
+ }
+ *c = 0;
+ addstring (arg, copy);
+}
+
+static void
+addtokstring(String *arg, const char *s)
+{
+ char copy[512], *c;
+
+ for (c = copy; *s && c < ©[sizeof(copy)-1]; s++) {
+ if (!isalpha(*s) && !isdigit(*s) && *s != '_')
+ *c++ = '_';
+ else
+ *c++ = *s;
+ }
+ *c = 0;
+ addstring (arg, copy);
+}
+
int
main(int argc, char *argv[])
@@ -892,7 +939,7 @@ main(int argc, char *argv[])
continue;
} else if (arg[1] == 'I') {
addstring(&includes, " ");
- addstring(&includes, arg);
+ addescapedstring(&includes, arg);
continue;
} else if (arg[1] == 'U' || arg[1] == 'D') {
if (num_cmd_defines < MAX_CMD_DEFINES) {
|
CWE-20
| null | null |
4,019
|
ReadFile(Buffer *buffer, FILE *input)
{
char buf[BUFSIZ + 1];
register int bytes;
buffer->used = 0;
while (!feof(input) && (bytes = fread(buf, 1, BUFSIZ, input)) > 0) {
#ifdef WIN32
char *p;
buf[bytes] = '\0';
for (p = buf; p = strchr(p, '\r'); ) {
if (p[-1] == '\\' && p[1] == '\n') {
bytes -= 3;
strcpy(p - 1, p + 2);
}
}
#endif
AppendToBuffer(buffer, buf, bytes);
}
AppendToBuffer(buffer, "", 1);
}
|
Exec Code
| 0
|
ReadFile(Buffer *buffer, FILE *input)
{
char buf[BUFSIZ + 1];
register int bytes;
buffer->used = 0;
while (!feof(input) && (bytes = fread(buf, 1, BUFSIZ, input)) > 0) {
#ifdef WIN32
char *p;
buf[bytes] = '\0';
for (p = buf; p = strchr(p, '\r'); ) {
if (p[-1] == '\\' && p[1] == '\n') {
bytes -= 3;
strcpy(p - 1, p + 2);
}
}
#endif
AppendToBuffer(buffer, buf, bytes);
}
AppendToBuffer(buffer, "", 1);
}
|
@@ -142,6 +142,8 @@ static Entries newDB;
static void fatal(char *, ...);
static void addstring ( String *arg, const char *s );
+static void addescapedstring ( String *arg, const char *s );
+static void addtokstring ( String *arg, const char *s );
static void FormatEntries ( Buffer *buffer, Entries *entries );
static void StoreProperty ( Display *dpy, Window root, Atom res_prop );
static void Process ( int scrno, Bool doScreen, Bool execute );
@@ -433,14 +435,20 @@ AddDef(String *buff, char *title, char *value)
addstring(buff, " -D");
} else
addstring(buff, "-D");
- addstring(buff, title);
+ addtokstring(buff, title);
if (value && (value[0] != '\0')) {
addstring(buff, "=");
- addstring(buff, value);
+ addescapedstring(buff, value);
}
}
static void
+AddSimpleDef(String *buff, char *title)
+{
+ AddDef(buff, title, (char *)NULL);
+}
+
+static void
AddDefQ(String *buff, char *title, char *value)
{
#ifdef PATHETICCPP
@@ -449,8 +457,9 @@ AddDefQ(String *buff, char *title, char *value)
else
#endif
if (value && (value[0] != '\0')) {
- AddDef(buff, title, "\"");
- addstring(buff, value);
+ AddSimpleDef(buff, title);
+ addstring(buff, "=\"");
+ addescapedstring(buff, value);
addstring(buff, "\"");
} else
AddDef(buff, title, NULL);
@@ -465,24 +474,28 @@ AddNum(String *buff, char *title, int value)
}
static void
-AddSimpleDef(String *buff, char *title)
+AddDefTok(String *buff, char *prefix, char *title)
{
- AddDef(buff, title, (char *)NULL);
+ char name[512];
+
+ snprintf(name, sizeof(name), "%s%s", prefix, title);
+ AddSimpleDef(buff, name);
}
static void
-AddDefTok(String *buff, char *prefix, char *title)
+AddDefHostname(String *buff, char *title, char *value)
{
char *s;
char name[512];
char c;
- snprintf(name, sizeof(name), "%s%s", prefix, title);
+ strncpy (name, value, sizeof(name)-1);
+ name[sizeof(name)-1] = '\0';
for (s = name; (c = *s); s++) {
- if (!isalpha(c) && !isdigit(c) && c != '_')
+ if (!isalpha(c) && !isdigit(c) && c != '_' && c != '.' && c != ':' && c != '-')
*s = '_';
}
- AddSimpleDef(buff, name);
+ AddDef(buff, title, name);
}
static void
@@ -502,7 +515,7 @@ AddUndef(String *buff, char *title)
addstring(buff, " -U");
} else
addstring(buff, "-U");
- addstring(buff, title);
+ addtokstring(buff, title);
}
static void
@@ -565,11 +578,11 @@ DoDisplayDefines(Display *display, String *defs, char *host)
}
if (!*server || !strcmp(server, "unix") || !strcmp(server, "localhost"))
strcpy(server, client);
- AddDef(defs, "HOST", server); /* R3 compatibility */
- AddDef(defs, "SERVERHOST", server);
+ AddDefHostname(defs, "HOST", server); /* R3 compatibility */
+ AddDefHostname(defs, "SERVERHOST", server);
AddDefTok(defs, "SRVR_", server);
AddNum(defs, "DISPLAY_NUM", n);
- AddDef(defs, "CLIENTHOST", client);
+ AddDefHostname(defs, "CLIENTHOST", client);
AddDefTok(defs, "CLNT_", client);
AddNum(defs, "VERSION", ProtocolVersion(display));
AddNum(defs, "REVISION", ProtocolRevision(display));
@@ -612,7 +625,7 @@ DoScreenDefines(Display *display, int scrno, String *defs)
AddNum(defs, "Y_RESOLUTION", Resolution(screen->height,screen->mheight));
AddNum(defs, "PLANES", DisplayPlanes(display, scrno));
AddNum(defs, "BITS_PER_RGB", visual->bits_per_rgb);
- AddDef(defs, "CLASS", ClassNames[visual->class]);
+ AddDefQ(defs, "CLASS", ClassNames[visual->class]);
snprintf(name, sizeof(name), "CLASS_%s", ClassNames[visual->class]);
AddNum(defs, name, (int)visual->visualid);
switch(visual->class) {
@@ -780,6 +793,40 @@ addstring(String *arg, const char *s)
arg->used += strlen(s);
}
+static void
+addescapedstring(String *arg, const char *s)
+{
+ char copy[512], *c;
+
+ for (c = copy; *s && c < ©[sizeof(copy)-1]; s++) {
+ switch (*s) {
+ case '"': case '\'': case '`':
+ case '$': case '\\':
+ *c++ = '_';
+ break;
+ default:
+ *c++ = *s;
+ }
+ }
+ *c = 0;
+ addstring (arg, copy);
+}
+
+static void
+addtokstring(String *arg, const char *s)
+{
+ char copy[512], *c;
+
+ for (c = copy; *s && c < ©[sizeof(copy)-1]; s++) {
+ if (!isalpha(*s) && !isdigit(*s) && *s != '_')
+ *c++ = '_';
+ else
+ *c++ = *s;
+ }
+ *c = 0;
+ addstring (arg, copy);
+}
+
int
main(int argc, char *argv[])
@@ -892,7 +939,7 @@ main(int argc, char *argv[])
continue;
} else if (arg[1] == 'I') {
addstring(&includes, " ");
- addstring(&includes, arg);
+ addescapedstring(&includes, arg);
continue;
} else if (arg[1] == 'U' || arg[1] == 'D') {
if (num_cmd_defines < MAX_CMD_DEFINES) {
|
CWE-20
| null | null |
4,020
|
asprintf(char ** ret, const char *format, ...)
{
char buf[256];
int len;
va_list ap;
va_start(ap, format);
len = vsnprintf(buf, sizeof(buf), format, ap);
va_end(ap);
if (len < 0)
return -1;
if (len < sizeof(buf))
{
*ret = strdup(buf);
}
else
{
*ret = malloc(len + 1); /* snprintf doesn't count trailing '\0' */
if (*ret != NULL)
{
va_start(ap, format);
len = vsnprintf(*ret, len + 1, format, ap);
va_end(ap);
if (len < 0) {
free(*ret);
*ret = NULL;
}
}
}
if (*ret == NULL)
return -1;
return len;
}
|
Exec Code
| 0
|
asprintf(char ** ret, const char *format, ...)
{
char buf[256];
int len;
va_list ap;
va_start(ap, format);
len = vsnprintf(buf, sizeof(buf), format, ap);
va_end(ap);
if (len < 0)
return -1;
if (len < sizeof(buf))
{
*ret = strdup(buf);
}
else
{
*ret = malloc(len + 1); /* snprintf doesn't count trailing '\0' */
if (*ret != NULL)
{
va_start(ap, format);
len = vsnprintf(*ret, len + 1, format, ap);
va_end(ap);
if (len < 0) {
free(*ret);
*ret = NULL;
}
}
}
if (*ret == NULL)
return -1;
return len;
}
|
@@ -142,6 +142,8 @@ static Entries newDB;
static void fatal(char *, ...);
static void addstring ( String *arg, const char *s );
+static void addescapedstring ( String *arg, const char *s );
+static void addtokstring ( String *arg, const char *s );
static void FormatEntries ( Buffer *buffer, Entries *entries );
static void StoreProperty ( Display *dpy, Window root, Atom res_prop );
static void Process ( int scrno, Bool doScreen, Bool execute );
@@ -433,14 +435,20 @@ AddDef(String *buff, char *title, char *value)
addstring(buff, " -D");
} else
addstring(buff, "-D");
- addstring(buff, title);
+ addtokstring(buff, title);
if (value && (value[0] != '\0')) {
addstring(buff, "=");
- addstring(buff, value);
+ addescapedstring(buff, value);
}
}
static void
+AddSimpleDef(String *buff, char *title)
+{
+ AddDef(buff, title, (char *)NULL);
+}
+
+static void
AddDefQ(String *buff, char *title, char *value)
{
#ifdef PATHETICCPP
@@ -449,8 +457,9 @@ AddDefQ(String *buff, char *title, char *value)
else
#endif
if (value && (value[0] != '\0')) {
- AddDef(buff, title, "\"");
- addstring(buff, value);
+ AddSimpleDef(buff, title);
+ addstring(buff, "=\"");
+ addescapedstring(buff, value);
addstring(buff, "\"");
} else
AddDef(buff, title, NULL);
@@ -465,24 +474,28 @@ AddNum(String *buff, char *title, int value)
}
static void
-AddSimpleDef(String *buff, char *title)
+AddDefTok(String *buff, char *prefix, char *title)
{
- AddDef(buff, title, (char *)NULL);
+ char name[512];
+
+ snprintf(name, sizeof(name), "%s%s", prefix, title);
+ AddSimpleDef(buff, name);
}
static void
-AddDefTok(String *buff, char *prefix, char *title)
+AddDefHostname(String *buff, char *title, char *value)
{
char *s;
char name[512];
char c;
- snprintf(name, sizeof(name), "%s%s", prefix, title);
+ strncpy (name, value, sizeof(name)-1);
+ name[sizeof(name)-1] = '\0';
for (s = name; (c = *s); s++) {
- if (!isalpha(c) && !isdigit(c) && c != '_')
+ if (!isalpha(c) && !isdigit(c) && c != '_' && c != '.' && c != ':' && c != '-')
*s = '_';
}
- AddSimpleDef(buff, name);
+ AddDef(buff, title, name);
}
static void
@@ -502,7 +515,7 @@ AddUndef(String *buff, char *title)
addstring(buff, " -U");
} else
addstring(buff, "-U");
- addstring(buff, title);
+ addtokstring(buff, title);
}
static void
@@ -565,11 +578,11 @@ DoDisplayDefines(Display *display, String *defs, char *host)
}
if (!*server || !strcmp(server, "unix") || !strcmp(server, "localhost"))
strcpy(server, client);
- AddDef(defs, "HOST", server); /* R3 compatibility */
- AddDef(defs, "SERVERHOST", server);
+ AddDefHostname(defs, "HOST", server); /* R3 compatibility */
+ AddDefHostname(defs, "SERVERHOST", server);
AddDefTok(defs, "SRVR_", server);
AddNum(defs, "DISPLAY_NUM", n);
- AddDef(defs, "CLIENTHOST", client);
+ AddDefHostname(defs, "CLIENTHOST", client);
AddDefTok(defs, "CLNT_", client);
AddNum(defs, "VERSION", ProtocolVersion(display));
AddNum(defs, "REVISION", ProtocolRevision(display));
@@ -612,7 +625,7 @@ DoScreenDefines(Display *display, int scrno, String *defs)
AddNum(defs, "Y_RESOLUTION", Resolution(screen->height,screen->mheight));
AddNum(defs, "PLANES", DisplayPlanes(display, scrno));
AddNum(defs, "BITS_PER_RGB", visual->bits_per_rgb);
- AddDef(defs, "CLASS", ClassNames[visual->class]);
+ AddDefQ(defs, "CLASS", ClassNames[visual->class]);
snprintf(name, sizeof(name), "CLASS_%s", ClassNames[visual->class]);
AddNum(defs, name, (int)visual->visualid);
switch(visual->class) {
@@ -780,6 +793,40 @@ addstring(String *arg, const char *s)
arg->used += strlen(s);
}
+static void
+addescapedstring(String *arg, const char *s)
+{
+ char copy[512], *c;
+
+ for (c = copy; *s && c < ©[sizeof(copy)-1]; s++) {
+ switch (*s) {
+ case '"': case '\'': case '`':
+ case '$': case '\\':
+ *c++ = '_';
+ break;
+ default:
+ *c++ = *s;
+ }
+ }
+ *c = 0;
+ addstring (arg, copy);
+}
+
+static void
+addtokstring(String *arg, const char *s)
+{
+ char copy[512], *c;
+
+ for (c = copy; *s && c < ©[sizeof(copy)-1]; s++) {
+ if (!isalpha(*s) && !isdigit(*s) && *s != '_')
+ *c++ = '_';
+ else
+ *c++ = *s;
+ }
+ *c = 0;
+ addstring (arg, copy);
+}
+
int
main(int argc, char *argv[])
@@ -892,7 +939,7 @@ main(int argc, char *argv[])
continue;
} else if (arg[1] == 'I') {
addstring(&includes, " ");
- addstring(&includes, arg);
+ addescapedstring(&includes, arg);
continue;
} else if (arg[1] == 'U' || arg[1] == 'D') {
if (num_cmd_defines < MAX_CMD_DEFINES) {
|
CWE-20
| null | null |
4,021
|
PHP_FUNCTION(curl_version)
{
curl_version_info_data *d;
zend_long uversion = CURLVERSION_NOW;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &uversion) == FAILURE) {
return;
}
d = curl_version_info(uversion);
if (d == NULL) {
RETURN_FALSE;
}
array_init(return_value);
CAAL("version_number", d->version_num);
CAAL("age", d->age);
CAAL("features", d->features);
CAAL("ssl_version_number", d->ssl_version_num);
CAAS("version", d->version);
CAAS("host", d->host);
CAAS("ssl_version", d->ssl_version);
CAAS("libz_version", d->libz_version);
/* Add an array of protocols */
{
char **p = (char **) d->protocols;
zval protocol_list;
array_init(&protocol_list);
while (*p != NULL) {
add_next_index_string(&protocol_list, *p);
p++;
}
CAAZ("protocols", &protocol_list);
}
}
|
DoS
| 0
|
PHP_FUNCTION(curl_version)
{
curl_version_info_data *d;
zend_long uversion = CURLVERSION_NOW;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &uversion) == FAILURE) {
return;
}
d = curl_version_info(uversion);
if (d == NULL) {
RETURN_FALSE;
}
array_init(return_value);
CAAL("version_number", d->version_num);
CAAL("age", d->age);
CAAL("features", d->features);
CAAL("ssl_version_number", d->ssl_version_num);
CAAS("version", d->version);
CAAS("host", d->host);
CAAS("ssl_version", d->ssl_version);
CAAS("libz_version", d->libz_version);
/* Add an array of protocols */
{
char **p = (char **) d->protocols;
zval protocol_list;
array_init(&protocol_list);
while (*p != NULL) {
add_next_index_string(&protocol_list, *p);
p++;
}
CAAZ("protocols", &protocol_list);
}
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,022
|
PHP_FUNCTION(curl_init)
{
php_curl *ch;
CURL *cp;
char *url = NULL;
size_t url_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &url, &url_len) == FAILURE) {
return;
}
cp = curl_easy_init();
if (!cp) {
php_error_docref(NULL, E_WARNING, "Could not initialize a new cURL handle");
RETURN_FALSE;
}
ch = alloc_curl_handle();
ch->cp = cp;
ch->handlers->write->method = PHP_CURL_STDOUT;
ch->handlers->read->method = PHP_CURL_DIRECT;
ch->handlers->write_header->method = PHP_CURL_IGNORE;
_php_curl_set_default_options(ch);
if (url) {
if (php_curl_option_url(ch, url, url_len) == FAILURE) {
_php_curl_close_ex(ch);
RETURN_FALSE;
}
}
ZEND_REGISTER_RESOURCE(return_value, ch, le_curl);
ch->res = Z_RES_P(return_value);
}
|
DoS
| 0
|
PHP_FUNCTION(curl_init)
{
php_curl *ch;
CURL *cp;
char *url = NULL;
size_t url_len = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &url, &url_len) == FAILURE) {
return;
}
cp = curl_easy_init();
if (!cp) {
php_error_docref(NULL, E_WARNING, "Could not initialize a new cURL handle");
RETURN_FALSE;
}
ch = alloc_curl_handle();
ch->cp = cp;
ch->handlers->write->method = PHP_CURL_STDOUT;
ch->handlers->read->method = PHP_CURL_DIRECT;
ch->handlers->write_header->method = PHP_CURL_IGNORE;
_php_curl_set_default_options(ch);
if (url) {
if (php_curl_option_url(ch, url, url_len) == FAILURE) {
_php_curl_close_ex(ch);
RETURN_FALSE;
}
}
ZEND_REGISTER_RESOURCE(return_value, ch, le_curl);
ch->res = Z_RES_P(return_value);
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,023
|
PHP_FUNCTION(curl_copy_handle)
{
CURL *cp;
zval *zid;
php_curl *ch, *dupch;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &zid) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
cp = curl_easy_duphandle(ch->cp);
if (!cp) {
php_error_docref(NULL, E_WARNING, "Cannot duplicate cURL handle");
RETURN_FALSE;
}
dupch = alloc_curl_handle();
dupch->cp = cp;
Z_ADDREF_P(zid);
if (!Z_ISUNDEF(ch->handlers->write->stream)) {
Z_ADDREF(ch->handlers->write->stream);
}
dupch->handlers->write->stream = ch->handlers->write->stream;
dupch->handlers->write->method = ch->handlers->write->method;
if (!Z_ISUNDEF(ch->handlers->read->stream)) {
Z_ADDREF(ch->handlers->read->stream);
}
dupch->handlers->read->stream = ch->handlers->read->stream;
dupch->handlers->read->method = ch->handlers->read->method;
dupch->handlers->write_header->method = ch->handlers->write_header->method;
if (!Z_ISUNDEF(ch->handlers->write_header->stream)) {
Z_ADDREF(ch->handlers->write_header->stream);
}
dupch->handlers->write_header->stream = ch->handlers->write_header->stream;
dupch->handlers->write->fp = ch->handlers->write->fp;
dupch->handlers->write_header->fp = ch->handlers->write_header->fp;
dupch->handlers->read->fp = ch->handlers->read->fp;
dupch->handlers->read->res = ch->handlers->read->res;
#if CURLOPT_PASSWDDATA != 0
if (!Z_ISUNDEF(ch->handlers->passwd)) {
ZVAL_COPY(&dupch->handlers->passwd, &ch->handlers->passwd);
curl_easy_setopt(ch->cp, CURLOPT_PASSWDDATA, (void *) dupch);
}
#endif
if (!Z_ISUNDEF(ch->handlers->write->func_name)) {
ZVAL_COPY(&dupch->handlers->write->func_name, &ch->handlers->write->func_name);
}
if (!Z_ISUNDEF(ch->handlers->read->func_name)) {
ZVAL_COPY(&dupch->handlers->read->func_name, &ch->handlers->read->func_name);
}
if (!Z_ISUNDEF(ch->handlers->write_header->func_name)) {
ZVAL_COPY(&dupch->handlers->write_header->func_name, &ch->handlers->write_header->func_name);
}
curl_easy_setopt(dupch->cp, CURLOPT_ERRORBUFFER, dupch->err.str);
curl_easy_setopt(dupch->cp, CURLOPT_FILE, (void *) dupch);
curl_easy_setopt(dupch->cp, CURLOPT_INFILE, (void *) dupch);
curl_easy_setopt(dupch->cp, CURLOPT_WRITEHEADER, (void *) dupch);
if (ch->handlers->progress) {
dupch->handlers->progress = ecalloc(1, sizeof(php_curl_progress));
if (!Z_ISUNDEF(ch->handlers->progress->func_name)) {
ZVAL_COPY(&dupch->handlers->progress->func_name, &ch->handlers->progress->func_name);
}
dupch->handlers->progress->method = ch->handlers->progress->method;
curl_easy_setopt(dupch->cp, CURLOPT_PROGRESSDATA, (void *) dupch);
}
/* Available since 7.21.0 */
#if LIBCURL_VERSION_NUM >= 0x071500
if (ch->handlers->fnmatch) {
dupch->handlers->fnmatch = ecalloc(1, sizeof(php_curl_fnmatch));
if (!Z_ISUNDEF(ch->handlers->fnmatch->func_name)) {
ZVAL_COPY(&dupch->handlers->fnmatch->func_name, &ch->handlers->fnmatch->func_name);
}
dupch->handlers->fnmatch->method = ch->handlers->fnmatch->method;
curl_easy_setopt(dupch->cp, CURLOPT_FNMATCH_DATA, (void *) dupch);
}
#endif
efree(dupch->to_free->slist);
efree(dupch->to_free);
dupch->to_free = ch->to_free;
/* Keep track of cloned copies to avoid invoking curl destructors for every clone */
ch->clone++;
ZEND_REGISTER_RESOURCE(return_value, dupch, le_curl);
dupch->res = Z_RES_P(return_value);
}
|
DoS
| 0
|
PHP_FUNCTION(curl_copy_handle)
{
CURL *cp;
zval *zid;
php_curl *ch, *dupch;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &zid) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
cp = curl_easy_duphandle(ch->cp);
if (!cp) {
php_error_docref(NULL, E_WARNING, "Cannot duplicate cURL handle");
RETURN_FALSE;
}
dupch = alloc_curl_handle();
dupch->cp = cp;
Z_ADDREF_P(zid);
if (!Z_ISUNDEF(ch->handlers->write->stream)) {
Z_ADDREF(ch->handlers->write->stream);
}
dupch->handlers->write->stream = ch->handlers->write->stream;
dupch->handlers->write->method = ch->handlers->write->method;
if (!Z_ISUNDEF(ch->handlers->read->stream)) {
Z_ADDREF(ch->handlers->read->stream);
}
dupch->handlers->read->stream = ch->handlers->read->stream;
dupch->handlers->read->method = ch->handlers->read->method;
dupch->handlers->write_header->method = ch->handlers->write_header->method;
if (!Z_ISUNDEF(ch->handlers->write_header->stream)) {
Z_ADDREF(ch->handlers->write_header->stream);
}
dupch->handlers->write_header->stream = ch->handlers->write_header->stream;
dupch->handlers->write->fp = ch->handlers->write->fp;
dupch->handlers->write_header->fp = ch->handlers->write_header->fp;
dupch->handlers->read->fp = ch->handlers->read->fp;
dupch->handlers->read->res = ch->handlers->read->res;
#if CURLOPT_PASSWDDATA != 0
if (!Z_ISUNDEF(ch->handlers->passwd)) {
ZVAL_COPY(&dupch->handlers->passwd, &ch->handlers->passwd);
curl_easy_setopt(ch->cp, CURLOPT_PASSWDDATA, (void *) dupch);
}
#endif
if (!Z_ISUNDEF(ch->handlers->write->func_name)) {
ZVAL_COPY(&dupch->handlers->write->func_name, &ch->handlers->write->func_name);
}
if (!Z_ISUNDEF(ch->handlers->read->func_name)) {
ZVAL_COPY(&dupch->handlers->read->func_name, &ch->handlers->read->func_name);
}
if (!Z_ISUNDEF(ch->handlers->write_header->func_name)) {
ZVAL_COPY(&dupch->handlers->write_header->func_name, &ch->handlers->write_header->func_name);
}
curl_easy_setopt(dupch->cp, CURLOPT_ERRORBUFFER, dupch->err.str);
curl_easy_setopt(dupch->cp, CURLOPT_FILE, (void *) dupch);
curl_easy_setopt(dupch->cp, CURLOPT_INFILE, (void *) dupch);
curl_easy_setopt(dupch->cp, CURLOPT_WRITEHEADER, (void *) dupch);
if (ch->handlers->progress) {
dupch->handlers->progress = ecalloc(1, sizeof(php_curl_progress));
if (!Z_ISUNDEF(ch->handlers->progress->func_name)) {
ZVAL_COPY(&dupch->handlers->progress->func_name, &ch->handlers->progress->func_name);
}
dupch->handlers->progress->method = ch->handlers->progress->method;
curl_easy_setopt(dupch->cp, CURLOPT_PROGRESSDATA, (void *) dupch);
}
/* Available since 7.21.0 */
#if LIBCURL_VERSION_NUM >= 0x071500
if (ch->handlers->fnmatch) {
dupch->handlers->fnmatch = ecalloc(1, sizeof(php_curl_fnmatch));
if (!Z_ISUNDEF(ch->handlers->fnmatch->func_name)) {
ZVAL_COPY(&dupch->handlers->fnmatch->func_name, &ch->handlers->fnmatch->func_name);
}
dupch->handlers->fnmatch->method = ch->handlers->fnmatch->method;
curl_easy_setopt(dupch->cp, CURLOPT_FNMATCH_DATA, (void *) dupch);
}
#endif
efree(dupch->to_free->slist);
efree(dupch->to_free);
dupch->to_free = ch->to_free;
/* Keep track of cloned copies to avoid invoking curl destructors for every clone */
ch->clone++;
ZEND_REGISTER_RESOURCE(return_value, dupch, le_curl);
dupch->res = Z_RES_P(return_value);
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,024
|
PHP_FUNCTION(curl_setopt)
{
zval *zid, *zvalue;
zend_long options;
php_curl *ch;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlz", &zid, &options, &zvalue) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
if (options <= 0 && options != CURLOPT_SAFE_UPLOAD) {
php_error_docref(NULL, E_WARNING, "Invalid curl configuration option");
RETURN_FALSE;
}
if (_php_curl_setopt(ch, options, zvalue) == SUCCESS) {
RETURN_TRUE;
} else {
RETURN_FALSE;
}
}
|
DoS
| 0
|
PHP_FUNCTION(curl_setopt)
{
zval *zid, *zvalue;
zend_long options;
php_curl *ch;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rlz", &zid, &options, &zvalue) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
if (options <= 0 && options != CURLOPT_SAFE_UPLOAD) {
php_error_docref(NULL, E_WARNING, "Invalid curl configuration option");
RETURN_FALSE;
}
if (_php_curl_setopt(ch, options, zvalue) == SUCCESS) {
RETURN_TRUE;
} else {
RETURN_FALSE;
}
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,025
|
PHP_FUNCTION(curl_getinfo)
{
zval *zid;
php_curl *ch;
zend_long option = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l", &zid, &option) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
if (ZEND_NUM_ARGS() < 2) {
char *s_code;
zend_long l_code;
double d_code;
#if LIBCURL_VERSION_NUM > 0x071301
struct curl_certinfo *ci = NULL;
zval listcode;
#endif
array_init(return_value);
if (curl_easy_getinfo(ch->cp, CURLINFO_EFFECTIVE_URL, &s_code) == CURLE_OK) {
CAAS("url", s_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_TYPE, &s_code) == CURLE_OK) {
if (s_code != NULL) {
CAAS("content_type", s_code);
} else {
zval retnull;
ZVAL_NULL(&retnull);
CAAZ("content_type", &retnull);
}
}
if (curl_easy_getinfo(ch->cp, CURLINFO_HTTP_CODE, &l_code) == CURLE_OK) {
CAAL("http_code", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_HEADER_SIZE, &l_code) == CURLE_OK) {
CAAL("header_size", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_REQUEST_SIZE, &l_code) == CURLE_OK) {
CAAL("request_size", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_FILETIME, &l_code) == CURLE_OK) {
CAAL("filetime", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_SSL_VERIFYRESULT, &l_code) == CURLE_OK) {
CAAL("ssl_verify_result", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_COUNT, &l_code) == CURLE_OK) {
CAAL("redirect_count", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_TOTAL_TIME, &d_code) == CURLE_OK) {
CAAD("total_time", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_NAMELOOKUP_TIME, &d_code) == CURLE_OK) {
CAAD("namelookup_time", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_CONNECT_TIME, &d_code) == CURLE_OK) {
CAAD("connect_time", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_PRETRANSFER_TIME, &d_code) == CURLE_OK) {
CAAD("pretransfer_time", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_SIZE_UPLOAD, &d_code) == CURLE_OK) {
CAAD("size_upload", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_SIZE_DOWNLOAD, &d_code) == CURLE_OK) {
CAAD("size_download", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_SPEED_DOWNLOAD, &d_code) == CURLE_OK) {
CAAD("speed_download", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_SPEED_UPLOAD, &d_code) == CURLE_OK) {
CAAD("speed_upload", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d_code) == CURLE_OK) {
CAAD("download_content_length", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_LENGTH_UPLOAD, &d_code) == CURLE_OK) {
CAAD("upload_content_length", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_STARTTRANSFER_TIME, &d_code) == CURLE_OK) {
CAAD("starttransfer_time", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_TIME, &d_code) == CURLE_OK) {
CAAD("redirect_time", d_code);
}
#if LIBCURL_VERSION_NUM >= 0x071202 /* Available since 7.18.2 */
if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_URL, &s_code) == CURLE_OK) {
CAAS("redirect_url", s_code);
}
#endif
#if LIBCURL_VERSION_NUM >= 0x071300 /* Available since 7.19.0 */
if (curl_easy_getinfo(ch->cp, CURLINFO_PRIMARY_IP, &s_code) == CURLE_OK) {
CAAS("primary_ip", s_code);
}
#endif
#if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */
if (curl_easy_getinfo(ch->cp, CURLINFO_CERTINFO, &ci) == CURLE_OK) {
array_init(&listcode);
create_certinfo(ci, &listcode);
CAAZ("certinfo", &listcode);
}
#endif
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
if (curl_easy_getinfo(ch->cp, CURLINFO_PRIMARY_PORT, &l_code) == CURLE_OK) {
CAAL("primary_port", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_LOCAL_IP, &s_code) == CURLE_OK) {
CAAS("local_ip", s_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_LOCAL_PORT, &l_code) == CURLE_OK) {
CAAL("local_port", l_code);
}
#endif
if (ch->header.str) {
CAASTR("request_header", ch->header.str);
}
} else {
switch (option) {
case CURLINFO_HEADER_OUT:
if (ch->header.str) {
RETURN_STR(zend_string_copy(ch->header.str));
} else {
RETURN_FALSE;
}
#if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */
case CURLINFO_CERTINFO: {
struct curl_certinfo *ci = NULL;
array_init(return_value);
if (curl_easy_getinfo(ch->cp, CURLINFO_CERTINFO, &ci) == CURLE_OK) {
create_certinfo(ci, return_value);
} else {
RETURN_FALSE;
}
break;
}
#endif
default: {
int type = CURLINFO_TYPEMASK & option;
switch (type) {
case CURLINFO_STRING:
{
char *s_code = NULL;
if (curl_easy_getinfo(ch->cp, option, &s_code) == CURLE_OK && s_code) {
RETURN_STRING(s_code);
} else {
RETURN_FALSE;
}
break;
}
case CURLINFO_LONG:
{
zend_long code = 0;
if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) {
RETURN_LONG(code);
} else {
RETURN_FALSE;
}
break;
}
case CURLINFO_DOUBLE:
{
double code = 0.0;
if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) {
RETURN_DOUBLE(code);
} else {
RETURN_FALSE;
}
break;
}
#if LIBCURL_VERSION_NUM >= 0x070c03 /* Available since 7.12.3 */
case CURLINFO_SLIST:
{
struct curl_slist *slist;
array_init(return_value);
if (curl_easy_getinfo(ch->cp, option, &slist) == CURLE_OK) {
while (slist) {
add_next_index_string(return_value, slist->data);
slist = slist->next;
}
curl_slist_free_all(slist);
} else {
RETURN_FALSE;
}
break;
}
#endif
default:
RETURN_FALSE;
}
}
}
}
}
|
DoS
| 0
|
PHP_FUNCTION(curl_getinfo)
{
zval *zid;
php_curl *ch;
zend_long option = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r|l", &zid, &option) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
if (ZEND_NUM_ARGS() < 2) {
char *s_code;
zend_long l_code;
double d_code;
#if LIBCURL_VERSION_NUM > 0x071301
struct curl_certinfo *ci = NULL;
zval listcode;
#endif
array_init(return_value);
if (curl_easy_getinfo(ch->cp, CURLINFO_EFFECTIVE_URL, &s_code) == CURLE_OK) {
CAAS("url", s_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_TYPE, &s_code) == CURLE_OK) {
if (s_code != NULL) {
CAAS("content_type", s_code);
} else {
zval retnull;
ZVAL_NULL(&retnull);
CAAZ("content_type", &retnull);
}
}
if (curl_easy_getinfo(ch->cp, CURLINFO_HTTP_CODE, &l_code) == CURLE_OK) {
CAAL("http_code", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_HEADER_SIZE, &l_code) == CURLE_OK) {
CAAL("header_size", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_REQUEST_SIZE, &l_code) == CURLE_OK) {
CAAL("request_size", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_FILETIME, &l_code) == CURLE_OK) {
CAAL("filetime", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_SSL_VERIFYRESULT, &l_code) == CURLE_OK) {
CAAL("ssl_verify_result", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_COUNT, &l_code) == CURLE_OK) {
CAAL("redirect_count", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_TOTAL_TIME, &d_code) == CURLE_OK) {
CAAD("total_time", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_NAMELOOKUP_TIME, &d_code) == CURLE_OK) {
CAAD("namelookup_time", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_CONNECT_TIME, &d_code) == CURLE_OK) {
CAAD("connect_time", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_PRETRANSFER_TIME, &d_code) == CURLE_OK) {
CAAD("pretransfer_time", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_SIZE_UPLOAD, &d_code) == CURLE_OK) {
CAAD("size_upload", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_SIZE_DOWNLOAD, &d_code) == CURLE_OK) {
CAAD("size_download", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_SPEED_DOWNLOAD, &d_code) == CURLE_OK) {
CAAD("speed_download", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_SPEED_UPLOAD, &d_code) == CURLE_OK) {
CAAD("speed_upload", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d_code) == CURLE_OK) {
CAAD("download_content_length", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_CONTENT_LENGTH_UPLOAD, &d_code) == CURLE_OK) {
CAAD("upload_content_length", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_STARTTRANSFER_TIME, &d_code) == CURLE_OK) {
CAAD("starttransfer_time", d_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_TIME, &d_code) == CURLE_OK) {
CAAD("redirect_time", d_code);
}
#if LIBCURL_VERSION_NUM >= 0x071202 /* Available since 7.18.2 */
if (curl_easy_getinfo(ch->cp, CURLINFO_REDIRECT_URL, &s_code) == CURLE_OK) {
CAAS("redirect_url", s_code);
}
#endif
#if LIBCURL_VERSION_NUM >= 0x071300 /* Available since 7.19.0 */
if (curl_easy_getinfo(ch->cp, CURLINFO_PRIMARY_IP, &s_code) == CURLE_OK) {
CAAS("primary_ip", s_code);
}
#endif
#if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */
if (curl_easy_getinfo(ch->cp, CURLINFO_CERTINFO, &ci) == CURLE_OK) {
array_init(&listcode);
create_certinfo(ci, &listcode);
CAAZ("certinfo", &listcode);
}
#endif
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
if (curl_easy_getinfo(ch->cp, CURLINFO_PRIMARY_PORT, &l_code) == CURLE_OK) {
CAAL("primary_port", l_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_LOCAL_IP, &s_code) == CURLE_OK) {
CAAS("local_ip", s_code);
}
if (curl_easy_getinfo(ch->cp, CURLINFO_LOCAL_PORT, &l_code) == CURLE_OK) {
CAAL("local_port", l_code);
}
#endif
if (ch->header.str) {
CAASTR("request_header", ch->header.str);
}
} else {
switch (option) {
case CURLINFO_HEADER_OUT:
if (ch->header.str) {
RETURN_STR(zend_string_copy(ch->header.str));
} else {
RETURN_FALSE;
}
#if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */
case CURLINFO_CERTINFO: {
struct curl_certinfo *ci = NULL;
array_init(return_value);
if (curl_easy_getinfo(ch->cp, CURLINFO_CERTINFO, &ci) == CURLE_OK) {
create_certinfo(ci, return_value);
} else {
RETURN_FALSE;
}
break;
}
#endif
default: {
int type = CURLINFO_TYPEMASK & option;
switch (type) {
case CURLINFO_STRING:
{
char *s_code = NULL;
if (curl_easy_getinfo(ch->cp, option, &s_code) == CURLE_OK && s_code) {
RETURN_STRING(s_code);
} else {
RETURN_FALSE;
}
break;
}
case CURLINFO_LONG:
{
zend_long code = 0;
if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) {
RETURN_LONG(code);
} else {
RETURN_FALSE;
}
break;
}
case CURLINFO_DOUBLE:
{
double code = 0.0;
if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) {
RETURN_DOUBLE(code);
} else {
RETURN_FALSE;
}
break;
}
#if LIBCURL_VERSION_NUM >= 0x070c03 /* Available since 7.12.3 */
case CURLINFO_SLIST:
{
struct curl_slist *slist;
array_init(return_value);
if (curl_easy_getinfo(ch->cp, option, &slist) == CURLE_OK) {
while (slist) {
add_next_index_string(return_value, slist->data);
slist = slist->next;
}
curl_slist_free_all(slist);
} else {
RETURN_FALSE;
}
break;
}
#endif
default:
RETURN_FALSE;
}
}
}
}
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,026
|
PHP_FUNCTION(curl_error)
{
zval *zid;
php_curl *ch;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &zid) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
ch->err.str[CURL_ERROR_SIZE] = 0;
RETURN_STRING(ch->err.str);
}
|
DoS
| 0
|
PHP_FUNCTION(curl_error)
{
zval *zid;
php_curl *ch;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &zid) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
ch->err.str[CURL_ERROR_SIZE] = 0;
RETURN_STRING(ch->err.str);
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,027
|
PHP_FUNCTION(curl_errno)
{
zval *zid;
php_curl *ch;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &zid) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
RETURN_LONG(ch->err.no);
}
|
DoS
| 0
|
PHP_FUNCTION(curl_errno)
{
zval *zid;
php_curl *ch;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &zid) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
RETURN_LONG(ch->err.no);
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,028
|
PHP_FUNCTION(curl_strerror)
{
zend_long code;
const char *str;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &code) == FAILURE) {
return;
}
str = curl_easy_strerror(code);
if (str) {
RETURN_STRING(str);
} else {
RETURN_NULL();
}
}
|
DoS
| 0
|
PHP_FUNCTION(curl_strerror)
{
zend_long code;
const char *str;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &code) == FAILURE) {
return;
}
str = curl_easy_strerror(code);
if (str) {
RETURN_STRING(str);
} else {
RETURN_NULL();
}
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,029
|
PHP_FUNCTION(curl_escape)
{
char *str = NULL, *res = NULL;
size_t str_len = 0;
zval *zid;
php_curl *ch;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs", &zid, &str, &str_len) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
if ((res = curl_easy_escape(ch->cp, str, str_len))) {
RETVAL_STRING(res);
curl_free(res);
} else {
RETURN_FALSE;
}
}
|
DoS
| 0
|
PHP_FUNCTION(curl_escape)
{
char *str = NULL, *res = NULL;
size_t str_len = 0;
zval *zid;
php_curl *ch;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs", &zid, &str, &str_len) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
if ((res = curl_easy_escape(ch->cp, str, str_len))) {
RETVAL_STRING(res);
curl_free(res);
} else {
RETURN_FALSE;
}
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,030
|
PHP_FUNCTION(curl_unescape)
{
char *str = NULL, *out = NULL;
int str_len = 0, out_len;
zval *zid;
php_curl *ch;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs", &zid, &str, &str_len) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
if ((out = curl_easy_unescape(ch->cp, str, str_len, &out_len))) {
RETVAL_STRINGL(out, out_len);
curl_free(out);
} else {
RETURN_FALSE;
}
}
|
DoS
| 0
|
PHP_FUNCTION(curl_unescape)
{
char *str = NULL, *out = NULL;
int str_len = 0, out_len;
zval *zid;
php_curl *ch;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs", &zid, &str, &str_len) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
if ((out = curl_easy_unescape(ch->cp, str, str_len, &out_len))) {
RETVAL_STRINGL(out, out_len);
curl_free(out);
} else {
RETURN_FALSE;
}
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,031
|
PHP_FUNCTION(curl_pause)
{
zend_long bitmask;
zval *zid;
php_curl *ch;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &zid, &bitmask) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
RETURN_LONG(curl_easy_pause(ch->cp, bitmask));
}
|
DoS
| 0
|
PHP_FUNCTION(curl_pause)
{
zend_long bitmask;
zval *zid;
php_curl *ch;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &zid, &bitmask) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(ch, php_curl *, zid, -1, le_curl_name, le_curl);
RETURN_LONG(curl_easy_pause(ch->cp, bitmask));
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,032
|
PHP_MINFO_FUNCTION(curl)
{
curl_version_info_data *d;
char **p;
char str[1024];
size_t n = 0;
d = curl_version_info(CURLVERSION_NOW);
php_info_print_table_start();
php_info_print_table_row(2, "cURL support", "enabled");
php_info_print_table_row(2, "cURL Information", d->version);
sprintf(str, "%d", d->age);
php_info_print_table_row(2, "Age", str);
/* To update on each new cURL release using src/main.c in cURL sources */
if (d->features) {
struct feat {
const char *name;
int bitmask;
};
unsigned int i;
static const struct feat feats[] = {
#if LIBCURL_VERSION_NUM >= 0x070a07 /* 7.10.7 */
{"AsynchDNS", CURL_VERSION_ASYNCHDNS},
#endif
#if LIBCURL_VERSION_NUM >= 0x070f04 /* 7.15.4 */
{"CharConv", CURL_VERSION_CONV},
#endif
#if LIBCURL_VERSION_NUM >= 0x070a06 /* 7.10.6 */
{"Debug", CURL_VERSION_DEBUG},
{"GSS-Negotiate", CURL_VERSION_GSSNEGOTIATE},
#endif
#if LIBCURL_VERSION_NUM >= 0x070c00 /* 7.12.0 */
{"IDN", CURL_VERSION_IDN},
#endif
{"IPv6", CURL_VERSION_IPV6},
{"krb4", CURL_VERSION_KERBEROS4},
#if LIBCURL_VERSION_NUM >= 0x070b01 /* 7.11.1 */
{"Largefile", CURL_VERSION_LARGEFILE},
#endif
{"libz", CURL_VERSION_LIBZ},
#if LIBCURL_VERSION_NUM >= 0x070a06 /* 7.10.6 */
{"NTLM", CURL_VERSION_NTLM},
#endif
#if LIBCURL_VERSION_NUM >= 0x071600 /* 7.22.0 */
{"NTLMWB", CURL_VERSION_NTLM_WB},
#endif
#if LIBCURL_VERSION_NUM >= 0x070a08 /* 7.10.8 */
{"SPNEGO", CURL_VERSION_SPNEGO},
#endif
{"SSL", CURL_VERSION_SSL},
#if LIBCURL_VERSION_NUM >= 0x070d02 /* 7.13.2 */
{"SSPI", CURL_VERSION_SSPI},
#endif
#if LIBCURL_VERSION_NUM >= 0x071504 /* 7.21.4 */
{"TLS-SRP", CURL_VERSION_TLSAUTH_SRP},
#endif
#if LIBCURL_VERSION_NUM >= 0x072100 /* 7.33.0 */
{"HTTP2", CURL_VERSION_HTTP2},
#endif
#if LIBCURL_VERSION_NUM >= 0x072600 /* 7.38.0 */
{"GSSAPI", CURL_VERSION_GSSAPI},
#endif
{NULL, 0}
};
php_info_print_table_row(1, "Features");
for(i=0; i<sizeof(feats)/sizeof(feats[0]); i++) {
if (feats[i].name) {
php_info_print_table_row(2, feats[i].name, d->features & feats[i].bitmask ? "Yes" : "No");
}
}
}
n = 0;
p = (char **) d->protocols;
while (*p != NULL) {
n += sprintf(str + n, "%s%s", *p, *(p + 1) != NULL ? ", " : "");
p++;
}
php_info_print_table_row(2, "Protocols", str);
php_info_print_table_row(2, "Host", d->host);
if (d->ssl_version) {
php_info_print_table_row(2, "SSL Version", d->ssl_version);
}
if (d->libz_version) {
php_info_print_table_row(2, "ZLib Version", d->libz_version);
}
#if defined(CURLVERSION_SECOND) && CURLVERSION_NOW >= CURLVERSION_SECOND
if (d->ares) {
php_info_print_table_row(2, "ZLib Version", d->ares);
}
#endif
#if defined(CURLVERSION_THIRD) && CURLVERSION_NOW >= CURLVERSION_THIRD
if (d->libidn) {
php_info_print_table_row(2, "libIDN Version", d->libidn);
}
#endif
#if LIBCURL_VERSION_NUM >= 0x071300
if (d->iconv_ver_num) {
php_info_print_table_row(2, "IconV Version", d->iconv_ver_num);
}
if (d->libssh_version) {
php_info_print_table_row(2, "libSSH Version", d->libssh_version);
}
#endif
php_info_print_table_end();
}
|
DoS
| 0
|
PHP_MINFO_FUNCTION(curl)
{
curl_version_info_data *d;
char **p;
char str[1024];
size_t n = 0;
d = curl_version_info(CURLVERSION_NOW);
php_info_print_table_start();
php_info_print_table_row(2, "cURL support", "enabled");
php_info_print_table_row(2, "cURL Information", d->version);
sprintf(str, "%d", d->age);
php_info_print_table_row(2, "Age", str);
/* To update on each new cURL release using src/main.c in cURL sources */
if (d->features) {
struct feat {
const char *name;
int bitmask;
};
unsigned int i;
static const struct feat feats[] = {
#if LIBCURL_VERSION_NUM >= 0x070a07 /* 7.10.7 */
{"AsynchDNS", CURL_VERSION_ASYNCHDNS},
#endif
#if LIBCURL_VERSION_NUM >= 0x070f04 /* 7.15.4 */
{"CharConv", CURL_VERSION_CONV},
#endif
#if LIBCURL_VERSION_NUM >= 0x070a06 /* 7.10.6 */
{"Debug", CURL_VERSION_DEBUG},
{"GSS-Negotiate", CURL_VERSION_GSSNEGOTIATE},
#endif
#if LIBCURL_VERSION_NUM >= 0x070c00 /* 7.12.0 */
{"IDN", CURL_VERSION_IDN},
#endif
{"IPv6", CURL_VERSION_IPV6},
{"krb4", CURL_VERSION_KERBEROS4},
#if LIBCURL_VERSION_NUM >= 0x070b01 /* 7.11.1 */
{"Largefile", CURL_VERSION_LARGEFILE},
#endif
{"libz", CURL_VERSION_LIBZ},
#if LIBCURL_VERSION_NUM >= 0x070a06 /* 7.10.6 */
{"NTLM", CURL_VERSION_NTLM},
#endif
#if LIBCURL_VERSION_NUM >= 0x071600 /* 7.22.0 */
{"NTLMWB", CURL_VERSION_NTLM_WB},
#endif
#if LIBCURL_VERSION_NUM >= 0x070a08 /* 7.10.8 */
{"SPNEGO", CURL_VERSION_SPNEGO},
#endif
{"SSL", CURL_VERSION_SSL},
#if LIBCURL_VERSION_NUM >= 0x070d02 /* 7.13.2 */
{"SSPI", CURL_VERSION_SSPI},
#endif
#if LIBCURL_VERSION_NUM >= 0x071504 /* 7.21.4 */
{"TLS-SRP", CURL_VERSION_TLSAUTH_SRP},
#endif
#if LIBCURL_VERSION_NUM >= 0x072100 /* 7.33.0 */
{"HTTP2", CURL_VERSION_HTTP2},
#endif
#if LIBCURL_VERSION_NUM >= 0x072600 /* 7.38.0 */
{"GSSAPI", CURL_VERSION_GSSAPI},
#endif
{NULL, 0}
};
php_info_print_table_row(1, "Features");
for(i=0; i<sizeof(feats)/sizeof(feats[0]); i++) {
if (feats[i].name) {
php_info_print_table_row(2, feats[i].name, d->features & feats[i].bitmask ? "Yes" : "No");
}
}
}
n = 0;
p = (char **) d->protocols;
while (*p != NULL) {
n += sprintf(str + n, "%s%s", *p, *(p + 1) != NULL ? ", " : "");
p++;
}
php_info_print_table_row(2, "Protocols", str);
php_info_print_table_row(2, "Host", d->host);
if (d->ssl_version) {
php_info_print_table_row(2, "SSL Version", d->ssl_version);
}
if (d->libz_version) {
php_info_print_table_row(2, "ZLib Version", d->libz_version);
}
#if defined(CURLVERSION_SECOND) && CURLVERSION_NOW >= CURLVERSION_SECOND
if (d->ares) {
php_info_print_table_row(2, "ZLib Version", d->ares);
}
#endif
#if defined(CURLVERSION_THIRD) && CURLVERSION_NOW >= CURLVERSION_THIRD
if (d->libidn) {
php_info_print_table_row(2, "libIDN Version", d->libidn);
}
#endif
#if LIBCURL_VERSION_NUM >= 0x071300
if (d->iconv_ver_num) {
php_info_print_table_row(2, "IconV Version", d->iconv_ver_num);
}
if (d->libssh_version) {
php_info_print_table_row(2, "libSSH Version", d->libssh_version);
}
#endif
php_info_print_table_end();
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,033
|
PHP_MINIT_FUNCTION(curl)
{
le_curl = zend_register_list_destructors_ex(_php_curl_close, NULL, "curl", module_number);
le_curl_multi_handle = zend_register_list_destructors_ex(_php_curl_multi_close, NULL, "curl_multi", module_number);
le_curl_share_handle = zend_register_list_destructors_ex(_php_curl_share_close, NULL, "curl_share", module_number);
REGISTER_INI_ENTRIES();
/* See http://curl.haxx.se/lxr/source/docs/libcurl/symbols-in-versions
or curl src/docs/libcurl/symbols-in-versions for a (almost) complete list
of options and which version they were introduced */
/* Constants for curl_setopt() */
REGISTER_CURL_CONSTANT(CURLOPT_AUTOREFERER);
REGISTER_CURL_CONSTANT(CURLOPT_BINARYTRANSFER);
REGISTER_CURL_CONSTANT(CURLOPT_BUFFERSIZE);
REGISTER_CURL_CONSTANT(CURLOPT_CAINFO);
REGISTER_CURL_CONSTANT(CURLOPT_CAPATH);
REGISTER_CURL_CONSTANT(CURLOPT_CONNECTTIMEOUT);
REGISTER_CURL_CONSTANT(CURLOPT_COOKIE);
REGISTER_CURL_CONSTANT(CURLOPT_COOKIEFILE);
REGISTER_CURL_CONSTANT(CURLOPT_COOKIEJAR);
REGISTER_CURL_CONSTANT(CURLOPT_COOKIESESSION);
REGISTER_CURL_CONSTANT(CURLOPT_CRLF);
REGISTER_CURL_CONSTANT(CURLOPT_CUSTOMREQUEST);
REGISTER_CURL_CONSTANT(CURLOPT_DNS_CACHE_TIMEOUT);
REGISTER_CURL_CONSTANT(CURLOPT_DNS_USE_GLOBAL_CACHE);
REGISTER_CURL_CONSTANT(CURLOPT_EGDSOCKET);
REGISTER_CURL_CONSTANT(CURLOPT_ENCODING);
REGISTER_CURL_CONSTANT(CURLOPT_FAILONERROR);
REGISTER_CURL_CONSTANT(CURLOPT_FILE);
REGISTER_CURL_CONSTANT(CURLOPT_FILETIME);
REGISTER_CURL_CONSTANT(CURLOPT_FOLLOWLOCATION);
REGISTER_CURL_CONSTANT(CURLOPT_FORBID_REUSE);
REGISTER_CURL_CONSTANT(CURLOPT_FRESH_CONNECT);
REGISTER_CURL_CONSTANT(CURLOPT_FTPAPPEND);
REGISTER_CURL_CONSTANT(CURLOPT_FTPLISTONLY);
REGISTER_CURL_CONSTANT(CURLOPT_FTPPORT);
REGISTER_CURL_CONSTANT(CURLOPT_FTP_USE_EPRT);
REGISTER_CURL_CONSTANT(CURLOPT_FTP_USE_EPSV);
REGISTER_CURL_CONSTANT(CURLOPT_HEADER);
REGISTER_CURL_CONSTANT(CURLOPT_HEADERFUNCTION);
REGISTER_CURL_CONSTANT(CURLOPT_HTTP200ALIASES);
REGISTER_CURL_CONSTANT(CURLOPT_HTTPGET);
REGISTER_CURL_CONSTANT(CURLOPT_HTTPHEADER);
REGISTER_CURL_CONSTANT(CURLOPT_HTTPPROXYTUNNEL);
REGISTER_CURL_CONSTANT(CURLOPT_HTTP_VERSION);
REGISTER_CURL_CONSTANT(CURLOPT_INFILE);
REGISTER_CURL_CONSTANT(CURLOPT_INFILESIZE);
REGISTER_CURL_CONSTANT(CURLOPT_INTERFACE);
REGISTER_CURL_CONSTANT(CURLOPT_KRB4LEVEL);
REGISTER_CURL_CONSTANT(CURLOPT_LOW_SPEED_LIMIT);
REGISTER_CURL_CONSTANT(CURLOPT_LOW_SPEED_TIME);
REGISTER_CURL_CONSTANT(CURLOPT_MAXCONNECTS);
REGISTER_CURL_CONSTANT(CURLOPT_MAXREDIRS);
REGISTER_CURL_CONSTANT(CURLOPT_NETRC);
REGISTER_CURL_CONSTANT(CURLOPT_NOBODY);
REGISTER_CURL_CONSTANT(CURLOPT_NOPROGRESS);
REGISTER_CURL_CONSTANT(CURLOPT_NOSIGNAL);
REGISTER_CURL_CONSTANT(CURLOPT_PORT);
REGISTER_CURL_CONSTANT(CURLOPT_POST);
REGISTER_CURL_CONSTANT(CURLOPT_POSTFIELDS);
REGISTER_CURL_CONSTANT(CURLOPT_POSTQUOTE);
REGISTER_CURL_CONSTANT(CURLOPT_PREQUOTE);
REGISTER_CURL_CONSTANT(CURLOPT_PRIVATE);
REGISTER_CURL_CONSTANT(CURLOPT_PROGRESSFUNCTION);
REGISTER_CURL_CONSTANT(CURLOPT_PROXY);
REGISTER_CURL_CONSTANT(CURLOPT_PROXYPORT);
REGISTER_CURL_CONSTANT(CURLOPT_PROXYTYPE);
REGISTER_CURL_CONSTANT(CURLOPT_PROXYUSERPWD);
REGISTER_CURL_CONSTANT(CURLOPT_PUT);
REGISTER_CURL_CONSTANT(CURLOPT_QUOTE);
REGISTER_CURL_CONSTANT(CURLOPT_RANDOM_FILE);
REGISTER_CURL_CONSTANT(CURLOPT_RANGE);
REGISTER_CURL_CONSTANT(CURLOPT_READDATA);
REGISTER_CURL_CONSTANT(CURLOPT_READFUNCTION);
REGISTER_CURL_CONSTANT(CURLOPT_REFERER);
REGISTER_CURL_CONSTANT(CURLOPT_RESUME_FROM);
REGISTER_CURL_CONSTANT(CURLOPT_RETURNTRANSFER);
REGISTER_CURL_CONSTANT(CURLOPT_SHARE);
REGISTER_CURL_CONSTANT(CURLOPT_SSLCERT);
REGISTER_CURL_CONSTANT(CURLOPT_SSLCERTPASSWD);
REGISTER_CURL_CONSTANT(CURLOPT_SSLCERTTYPE);
REGISTER_CURL_CONSTANT(CURLOPT_SSLENGINE);
REGISTER_CURL_CONSTANT(CURLOPT_SSLENGINE_DEFAULT);
REGISTER_CURL_CONSTANT(CURLOPT_SSLKEY);
REGISTER_CURL_CONSTANT(CURLOPT_SSLKEYPASSWD);
REGISTER_CURL_CONSTANT(CURLOPT_SSLKEYTYPE);
REGISTER_CURL_CONSTANT(CURLOPT_SSLVERSION);
REGISTER_CURL_CONSTANT(CURLOPT_SSL_CIPHER_LIST);
REGISTER_CURL_CONSTANT(CURLOPT_SSL_VERIFYHOST);
REGISTER_CURL_CONSTANT(CURLOPT_SSL_VERIFYPEER);
REGISTER_CURL_CONSTANT(CURLOPT_STDERR);
REGISTER_CURL_CONSTANT(CURLOPT_TELNETOPTIONS);
REGISTER_CURL_CONSTANT(CURLOPT_TIMECONDITION);
REGISTER_CURL_CONSTANT(CURLOPT_TIMEOUT);
REGISTER_CURL_CONSTANT(CURLOPT_TIMEVALUE);
REGISTER_CURL_CONSTANT(CURLOPT_TRANSFERTEXT);
REGISTER_CURL_CONSTANT(CURLOPT_UNRESTRICTED_AUTH);
REGISTER_CURL_CONSTANT(CURLOPT_UPLOAD);
REGISTER_CURL_CONSTANT(CURLOPT_URL);
REGISTER_CURL_CONSTANT(CURLOPT_USERAGENT);
REGISTER_CURL_CONSTANT(CURLOPT_USERPWD);
REGISTER_CURL_CONSTANT(CURLOPT_VERBOSE);
REGISTER_CURL_CONSTANT(CURLOPT_WRITEFUNCTION);
REGISTER_CURL_CONSTANT(CURLOPT_WRITEHEADER);
/* */
REGISTER_CURL_CONSTANT(CURLE_ABORTED_BY_CALLBACK);
REGISTER_CURL_CONSTANT(CURLE_BAD_CALLING_ORDER);
REGISTER_CURL_CONSTANT(CURLE_BAD_CONTENT_ENCODING);
REGISTER_CURL_CONSTANT(CURLE_BAD_DOWNLOAD_RESUME);
REGISTER_CURL_CONSTANT(CURLE_BAD_FUNCTION_ARGUMENT);
REGISTER_CURL_CONSTANT(CURLE_BAD_PASSWORD_ENTERED);
REGISTER_CURL_CONSTANT(CURLE_COULDNT_CONNECT);
REGISTER_CURL_CONSTANT(CURLE_COULDNT_RESOLVE_HOST);
REGISTER_CURL_CONSTANT(CURLE_COULDNT_RESOLVE_PROXY);
REGISTER_CURL_CONSTANT(CURLE_FAILED_INIT);
REGISTER_CURL_CONSTANT(CURLE_FILE_COULDNT_READ_FILE);
REGISTER_CURL_CONSTANT(CURLE_FTP_ACCESS_DENIED);
REGISTER_CURL_CONSTANT(CURLE_FTP_BAD_DOWNLOAD_RESUME);
REGISTER_CURL_CONSTANT(CURLE_FTP_CANT_GET_HOST);
REGISTER_CURL_CONSTANT(CURLE_FTP_CANT_RECONNECT);
REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_GET_SIZE);
REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_RETR_FILE);
REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_SET_ASCII);
REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_SET_BINARY);
REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_STOR_FILE);
REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_USE_REST);
REGISTER_CURL_CONSTANT(CURLE_FTP_PARTIAL_FILE);
REGISTER_CURL_CONSTANT(CURLE_FTP_PORT_FAILED);
REGISTER_CURL_CONSTANT(CURLE_FTP_QUOTE_ERROR);
REGISTER_CURL_CONSTANT(CURLE_FTP_USER_PASSWORD_INCORRECT);
REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_227_FORMAT);
REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_PASS_REPLY);
REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_PASV_REPLY);
REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_SERVER_REPLY);
REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_USER_REPLY);
REGISTER_CURL_CONSTANT(CURLE_FTP_WRITE_ERROR);
REGISTER_CURL_CONSTANT(CURLE_FUNCTION_NOT_FOUND);
REGISTER_CURL_CONSTANT(CURLE_GOT_NOTHING);
REGISTER_CURL_CONSTANT(CURLE_HTTP_NOT_FOUND);
REGISTER_CURL_CONSTANT(CURLE_HTTP_PORT_FAILED);
REGISTER_CURL_CONSTANT(CURLE_HTTP_POST_ERROR);
REGISTER_CURL_CONSTANT(CURLE_HTTP_RANGE_ERROR);
REGISTER_CURL_CONSTANT(CURLE_HTTP_RETURNED_ERROR);
REGISTER_CURL_CONSTANT(CURLE_LDAP_CANNOT_BIND);
REGISTER_CURL_CONSTANT(CURLE_LDAP_SEARCH_FAILED);
REGISTER_CURL_CONSTANT(CURLE_LIBRARY_NOT_FOUND);
REGISTER_CURL_CONSTANT(CURLE_MALFORMAT_USER);
REGISTER_CURL_CONSTANT(CURLE_OBSOLETE);
REGISTER_CURL_CONSTANT(CURLE_OK);
REGISTER_CURL_CONSTANT(CURLE_OPERATION_TIMEDOUT);
REGISTER_CURL_CONSTANT(CURLE_OPERATION_TIMEOUTED);
REGISTER_CURL_CONSTANT(CURLE_OUT_OF_MEMORY);
REGISTER_CURL_CONSTANT(CURLE_PARTIAL_FILE);
REGISTER_CURL_CONSTANT(CURLE_READ_ERROR);
REGISTER_CURL_CONSTANT(CURLE_RECV_ERROR);
REGISTER_CURL_CONSTANT(CURLE_SEND_ERROR);
REGISTER_CURL_CONSTANT(CURLE_SHARE_IN_USE);
REGISTER_CURL_CONSTANT(CURLE_SSL_CACERT);
REGISTER_CURL_CONSTANT(CURLE_SSL_CERTPROBLEM);
REGISTER_CURL_CONSTANT(CURLE_SSL_CIPHER);
REGISTER_CURL_CONSTANT(CURLE_SSL_CONNECT_ERROR);
REGISTER_CURL_CONSTANT(CURLE_SSL_ENGINE_NOTFOUND);
REGISTER_CURL_CONSTANT(CURLE_SSL_ENGINE_SETFAILED);
REGISTER_CURL_CONSTANT(CURLE_SSL_PEER_CERTIFICATE);
REGISTER_CURL_CONSTANT(CURLE_TELNET_OPTION_SYNTAX);
REGISTER_CURL_CONSTANT(CURLE_TOO_MANY_REDIRECTS);
REGISTER_CURL_CONSTANT(CURLE_UNKNOWN_TELNET_OPTION);
REGISTER_CURL_CONSTANT(CURLE_UNSUPPORTED_PROTOCOL);
REGISTER_CURL_CONSTANT(CURLE_URL_MALFORMAT);
REGISTER_CURL_CONSTANT(CURLE_URL_MALFORMAT_USER);
REGISTER_CURL_CONSTANT(CURLE_WRITE_ERROR);
/* cURL info constants */
REGISTER_CURL_CONSTANT(CURLINFO_CONNECT_TIME);
REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_LENGTH_DOWNLOAD);
REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_LENGTH_UPLOAD);
REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_TYPE);
REGISTER_CURL_CONSTANT(CURLINFO_EFFECTIVE_URL);
REGISTER_CURL_CONSTANT(CURLINFO_FILETIME);
REGISTER_CURL_CONSTANT(CURLINFO_HEADER_OUT);
REGISTER_CURL_CONSTANT(CURLINFO_HEADER_SIZE);
REGISTER_CURL_CONSTANT(CURLINFO_HTTP_CODE);
REGISTER_CURL_CONSTANT(CURLINFO_LASTONE);
REGISTER_CURL_CONSTANT(CURLINFO_NAMELOOKUP_TIME);
REGISTER_CURL_CONSTANT(CURLINFO_PRETRANSFER_TIME);
REGISTER_CURL_CONSTANT(CURLINFO_PRIVATE);
REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_COUNT);
REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_TIME);
REGISTER_CURL_CONSTANT(CURLINFO_REQUEST_SIZE);
REGISTER_CURL_CONSTANT(CURLINFO_SIZE_DOWNLOAD);
REGISTER_CURL_CONSTANT(CURLINFO_SIZE_UPLOAD);
REGISTER_CURL_CONSTANT(CURLINFO_SPEED_DOWNLOAD);
REGISTER_CURL_CONSTANT(CURLINFO_SPEED_UPLOAD);
REGISTER_CURL_CONSTANT(CURLINFO_SSL_VERIFYRESULT);
REGISTER_CURL_CONSTANT(CURLINFO_STARTTRANSFER_TIME);
REGISTER_CURL_CONSTANT(CURLINFO_TOTAL_TIME);
/* Other */
REGISTER_CURL_CONSTANT(CURLMSG_DONE);
REGISTER_CURL_CONSTANT(CURLVERSION_NOW);
/* Curl Multi Constants */
REGISTER_CURL_CONSTANT(CURLM_BAD_EASY_HANDLE);
REGISTER_CURL_CONSTANT(CURLM_BAD_HANDLE);
REGISTER_CURL_CONSTANT(CURLM_CALL_MULTI_PERFORM);
REGISTER_CURL_CONSTANT(CURLM_INTERNAL_ERROR);
REGISTER_CURL_CONSTANT(CURLM_OK);
REGISTER_CURL_CONSTANT(CURLM_OUT_OF_MEMORY);
/* Curl proxy constants */
REGISTER_CURL_CONSTANT(CURLPROXY_HTTP);
REGISTER_CURL_CONSTANT(CURLPROXY_SOCKS4);
REGISTER_CURL_CONSTANT(CURLPROXY_SOCKS5);
/* Curl Share constants */
REGISTER_CURL_CONSTANT(CURLSHOPT_NONE);
REGISTER_CURL_CONSTANT(CURLSHOPT_SHARE);
REGISTER_CURL_CONSTANT(CURLSHOPT_UNSHARE);
/* Curl Http Version constants (CURLOPT_HTTP_VERSION) */
REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_1_0);
REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_1_1);
REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_NONE);
/* Curl Lock constants */
REGISTER_CURL_CONSTANT(CURL_LOCK_DATA_COOKIE);
REGISTER_CURL_CONSTANT(CURL_LOCK_DATA_DNS);
REGISTER_CURL_CONSTANT(CURL_LOCK_DATA_SSL_SESSION);
/* Curl NETRC constants (CURLOPT_NETRC) */
REGISTER_CURL_CONSTANT(CURL_NETRC_IGNORED);
REGISTER_CURL_CONSTANT(CURL_NETRC_OPTIONAL);
REGISTER_CURL_CONSTANT(CURL_NETRC_REQUIRED);
/* Curl SSL Version constants (CURLOPT_SSLVERSION) */
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_DEFAULT);
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_SSLv2);
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_SSLv3);
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_TLSv1);
/* Curl TIMECOND constants (CURLOPT_TIMECONDITION) */
REGISTER_CURL_CONSTANT(CURL_TIMECOND_IFMODSINCE);
REGISTER_CURL_CONSTANT(CURL_TIMECOND_IFUNMODSINCE);
REGISTER_CURL_CONSTANT(CURL_TIMECOND_LASTMOD);
REGISTER_CURL_CONSTANT(CURL_TIMECOND_NONE);
/* Curl version constants */
REGISTER_CURL_CONSTANT(CURL_VERSION_IPV6);
REGISTER_CURL_CONSTANT(CURL_VERSION_KERBEROS4);
REGISTER_CURL_CONSTANT(CURL_VERSION_LIBZ);
REGISTER_CURL_CONSTANT(CURL_VERSION_SSL);
#if LIBCURL_VERSION_NUM >= 0x070a06 /* Available since 7.10.6 */
REGISTER_CURL_CONSTANT(CURLOPT_HTTPAUTH);
/* http authentication options */
REGISTER_CURL_CONSTANT(CURLAUTH_ANY);
REGISTER_CURL_CONSTANT(CURLAUTH_ANYSAFE);
REGISTER_CURL_CONSTANT(CURLAUTH_BASIC);
REGISTER_CURL_CONSTANT(CURLAUTH_DIGEST);
REGISTER_CURL_CONSTANT(CURLAUTH_GSSNEGOTIATE);
REGISTER_CURL_CONSTANT(CURLAUTH_NONE);
REGISTER_CURL_CONSTANT(CURLAUTH_NTLM);
#endif
#if LIBCURL_VERSION_NUM >= 0x070a07 /* Available since 7.10.7 */
REGISTER_CURL_CONSTANT(CURLINFO_HTTP_CONNECTCODE);
REGISTER_CURL_CONSTANT(CURLOPT_FTP_CREATE_MISSING_DIRS);
REGISTER_CURL_CONSTANT(CURLOPT_PROXYAUTH);
#endif
#if LIBCURL_VERSION_NUM >= 0x070a08 /* Available since 7.10.8 */
REGISTER_CURL_CONSTANT(CURLE_FILESIZE_EXCEEDED);
REGISTER_CURL_CONSTANT(CURLE_LDAP_INVALID_URL);
REGISTER_CURL_CONSTANT(CURLINFO_HTTPAUTH_AVAIL);
REGISTER_CURL_CONSTANT(CURLINFO_RESPONSE_CODE);
REGISTER_CURL_CONSTANT(CURLINFO_PROXYAUTH_AVAIL);
REGISTER_CURL_CONSTANT(CURLOPT_FTP_RESPONSE_TIMEOUT);
REGISTER_CURL_CONSTANT(CURLOPT_IPRESOLVE);
REGISTER_CURL_CONSTANT(CURLOPT_MAXFILESIZE);
REGISTER_CURL_CONSTANT(CURL_IPRESOLVE_V4);
REGISTER_CURL_CONSTANT(CURL_IPRESOLVE_V6);
REGISTER_CURL_CONSTANT(CURL_IPRESOLVE_WHATEVER);
#endif
#if LIBCURL_VERSION_NUM >= 0x070b00 /* Available since 7.11.0 */
REGISTER_CURL_CONSTANT(CURLE_FTP_SSL_FAILED);
REGISTER_CURL_CONSTANT(CURLFTPSSL_ALL);
REGISTER_CURL_CONSTANT(CURLFTPSSL_CONTROL);
REGISTER_CURL_CONSTANT(CURLFTPSSL_NONE);
REGISTER_CURL_CONSTANT(CURLFTPSSL_TRY);
REGISTER_CURL_CONSTANT(CURLOPT_FTP_SSL);
REGISTER_CURL_CONSTANT(CURLOPT_NETRC_FILE);
#endif
#if LIBCURL_VERSION_NUM >= 0x070c02 /* Available since 7.12.2 */
REGISTER_CURL_CONSTANT(CURLFTPAUTH_DEFAULT);
REGISTER_CURL_CONSTANT(CURLFTPAUTH_SSL);
REGISTER_CURL_CONSTANT(CURLFTPAUTH_TLS);
REGISTER_CURL_CONSTANT(CURLOPT_FTPSSLAUTH);
#endif
#if LIBCURL_VERSION_NUM >= 0x070d00 /* Available since 7.13.0 */
REGISTER_CURL_CONSTANT(CURLOPT_FTP_ACCOUNT);
#endif
#if LIBCURL_VERSION_NUM >= 0x070b02 /* Available since 7.11.2 */
REGISTER_CURL_CONSTANT(CURLOPT_TCP_NODELAY);
#endif
#if LIBCURL_VERSION_NUM >= 0x070c02 /* Available since 7.12.2 */
REGISTER_CURL_CONSTANT(CURLINFO_OS_ERRNO);
#endif
#if LIBCURL_VERSION_NUM >= 0x070c03 /* Available since 7.12.3 */
REGISTER_CURL_CONSTANT(CURLINFO_NUM_CONNECTS);
REGISTER_CURL_CONSTANT(CURLINFO_SSL_ENGINES);
#endif
#if LIBCURL_VERSION_NUM >= 0x070e01 /* Available since 7.14.1 */
REGISTER_CURL_CONSTANT(CURLINFO_COOKIELIST);
REGISTER_CURL_CONSTANT(CURLOPT_COOKIELIST);
REGISTER_CURL_CONSTANT(CURLOPT_IGNORE_CONTENT_LENGTH);
#endif
#if LIBCURL_VERSION_NUM >= 0x070f00 /* Available since 7.15.0 */
REGISTER_CURL_CONSTANT(CURLOPT_FTP_SKIP_PASV_IP);
#endif
#if LIBCURL_VERSION_NUM >= 0x070f01 /* Available since 7.15.1 */
REGISTER_CURL_CONSTANT(CURLOPT_FTP_FILEMETHOD);
#endif
#if LIBCURL_VERSION_NUM >= 0x070f02 /* Available since 7.15.2 */
REGISTER_CURL_CONSTANT(CURLOPT_CONNECT_ONLY);
REGISTER_CURL_CONSTANT(CURLOPT_LOCALPORT);
REGISTER_CURL_CONSTANT(CURLOPT_LOCALPORTRANGE);
#endif
#if LIBCURL_VERSION_NUM >= 0x070f03 /* Available since 7.15.3 */
REGISTER_CURL_CONSTANT(CURLFTPMETHOD_MULTICWD);
REGISTER_CURL_CONSTANT(CURLFTPMETHOD_NOCWD);
REGISTER_CURL_CONSTANT(CURLFTPMETHOD_SINGLECWD);
#endif
#if LIBCURL_VERSION_NUM >= 0x070f04 /* Available since 7.15.4 */
REGISTER_CURL_CONSTANT(CURLINFO_FTP_ENTRY_PATH);
#endif
#if LIBCURL_VERSION_NUM >= 0x070f05 /* Available since 7.15.5 */
REGISTER_CURL_CONSTANT(CURLOPT_FTP_ALTERNATIVE_TO_USER);
REGISTER_CURL_CONSTANT(CURLOPT_MAX_RECV_SPEED_LARGE);
REGISTER_CURL_CONSTANT(CURLOPT_MAX_SEND_SPEED_LARGE);
#endif
#if LIBCURL_VERSION_NUM >= 0x071000 /* Available since 7.16.0 */
REGISTER_CURL_CONSTANT(CURLOPT_SSL_SESSIONID_CACHE);
REGISTER_CURL_CONSTANT(CURLMOPT_PIPELINING);
#endif
#if LIBCURL_VERSION_NUM >= 0x071001 /* Available since 7.16.1 */
REGISTER_CURL_CONSTANT(CURLE_SSH);
REGISTER_CURL_CONSTANT(CURLOPT_FTP_SSL_CCC);
REGISTER_CURL_CONSTANT(CURLOPT_SSH_AUTH_TYPES);
REGISTER_CURL_CONSTANT(CURLOPT_SSH_PRIVATE_KEYFILE);
REGISTER_CURL_CONSTANT(CURLOPT_SSH_PUBLIC_KEYFILE);
REGISTER_CURL_CONSTANT(CURLFTPSSL_CCC_ACTIVE);
REGISTER_CURL_CONSTANT(CURLFTPSSL_CCC_NONE);
REGISTER_CURL_CONSTANT(CURLFTPSSL_CCC_PASSIVE);
#endif
#if LIBCURL_VERSION_NUM >= 0x071002 /* Available since 7.16.2 */
REGISTER_CURL_CONSTANT(CURLOPT_CONNECTTIMEOUT_MS);
REGISTER_CURL_CONSTANT(CURLOPT_HTTP_CONTENT_DECODING);
REGISTER_CURL_CONSTANT(CURLOPT_HTTP_TRANSFER_DECODING);
REGISTER_CURL_CONSTANT(CURLOPT_TIMEOUT_MS);
#endif
#if LIBCURL_VERSION_NUM >= 0x071003 /* Available since 7.16.3 */
REGISTER_CURL_CONSTANT(CURLMOPT_MAXCONNECTS);
#endif
#if LIBCURL_VERSION_NUM >= 0x071004 /* Available since 7.16.4 */
REGISTER_CURL_CONSTANT(CURLOPT_KRBLEVEL);
REGISTER_CURL_CONSTANT(CURLOPT_NEW_DIRECTORY_PERMS);
REGISTER_CURL_CONSTANT(CURLOPT_NEW_FILE_PERMS);
#endif
#if LIBCURL_VERSION_NUM >= 0x071100 /* Available since 7.17.0 */
REGISTER_CURL_CONSTANT(CURLOPT_APPEND);
REGISTER_CURL_CONSTANT(CURLOPT_DIRLISTONLY);
REGISTER_CURL_CONSTANT(CURLOPT_USE_SSL);
/* Curl SSL Constants */
REGISTER_CURL_CONSTANT(CURLUSESSL_ALL);
REGISTER_CURL_CONSTANT(CURLUSESSL_CONTROL);
REGISTER_CURL_CONSTANT(CURLUSESSL_NONE);
REGISTER_CURL_CONSTANT(CURLUSESSL_TRY);
#endif
#if LIBCURL_VERSION_NUM >= 0x071101 /* Available since 7.17.1 */
REGISTER_CURL_CONSTANT(CURLOPT_SSH_HOST_PUBLIC_KEY_MD5);
#endif
#if LIBCURL_VERSION_NUM >= 0x071200 /* Available since 7.18.0 */
REGISTER_CURL_CONSTANT(CURLOPT_PROXY_TRANSFER_MODE);
REGISTER_CURL_CONSTANT(CURLPAUSE_ALL);
REGISTER_CURL_CONSTANT(CURLPAUSE_CONT);
REGISTER_CURL_CONSTANT(CURLPAUSE_RECV);
REGISTER_CURL_CONSTANT(CURLPAUSE_RECV_CONT);
REGISTER_CURL_CONSTANT(CURLPAUSE_SEND);
REGISTER_CURL_CONSTANT(CURLPAUSE_SEND_CONT);
REGISTER_CURL_CONSTANT(CURL_READFUNC_PAUSE);
REGISTER_CURL_CONSTANT(CURL_WRITEFUNC_PAUSE);
#endif
#if LIBCURL_VERSION_NUM >= 0x071202 /* Available since 7.18.2 */
REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_URL);
#endif
#if LIBCURL_VERSION_NUM >= 0x071300 /* Available since 7.19.0 */
REGISTER_CURL_CONSTANT(CURLINFO_APPCONNECT_TIME);
REGISTER_CURL_CONSTANT(CURLINFO_PRIMARY_IP);
REGISTER_CURL_CONSTANT(CURLOPT_ADDRESS_SCOPE);
REGISTER_CURL_CONSTANT(CURLOPT_CRLFILE);
REGISTER_CURL_CONSTANT(CURLOPT_ISSUERCERT);
REGISTER_CURL_CONSTANT(CURLOPT_KEYPASSWD);
REGISTER_CURL_CONSTANT(CURLSSH_AUTH_ANY);
REGISTER_CURL_CONSTANT(CURLSSH_AUTH_DEFAULT);
REGISTER_CURL_CONSTANT(CURLSSH_AUTH_HOST);
REGISTER_CURL_CONSTANT(CURLSSH_AUTH_KEYBOARD);
REGISTER_CURL_CONSTANT(CURLSSH_AUTH_NONE);
REGISTER_CURL_CONSTANT(CURLSSH_AUTH_PASSWORD);
REGISTER_CURL_CONSTANT(CURLSSH_AUTH_PUBLICKEY);
#endif
#if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */
REGISTER_CURL_CONSTANT(CURLINFO_CERTINFO);
REGISTER_CURL_CONSTANT(CURLOPT_CERTINFO);
REGISTER_CURL_CONSTANT(CURLOPT_PASSWORD);
REGISTER_CURL_CONSTANT(CURLOPT_POSTREDIR);
REGISTER_CURL_CONSTANT(CURLOPT_PROXYPASSWORD);
REGISTER_CURL_CONSTANT(CURLOPT_PROXYUSERNAME);
REGISTER_CURL_CONSTANT(CURLOPT_USERNAME);
#endif
#if LIBCURL_VERSION_NUM >= 0x071303 /* Available since 7.19.3 */
REGISTER_CURL_CONSTANT(CURLAUTH_DIGEST_IE);
#endif
#if LIBCURL_VERSION_NUM >= 0x071304 /* Available since 7.19.4 */
REGISTER_CURL_CONSTANT(CURLINFO_CONDITION_UNMET);
REGISTER_CURL_CONSTANT(CURLOPT_NOPROXY);
REGISTER_CURL_CONSTANT(CURLOPT_PROTOCOLS);
REGISTER_CURL_CONSTANT(CURLOPT_REDIR_PROTOCOLS);
REGISTER_CURL_CONSTANT(CURLOPT_SOCKS5_GSSAPI_NEC);
REGISTER_CURL_CONSTANT(CURLOPT_SOCKS5_GSSAPI_SERVICE);
REGISTER_CURL_CONSTANT(CURLOPT_TFTP_BLKSIZE);
REGISTER_CURL_CONSTANT(CURLPROTO_ALL);
REGISTER_CURL_CONSTANT(CURLPROTO_DICT);
REGISTER_CURL_CONSTANT(CURLPROTO_FILE);
REGISTER_CURL_CONSTANT(CURLPROTO_FTP);
REGISTER_CURL_CONSTANT(CURLPROTO_FTPS);
REGISTER_CURL_CONSTANT(CURLPROTO_HTTP);
REGISTER_CURL_CONSTANT(CURLPROTO_HTTPS);
REGISTER_CURL_CONSTANT(CURLPROTO_LDAP);
REGISTER_CURL_CONSTANT(CURLPROTO_LDAPS);
REGISTER_CURL_CONSTANT(CURLPROTO_SCP);
REGISTER_CURL_CONSTANT(CURLPROTO_SFTP);
REGISTER_CURL_CONSTANT(CURLPROTO_TELNET);
REGISTER_CURL_CONSTANT(CURLPROTO_TFTP);
#endif
#if LIBCURL_VERSION_NUM >= 0x071306 /* Available since 7.19.6 */
REGISTER_CURL_CONSTANT(CURLOPT_SSH_KNOWNHOSTS);
#endif
#if LIBCURL_VERSION_NUM >= 0x071400 /* Available since 7.20.0 */
REGISTER_CURL_CONSTANT(CURLINFO_RTSP_CLIENT_CSEQ);
REGISTER_CURL_CONSTANT(CURLINFO_RTSP_CSEQ_RECV);
REGISTER_CURL_CONSTANT(CURLINFO_RTSP_SERVER_CSEQ);
REGISTER_CURL_CONSTANT(CURLINFO_RTSP_SESSION_ID);
REGISTER_CURL_CONSTANT(CURLOPT_FTP_USE_PRET);
REGISTER_CURL_CONSTANT(CURLOPT_MAIL_FROM);
REGISTER_CURL_CONSTANT(CURLOPT_MAIL_RCPT);
REGISTER_CURL_CONSTANT(CURLOPT_RTSP_CLIENT_CSEQ);
REGISTER_CURL_CONSTANT(CURLOPT_RTSP_REQUEST);
REGISTER_CURL_CONSTANT(CURLOPT_RTSP_SERVER_CSEQ);
REGISTER_CURL_CONSTANT(CURLOPT_RTSP_SESSION_ID);
REGISTER_CURL_CONSTANT(CURLOPT_RTSP_STREAM_URI);
REGISTER_CURL_CONSTANT(CURLOPT_RTSP_TRANSPORT);
REGISTER_CURL_CONSTANT(CURLPROTO_IMAP);
REGISTER_CURL_CONSTANT(CURLPROTO_IMAPS);
REGISTER_CURL_CONSTANT(CURLPROTO_POP3);
REGISTER_CURL_CONSTANT(CURLPROTO_POP3S);
REGISTER_CURL_CONSTANT(CURLPROTO_RTSP);
REGISTER_CURL_CONSTANT(CURLPROTO_SMTP);
REGISTER_CURL_CONSTANT(CURLPROTO_SMTPS);
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_ANNOUNCE);
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_DESCRIBE);
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_GET_PARAMETER);
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_OPTIONS);
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_PAUSE);
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_PLAY);
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_RECEIVE);
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_RECORD);
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_SETUP);
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_SET_PARAMETER);
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_TEARDOWN);
#endif
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
REGISTER_CURL_CONSTANT(CURLINFO_LOCAL_IP);
REGISTER_CURL_CONSTANT(CURLINFO_LOCAL_PORT);
REGISTER_CURL_CONSTANT(CURLINFO_PRIMARY_PORT);
REGISTER_CURL_CONSTANT(CURLOPT_FNMATCH_FUNCTION);
REGISTER_CURL_CONSTANT(CURLOPT_WILDCARDMATCH);
REGISTER_CURL_CONSTANT(CURLPROTO_RTMP);
REGISTER_CURL_CONSTANT(CURLPROTO_RTMPE);
REGISTER_CURL_CONSTANT(CURLPROTO_RTMPS);
REGISTER_CURL_CONSTANT(CURLPROTO_RTMPT);
REGISTER_CURL_CONSTANT(CURLPROTO_RTMPTE);
REGISTER_CURL_CONSTANT(CURLPROTO_RTMPTS);
REGISTER_CURL_CONSTANT(CURL_FNMATCHFUNC_FAIL);
REGISTER_CURL_CONSTANT(CURL_FNMATCHFUNC_MATCH);
REGISTER_CURL_CONSTANT(CURL_FNMATCHFUNC_NOMATCH);
#endif
#if LIBCURL_VERSION_NUM >= 0x071502 /* Available since 7.21.2 */
REGISTER_CURL_CONSTANT(CURLPROTO_GOPHER);
#endif
#if LIBCURL_VERSION_NUM >= 0x071503 /* Available since 7.21.3 */
REGISTER_CURL_CONSTANT(CURLAUTH_ONLY);
REGISTER_CURL_CONSTANT(CURLOPT_RESOLVE);
#endif
#if LIBCURL_VERSION_NUM >= 0x071504 /* Available since 7.21.4 */
REGISTER_CURL_CONSTANT(CURLOPT_TLSAUTH_PASSWORD);
REGISTER_CURL_CONSTANT(CURLOPT_TLSAUTH_TYPE);
REGISTER_CURL_CONSTANT(CURLOPT_TLSAUTH_USERNAME);
REGISTER_CURL_CONSTANT(CURL_TLSAUTH_SRP);
#endif
#if LIBCURL_VERSION_NUM >= 0x071506 /* Available since 7.21.6 */
REGISTER_CURL_CONSTANT(CURLOPT_ACCEPT_ENCODING);
REGISTER_CURL_CONSTANT(CURLOPT_TRANSFER_ENCODING);
#endif
#if LIBCURL_VERSION_NUM >= 0x071600 /* Available since 7.22.0 */
REGISTER_CURL_CONSTANT(CURLGSSAPI_DELEGATION_FLAG);
REGISTER_CURL_CONSTANT(CURLGSSAPI_DELEGATION_POLICY_FLAG);
REGISTER_CURL_CONSTANT(CURLOPT_GSSAPI_DELEGATION);
#endif
#if LIBCURL_VERSION_NUM >= 0x071800 /* Available since 7.24.0 */
REGISTER_CURL_CONSTANT(CURLOPT_ACCEPTTIMEOUT_MS);
REGISTER_CURL_CONSTANT(CURLOPT_DNS_SERVERS);
#endif
#if LIBCURL_VERSION_NUM >= 0x071900 /* Available since 7.25.0 */
REGISTER_CURL_CONSTANT(CURLOPT_MAIL_AUTH);
REGISTER_CURL_CONSTANT(CURLOPT_SSL_OPTIONS);
REGISTER_CURL_CONSTANT(CURLOPT_TCP_KEEPALIVE);
REGISTER_CURL_CONSTANT(CURLOPT_TCP_KEEPIDLE);
REGISTER_CURL_CONSTANT(CURLOPT_TCP_KEEPINTVL);
REGISTER_CURL_CONSTANT(CURLSSLOPT_ALLOW_BEAST);
#endif
#if LIBCURL_VERSION_NUM >= 0x072200 /* Available since 7.34.0 */
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_TLSv1_0);
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_TLSv1_1);
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_TLSv1_2);
#endif
#if CURLOPT_FTPASCII != 0
REGISTER_CURL_CONSTANT(CURLOPT_FTPASCII);
#endif
#if CURLOPT_MUTE != 0
REGISTER_CURL_CONSTANT(CURLOPT_MUTE);
#endif
#if CURLOPT_PASSWDFUNCTION != 0
REGISTER_CURL_CONSTANT(CURLOPT_PASSWDFUNCTION);
#endif
REGISTER_CURL_CONSTANT(CURLOPT_SAFE_UPLOAD);
#ifdef PHP_CURL_NEED_OPENSSL_TSL
if (!CRYPTO_get_id_callback()) {
int i, c = CRYPTO_num_locks();
php_curl_openssl_tsl = malloc(c * sizeof(MUTEX_T));
if (!php_curl_openssl_tsl) {
return FAILURE;
}
for (i = 0; i < c; ++i) {
php_curl_openssl_tsl[i] = tsrm_mutex_alloc();
}
CRYPTO_set_id_callback(php_curl_ssl_id);
CRYPTO_set_locking_callback(php_curl_ssl_lock);
}
#endif
#ifdef PHP_CURL_NEED_GNUTLS_TSL
gcry_control(GCRYCTL_SET_THREAD_CBS, &php_curl_gnutls_tsl);
#endif
if (curl_global_init(CURL_GLOBAL_SSL) != CURLE_OK) {
return FAILURE;
}
curlfile_register_class();
return SUCCESS;
}
|
DoS
| 0
|
PHP_MINIT_FUNCTION(curl)
{
le_curl = zend_register_list_destructors_ex(_php_curl_close, NULL, "curl", module_number);
le_curl_multi_handle = zend_register_list_destructors_ex(_php_curl_multi_close, NULL, "curl_multi", module_number);
le_curl_share_handle = zend_register_list_destructors_ex(_php_curl_share_close, NULL, "curl_share", module_number);
REGISTER_INI_ENTRIES();
/* See http://curl.haxx.se/lxr/source/docs/libcurl/symbols-in-versions
or curl src/docs/libcurl/symbols-in-versions for a (almost) complete list
of options and which version they were introduced */
/* Constants for curl_setopt() */
REGISTER_CURL_CONSTANT(CURLOPT_AUTOREFERER);
REGISTER_CURL_CONSTANT(CURLOPT_BINARYTRANSFER);
REGISTER_CURL_CONSTANT(CURLOPT_BUFFERSIZE);
REGISTER_CURL_CONSTANT(CURLOPT_CAINFO);
REGISTER_CURL_CONSTANT(CURLOPT_CAPATH);
REGISTER_CURL_CONSTANT(CURLOPT_CONNECTTIMEOUT);
REGISTER_CURL_CONSTANT(CURLOPT_COOKIE);
REGISTER_CURL_CONSTANT(CURLOPT_COOKIEFILE);
REGISTER_CURL_CONSTANT(CURLOPT_COOKIEJAR);
REGISTER_CURL_CONSTANT(CURLOPT_COOKIESESSION);
REGISTER_CURL_CONSTANT(CURLOPT_CRLF);
REGISTER_CURL_CONSTANT(CURLOPT_CUSTOMREQUEST);
REGISTER_CURL_CONSTANT(CURLOPT_DNS_CACHE_TIMEOUT);
REGISTER_CURL_CONSTANT(CURLOPT_DNS_USE_GLOBAL_CACHE);
REGISTER_CURL_CONSTANT(CURLOPT_EGDSOCKET);
REGISTER_CURL_CONSTANT(CURLOPT_ENCODING);
REGISTER_CURL_CONSTANT(CURLOPT_FAILONERROR);
REGISTER_CURL_CONSTANT(CURLOPT_FILE);
REGISTER_CURL_CONSTANT(CURLOPT_FILETIME);
REGISTER_CURL_CONSTANT(CURLOPT_FOLLOWLOCATION);
REGISTER_CURL_CONSTANT(CURLOPT_FORBID_REUSE);
REGISTER_CURL_CONSTANT(CURLOPT_FRESH_CONNECT);
REGISTER_CURL_CONSTANT(CURLOPT_FTPAPPEND);
REGISTER_CURL_CONSTANT(CURLOPT_FTPLISTONLY);
REGISTER_CURL_CONSTANT(CURLOPT_FTPPORT);
REGISTER_CURL_CONSTANT(CURLOPT_FTP_USE_EPRT);
REGISTER_CURL_CONSTANT(CURLOPT_FTP_USE_EPSV);
REGISTER_CURL_CONSTANT(CURLOPT_HEADER);
REGISTER_CURL_CONSTANT(CURLOPT_HEADERFUNCTION);
REGISTER_CURL_CONSTANT(CURLOPT_HTTP200ALIASES);
REGISTER_CURL_CONSTANT(CURLOPT_HTTPGET);
REGISTER_CURL_CONSTANT(CURLOPT_HTTPHEADER);
REGISTER_CURL_CONSTANT(CURLOPT_HTTPPROXYTUNNEL);
REGISTER_CURL_CONSTANT(CURLOPT_HTTP_VERSION);
REGISTER_CURL_CONSTANT(CURLOPT_INFILE);
REGISTER_CURL_CONSTANT(CURLOPT_INFILESIZE);
REGISTER_CURL_CONSTANT(CURLOPT_INTERFACE);
REGISTER_CURL_CONSTANT(CURLOPT_KRB4LEVEL);
REGISTER_CURL_CONSTANT(CURLOPT_LOW_SPEED_LIMIT);
REGISTER_CURL_CONSTANT(CURLOPT_LOW_SPEED_TIME);
REGISTER_CURL_CONSTANT(CURLOPT_MAXCONNECTS);
REGISTER_CURL_CONSTANT(CURLOPT_MAXREDIRS);
REGISTER_CURL_CONSTANT(CURLOPT_NETRC);
REGISTER_CURL_CONSTANT(CURLOPT_NOBODY);
REGISTER_CURL_CONSTANT(CURLOPT_NOPROGRESS);
REGISTER_CURL_CONSTANT(CURLOPT_NOSIGNAL);
REGISTER_CURL_CONSTANT(CURLOPT_PORT);
REGISTER_CURL_CONSTANT(CURLOPT_POST);
REGISTER_CURL_CONSTANT(CURLOPT_POSTFIELDS);
REGISTER_CURL_CONSTANT(CURLOPT_POSTQUOTE);
REGISTER_CURL_CONSTANT(CURLOPT_PREQUOTE);
REGISTER_CURL_CONSTANT(CURLOPT_PRIVATE);
REGISTER_CURL_CONSTANT(CURLOPT_PROGRESSFUNCTION);
REGISTER_CURL_CONSTANT(CURLOPT_PROXY);
REGISTER_CURL_CONSTANT(CURLOPT_PROXYPORT);
REGISTER_CURL_CONSTANT(CURLOPT_PROXYTYPE);
REGISTER_CURL_CONSTANT(CURLOPT_PROXYUSERPWD);
REGISTER_CURL_CONSTANT(CURLOPT_PUT);
REGISTER_CURL_CONSTANT(CURLOPT_QUOTE);
REGISTER_CURL_CONSTANT(CURLOPT_RANDOM_FILE);
REGISTER_CURL_CONSTANT(CURLOPT_RANGE);
REGISTER_CURL_CONSTANT(CURLOPT_READDATA);
REGISTER_CURL_CONSTANT(CURLOPT_READFUNCTION);
REGISTER_CURL_CONSTANT(CURLOPT_REFERER);
REGISTER_CURL_CONSTANT(CURLOPT_RESUME_FROM);
REGISTER_CURL_CONSTANT(CURLOPT_RETURNTRANSFER);
REGISTER_CURL_CONSTANT(CURLOPT_SHARE);
REGISTER_CURL_CONSTANT(CURLOPT_SSLCERT);
REGISTER_CURL_CONSTANT(CURLOPT_SSLCERTPASSWD);
REGISTER_CURL_CONSTANT(CURLOPT_SSLCERTTYPE);
REGISTER_CURL_CONSTANT(CURLOPT_SSLENGINE);
REGISTER_CURL_CONSTANT(CURLOPT_SSLENGINE_DEFAULT);
REGISTER_CURL_CONSTANT(CURLOPT_SSLKEY);
REGISTER_CURL_CONSTANT(CURLOPT_SSLKEYPASSWD);
REGISTER_CURL_CONSTANT(CURLOPT_SSLKEYTYPE);
REGISTER_CURL_CONSTANT(CURLOPT_SSLVERSION);
REGISTER_CURL_CONSTANT(CURLOPT_SSL_CIPHER_LIST);
REGISTER_CURL_CONSTANT(CURLOPT_SSL_VERIFYHOST);
REGISTER_CURL_CONSTANT(CURLOPT_SSL_VERIFYPEER);
REGISTER_CURL_CONSTANT(CURLOPT_STDERR);
REGISTER_CURL_CONSTANT(CURLOPT_TELNETOPTIONS);
REGISTER_CURL_CONSTANT(CURLOPT_TIMECONDITION);
REGISTER_CURL_CONSTANT(CURLOPT_TIMEOUT);
REGISTER_CURL_CONSTANT(CURLOPT_TIMEVALUE);
REGISTER_CURL_CONSTANT(CURLOPT_TRANSFERTEXT);
REGISTER_CURL_CONSTANT(CURLOPT_UNRESTRICTED_AUTH);
REGISTER_CURL_CONSTANT(CURLOPT_UPLOAD);
REGISTER_CURL_CONSTANT(CURLOPT_URL);
REGISTER_CURL_CONSTANT(CURLOPT_USERAGENT);
REGISTER_CURL_CONSTANT(CURLOPT_USERPWD);
REGISTER_CURL_CONSTANT(CURLOPT_VERBOSE);
REGISTER_CURL_CONSTANT(CURLOPT_WRITEFUNCTION);
REGISTER_CURL_CONSTANT(CURLOPT_WRITEHEADER);
/* */
REGISTER_CURL_CONSTANT(CURLE_ABORTED_BY_CALLBACK);
REGISTER_CURL_CONSTANT(CURLE_BAD_CALLING_ORDER);
REGISTER_CURL_CONSTANT(CURLE_BAD_CONTENT_ENCODING);
REGISTER_CURL_CONSTANT(CURLE_BAD_DOWNLOAD_RESUME);
REGISTER_CURL_CONSTANT(CURLE_BAD_FUNCTION_ARGUMENT);
REGISTER_CURL_CONSTANT(CURLE_BAD_PASSWORD_ENTERED);
REGISTER_CURL_CONSTANT(CURLE_COULDNT_CONNECT);
REGISTER_CURL_CONSTANT(CURLE_COULDNT_RESOLVE_HOST);
REGISTER_CURL_CONSTANT(CURLE_COULDNT_RESOLVE_PROXY);
REGISTER_CURL_CONSTANT(CURLE_FAILED_INIT);
REGISTER_CURL_CONSTANT(CURLE_FILE_COULDNT_READ_FILE);
REGISTER_CURL_CONSTANT(CURLE_FTP_ACCESS_DENIED);
REGISTER_CURL_CONSTANT(CURLE_FTP_BAD_DOWNLOAD_RESUME);
REGISTER_CURL_CONSTANT(CURLE_FTP_CANT_GET_HOST);
REGISTER_CURL_CONSTANT(CURLE_FTP_CANT_RECONNECT);
REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_GET_SIZE);
REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_RETR_FILE);
REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_SET_ASCII);
REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_SET_BINARY);
REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_STOR_FILE);
REGISTER_CURL_CONSTANT(CURLE_FTP_COULDNT_USE_REST);
REGISTER_CURL_CONSTANT(CURLE_FTP_PARTIAL_FILE);
REGISTER_CURL_CONSTANT(CURLE_FTP_PORT_FAILED);
REGISTER_CURL_CONSTANT(CURLE_FTP_QUOTE_ERROR);
REGISTER_CURL_CONSTANT(CURLE_FTP_USER_PASSWORD_INCORRECT);
REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_227_FORMAT);
REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_PASS_REPLY);
REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_PASV_REPLY);
REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_SERVER_REPLY);
REGISTER_CURL_CONSTANT(CURLE_FTP_WEIRD_USER_REPLY);
REGISTER_CURL_CONSTANT(CURLE_FTP_WRITE_ERROR);
REGISTER_CURL_CONSTANT(CURLE_FUNCTION_NOT_FOUND);
REGISTER_CURL_CONSTANT(CURLE_GOT_NOTHING);
REGISTER_CURL_CONSTANT(CURLE_HTTP_NOT_FOUND);
REGISTER_CURL_CONSTANT(CURLE_HTTP_PORT_FAILED);
REGISTER_CURL_CONSTANT(CURLE_HTTP_POST_ERROR);
REGISTER_CURL_CONSTANT(CURLE_HTTP_RANGE_ERROR);
REGISTER_CURL_CONSTANT(CURLE_HTTP_RETURNED_ERROR);
REGISTER_CURL_CONSTANT(CURLE_LDAP_CANNOT_BIND);
REGISTER_CURL_CONSTANT(CURLE_LDAP_SEARCH_FAILED);
REGISTER_CURL_CONSTANT(CURLE_LIBRARY_NOT_FOUND);
REGISTER_CURL_CONSTANT(CURLE_MALFORMAT_USER);
REGISTER_CURL_CONSTANT(CURLE_OBSOLETE);
REGISTER_CURL_CONSTANT(CURLE_OK);
REGISTER_CURL_CONSTANT(CURLE_OPERATION_TIMEDOUT);
REGISTER_CURL_CONSTANT(CURLE_OPERATION_TIMEOUTED);
REGISTER_CURL_CONSTANT(CURLE_OUT_OF_MEMORY);
REGISTER_CURL_CONSTANT(CURLE_PARTIAL_FILE);
REGISTER_CURL_CONSTANT(CURLE_READ_ERROR);
REGISTER_CURL_CONSTANT(CURLE_RECV_ERROR);
REGISTER_CURL_CONSTANT(CURLE_SEND_ERROR);
REGISTER_CURL_CONSTANT(CURLE_SHARE_IN_USE);
REGISTER_CURL_CONSTANT(CURLE_SSL_CACERT);
REGISTER_CURL_CONSTANT(CURLE_SSL_CERTPROBLEM);
REGISTER_CURL_CONSTANT(CURLE_SSL_CIPHER);
REGISTER_CURL_CONSTANT(CURLE_SSL_CONNECT_ERROR);
REGISTER_CURL_CONSTANT(CURLE_SSL_ENGINE_NOTFOUND);
REGISTER_CURL_CONSTANT(CURLE_SSL_ENGINE_SETFAILED);
REGISTER_CURL_CONSTANT(CURLE_SSL_PEER_CERTIFICATE);
REGISTER_CURL_CONSTANT(CURLE_TELNET_OPTION_SYNTAX);
REGISTER_CURL_CONSTANT(CURLE_TOO_MANY_REDIRECTS);
REGISTER_CURL_CONSTANT(CURLE_UNKNOWN_TELNET_OPTION);
REGISTER_CURL_CONSTANT(CURLE_UNSUPPORTED_PROTOCOL);
REGISTER_CURL_CONSTANT(CURLE_URL_MALFORMAT);
REGISTER_CURL_CONSTANT(CURLE_URL_MALFORMAT_USER);
REGISTER_CURL_CONSTANT(CURLE_WRITE_ERROR);
/* cURL info constants */
REGISTER_CURL_CONSTANT(CURLINFO_CONNECT_TIME);
REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_LENGTH_DOWNLOAD);
REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_LENGTH_UPLOAD);
REGISTER_CURL_CONSTANT(CURLINFO_CONTENT_TYPE);
REGISTER_CURL_CONSTANT(CURLINFO_EFFECTIVE_URL);
REGISTER_CURL_CONSTANT(CURLINFO_FILETIME);
REGISTER_CURL_CONSTANT(CURLINFO_HEADER_OUT);
REGISTER_CURL_CONSTANT(CURLINFO_HEADER_SIZE);
REGISTER_CURL_CONSTANT(CURLINFO_HTTP_CODE);
REGISTER_CURL_CONSTANT(CURLINFO_LASTONE);
REGISTER_CURL_CONSTANT(CURLINFO_NAMELOOKUP_TIME);
REGISTER_CURL_CONSTANT(CURLINFO_PRETRANSFER_TIME);
REGISTER_CURL_CONSTANT(CURLINFO_PRIVATE);
REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_COUNT);
REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_TIME);
REGISTER_CURL_CONSTANT(CURLINFO_REQUEST_SIZE);
REGISTER_CURL_CONSTANT(CURLINFO_SIZE_DOWNLOAD);
REGISTER_CURL_CONSTANT(CURLINFO_SIZE_UPLOAD);
REGISTER_CURL_CONSTANT(CURLINFO_SPEED_DOWNLOAD);
REGISTER_CURL_CONSTANT(CURLINFO_SPEED_UPLOAD);
REGISTER_CURL_CONSTANT(CURLINFO_SSL_VERIFYRESULT);
REGISTER_CURL_CONSTANT(CURLINFO_STARTTRANSFER_TIME);
REGISTER_CURL_CONSTANT(CURLINFO_TOTAL_TIME);
/* Other */
REGISTER_CURL_CONSTANT(CURLMSG_DONE);
REGISTER_CURL_CONSTANT(CURLVERSION_NOW);
/* Curl Multi Constants */
REGISTER_CURL_CONSTANT(CURLM_BAD_EASY_HANDLE);
REGISTER_CURL_CONSTANT(CURLM_BAD_HANDLE);
REGISTER_CURL_CONSTANT(CURLM_CALL_MULTI_PERFORM);
REGISTER_CURL_CONSTANT(CURLM_INTERNAL_ERROR);
REGISTER_CURL_CONSTANT(CURLM_OK);
REGISTER_CURL_CONSTANT(CURLM_OUT_OF_MEMORY);
/* Curl proxy constants */
REGISTER_CURL_CONSTANT(CURLPROXY_HTTP);
REGISTER_CURL_CONSTANT(CURLPROXY_SOCKS4);
REGISTER_CURL_CONSTANT(CURLPROXY_SOCKS5);
/* Curl Share constants */
REGISTER_CURL_CONSTANT(CURLSHOPT_NONE);
REGISTER_CURL_CONSTANT(CURLSHOPT_SHARE);
REGISTER_CURL_CONSTANT(CURLSHOPT_UNSHARE);
/* Curl Http Version constants (CURLOPT_HTTP_VERSION) */
REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_1_0);
REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_1_1);
REGISTER_CURL_CONSTANT(CURL_HTTP_VERSION_NONE);
/* Curl Lock constants */
REGISTER_CURL_CONSTANT(CURL_LOCK_DATA_COOKIE);
REGISTER_CURL_CONSTANT(CURL_LOCK_DATA_DNS);
REGISTER_CURL_CONSTANT(CURL_LOCK_DATA_SSL_SESSION);
/* Curl NETRC constants (CURLOPT_NETRC) */
REGISTER_CURL_CONSTANT(CURL_NETRC_IGNORED);
REGISTER_CURL_CONSTANT(CURL_NETRC_OPTIONAL);
REGISTER_CURL_CONSTANT(CURL_NETRC_REQUIRED);
/* Curl SSL Version constants (CURLOPT_SSLVERSION) */
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_DEFAULT);
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_SSLv2);
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_SSLv3);
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_TLSv1);
/* Curl TIMECOND constants (CURLOPT_TIMECONDITION) */
REGISTER_CURL_CONSTANT(CURL_TIMECOND_IFMODSINCE);
REGISTER_CURL_CONSTANT(CURL_TIMECOND_IFUNMODSINCE);
REGISTER_CURL_CONSTANT(CURL_TIMECOND_LASTMOD);
REGISTER_CURL_CONSTANT(CURL_TIMECOND_NONE);
/* Curl version constants */
REGISTER_CURL_CONSTANT(CURL_VERSION_IPV6);
REGISTER_CURL_CONSTANT(CURL_VERSION_KERBEROS4);
REGISTER_CURL_CONSTANT(CURL_VERSION_LIBZ);
REGISTER_CURL_CONSTANT(CURL_VERSION_SSL);
#if LIBCURL_VERSION_NUM >= 0x070a06 /* Available since 7.10.6 */
REGISTER_CURL_CONSTANT(CURLOPT_HTTPAUTH);
/* http authentication options */
REGISTER_CURL_CONSTANT(CURLAUTH_ANY);
REGISTER_CURL_CONSTANT(CURLAUTH_ANYSAFE);
REGISTER_CURL_CONSTANT(CURLAUTH_BASIC);
REGISTER_CURL_CONSTANT(CURLAUTH_DIGEST);
REGISTER_CURL_CONSTANT(CURLAUTH_GSSNEGOTIATE);
REGISTER_CURL_CONSTANT(CURLAUTH_NONE);
REGISTER_CURL_CONSTANT(CURLAUTH_NTLM);
#endif
#if LIBCURL_VERSION_NUM >= 0x070a07 /* Available since 7.10.7 */
REGISTER_CURL_CONSTANT(CURLINFO_HTTP_CONNECTCODE);
REGISTER_CURL_CONSTANT(CURLOPT_FTP_CREATE_MISSING_DIRS);
REGISTER_CURL_CONSTANT(CURLOPT_PROXYAUTH);
#endif
#if LIBCURL_VERSION_NUM >= 0x070a08 /* Available since 7.10.8 */
REGISTER_CURL_CONSTANT(CURLE_FILESIZE_EXCEEDED);
REGISTER_CURL_CONSTANT(CURLE_LDAP_INVALID_URL);
REGISTER_CURL_CONSTANT(CURLINFO_HTTPAUTH_AVAIL);
REGISTER_CURL_CONSTANT(CURLINFO_RESPONSE_CODE);
REGISTER_CURL_CONSTANT(CURLINFO_PROXYAUTH_AVAIL);
REGISTER_CURL_CONSTANT(CURLOPT_FTP_RESPONSE_TIMEOUT);
REGISTER_CURL_CONSTANT(CURLOPT_IPRESOLVE);
REGISTER_CURL_CONSTANT(CURLOPT_MAXFILESIZE);
REGISTER_CURL_CONSTANT(CURL_IPRESOLVE_V4);
REGISTER_CURL_CONSTANT(CURL_IPRESOLVE_V6);
REGISTER_CURL_CONSTANT(CURL_IPRESOLVE_WHATEVER);
#endif
#if LIBCURL_VERSION_NUM >= 0x070b00 /* Available since 7.11.0 */
REGISTER_CURL_CONSTANT(CURLE_FTP_SSL_FAILED);
REGISTER_CURL_CONSTANT(CURLFTPSSL_ALL);
REGISTER_CURL_CONSTANT(CURLFTPSSL_CONTROL);
REGISTER_CURL_CONSTANT(CURLFTPSSL_NONE);
REGISTER_CURL_CONSTANT(CURLFTPSSL_TRY);
REGISTER_CURL_CONSTANT(CURLOPT_FTP_SSL);
REGISTER_CURL_CONSTANT(CURLOPT_NETRC_FILE);
#endif
#if LIBCURL_VERSION_NUM >= 0x070c02 /* Available since 7.12.2 */
REGISTER_CURL_CONSTANT(CURLFTPAUTH_DEFAULT);
REGISTER_CURL_CONSTANT(CURLFTPAUTH_SSL);
REGISTER_CURL_CONSTANT(CURLFTPAUTH_TLS);
REGISTER_CURL_CONSTANT(CURLOPT_FTPSSLAUTH);
#endif
#if LIBCURL_VERSION_NUM >= 0x070d00 /* Available since 7.13.0 */
REGISTER_CURL_CONSTANT(CURLOPT_FTP_ACCOUNT);
#endif
#if LIBCURL_VERSION_NUM >= 0x070b02 /* Available since 7.11.2 */
REGISTER_CURL_CONSTANT(CURLOPT_TCP_NODELAY);
#endif
#if LIBCURL_VERSION_NUM >= 0x070c02 /* Available since 7.12.2 */
REGISTER_CURL_CONSTANT(CURLINFO_OS_ERRNO);
#endif
#if LIBCURL_VERSION_NUM >= 0x070c03 /* Available since 7.12.3 */
REGISTER_CURL_CONSTANT(CURLINFO_NUM_CONNECTS);
REGISTER_CURL_CONSTANT(CURLINFO_SSL_ENGINES);
#endif
#if LIBCURL_VERSION_NUM >= 0x070e01 /* Available since 7.14.1 */
REGISTER_CURL_CONSTANT(CURLINFO_COOKIELIST);
REGISTER_CURL_CONSTANT(CURLOPT_COOKIELIST);
REGISTER_CURL_CONSTANT(CURLOPT_IGNORE_CONTENT_LENGTH);
#endif
#if LIBCURL_VERSION_NUM >= 0x070f00 /* Available since 7.15.0 */
REGISTER_CURL_CONSTANT(CURLOPT_FTP_SKIP_PASV_IP);
#endif
#if LIBCURL_VERSION_NUM >= 0x070f01 /* Available since 7.15.1 */
REGISTER_CURL_CONSTANT(CURLOPT_FTP_FILEMETHOD);
#endif
#if LIBCURL_VERSION_NUM >= 0x070f02 /* Available since 7.15.2 */
REGISTER_CURL_CONSTANT(CURLOPT_CONNECT_ONLY);
REGISTER_CURL_CONSTANT(CURLOPT_LOCALPORT);
REGISTER_CURL_CONSTANT(CURLOPT_LOCALPORTRANGE);
#endif
#if LIBCURL_VERSION_NUM >= 0x070f03 /* Available since 7.15.3 */
REGISTER_CURL_CONSTANT(CURLFTPMETHOD_MULTICWD);
REGISTER_CURL_CONSTANT(CURLFTPMETHOD_NOCWD);
REGISTER_CURL_CONSTANT(CURLFTPMETHOD_SINGLECWD);
#endif
#if LIBCURL_VERSION_NUM >= 0x070f04 /* Available since 7.15.4 */
REGISTER_CURL_CONSTANT(CURLINFO_FTP_ENTRY_PATH);
#endif
#if LIBCURL_VERSION_NUM >= 0x070f05 /* Available since 7.15.5 */
REGISTER_CURL_CONSTANT(CURLOPT_FTP_ALTERNATIVE_TO_USER);
REGISTER_CURL_CONSTANT(CURLOPT_MAX_RECV_SPEED_LARGE);
REGISTER_CURL_CONSTANT(CURLOPT_MAX_SEND_SPEED_LARGE);
#endif
#if LIBCURL_VERSION_NUM >= 0x071000 /* Available since 7.16.0 */
REGISTER_CURL_CONSTANT(CURLOPT_SSL_SESSIONID_CACHE);
REGISTER_CURL_CONSTANT(CURLMOPT_PIPELINING);
#endif
#if LIBCURL_VERSION_NUM >= 0x071001 /* Available since 7.16.1 */
REGISTER_CURL_CONSTANT(CURLE_SSH);
REGISTER_CURL_CONSTANT(CURLOPT_FTP_SSL_CCC);
REGISTER_CURL_CONSTANT(CURLOPT_SSH_AUTH_TYPES);
REGISTER_CURL_CONSTANT(CURLOPT_SSH_PRIVATE_KEYFILE);
REGISTER_CURL_CONSTANT(CURLOPT_SSH_PUBLIC_KEYFILE);
REGISTER_CURL_CONSTANT(CURLFTPSSL_CCC_ACTIVE);
REGISTER_CURL_CONSTANT(CURLFTPSSL_CCC_NONE);
REGISTER_CURL_CONSTANT(CURLFTPSSL_CCC_PASSIVE);
#endif
#if LIBCURL_VERSION_NUM >= 0x071002 /* Available since 7.16.2 */
REGISTER_CURL_CONSTANT(CURLOPT_CONNECTTIMEOUT_MS);
REGISTER_CURL_CONSTANT(CURLOPT_HTTP_CONTENT_DECODING);
REGISTER_CURL_CONSTANT(CURLOPT_HTTP_TRANSFER_DECODING);
REGISTER_CURL_CONSTANT(CURLOPT_TIMEOUT_MS);
#endif
#if LIBCURL_VERSION_NUM >= 0x071003 /* Available since 7.16.3 */
REGISTER_CURL_CONSTANT(CURLMOPT_MAXCONNECTS);
#endif
#if LIBCURL_VERSION_NUM >= 0x071004 /* Available since 7.16.4 */
REGISTER_CURL_CONSTANT(CURLOPT_KRBLEVEL);
REGISTER_CURL_CONSTANT(CURLOPT_NEW_DIRECTORY_PERMS);
REGISTER_CURL_CONSTANT(CURLOPT_NEW_FILE_PERMS);
#endif
#if LIBCURL_VERSION_NUM >= 0x071100 /* Available since 7.17.0 */
REGISTER_CURL_CONSTANT(CURLOPT_APPEND);
REGISTER_CURL_CONSTANT(CURLOPT_DIRLISTONLY);
REGISTER_CURL_CONSTANT(CURLOPT_USE_SSL);
/* Curl SSL Constants */
REGISTER_CURL_CONSTANT(CURLUSESSL_ALL);
REGISTER_CURL_CONSTANT(CURLUSESSL_CONTROL);
REGISTER_CURL_CONSTANT(CURLUSESSL_NONE);
REGISTER_CURL_CONSTANT(CURLUSESSL_TRY);
#endif
#if LIBCURL_VERSION_NUM >= 0x071101 /* Available since 7.17.1 */
REGISTER_CURL_CONSTANT(CURLOPT_SSH_HOST_PUBLIC_KEY_MD5);
#endif
#if LIBCURL_VERSION_NUM >= 0x071200 /* Available since 7.18.0 */
REGISTER_CURL_CONSTANT(CURLOPT_PROXY_TRANSFER_MODE);
REGISTER_CURL_CONSTANT(CURLPAUSE_ALL);
REGISTER_CURL_CONSTANT(CURLPAUSE_CONT);
REGISTER_CURL_CONSTANT(CURLPAUSE_RECV);
REGISTER_CURL_CONSTANT(CURLPAUSE_RECV_CONT);
REGISTER_CURL_CONSTANT(CURLPAUSE_SEND);
REGISTER_CURL_CONSTANT(CURLPAUSE_SEND_CONT);
REGISTER_CURL_CONSTANT(CURL_READFUNC_PAUSE);
REGISTER_CURL_CONSTANT(CURL_WRITEFUNC_PAUSE);
#endif
#if LIBCURL_VERSION_NUM >= 0x071202 /* Available since 7.18.2 */
REGISTER_CURL_CONSTANT(CURLINFO_REDIRECT_URL);
#endif
#if LIBCURL_VERSION_NUM >= 0x071300 /* Available since 7.19.0 */
REGISTER_CURL_CONSTANT(CURLINFO_APPCONNECT_TIME);
REGISTER_CURL_CONSTANT(CURLINFO_PRIMARY_IP);
REGISTER_CURL_CONSTANT(CURLOPT_ADDRESS_SCOPE);
REGISTER_CURL_CONSTANT(CURLOPT_CRLFILE);
REGISTER_CURL_CONSTANT(CURLOPT_ISSUERCERT);
REGISTER_CURL_CONSTANT(CURLOPT_KEYPASSWD);
REGISTER_CURL_CONSTANT(CURLSSH_AUTH_ANY);
REGISTER_CURL_CONSTANT(CURLSSH_AUTH_DEFAULT);
REGISTER_CURL_CONSTANT(CURLSSH_AUTH_HOST);
REGISTER_CURL_CONSTANT(CURLSSH_AUTH_KEYBOARD);
REGISTER_CURL_CONSTANT(CURLSSH_AUTH_NONE);
REGISTER_CURL_CONSTANT(CURLSSH_AUTH_PASSWORD);
REGISTER_CURL_CONSTANT(CURLSSH_AUTH_PUBLICKEY);
#endif
#if LIBCURL_VERSION_NUM >= 0x071301 /* Available since 7.19.1 */
REGISTER_CURL_CONSTANT(CURLINFO_CERTINFO);
REGISTER_CURL_CONSTANT(CURLOPT_CERTINFO);
REGISTER_CURL_CONSTANT(CURLOPT_PASSWORD);
REGISTER_CURL_CONSTANT(CURLOPT_POSTREDIR);
REGISTER_CURL_CONSTANT(CURLOPT_PROXYPASSWORD);
REGISTER_CURL_CONSTANT(CURLOPT_PROXYUSERNAME);
REGISTER_CURL_CONSTANT(CURLOPT_USERNAME);
#endif
#if LIBCURL_VERSION_NUM >= 0x071303 /* Available since 7.19.3 */
REGISTER_CURL_CONSTANT(CURLAUTH_DIGEST_IE);
#endif
#if LIBCURL_VERSION_NUM >= 0x071304 /* Available since 7.19.4 */
REGISTER_CURL_CONSTANT(CURLINFO_CONDITION_UNMET);
REGISTER_CURL_CONSTANT(CURLOPT_NOPROXY);
REGISTER_CURL_CONSTANT(CURLOPT_PROTOCOLS);
REGISTER_CURL_CONSTANT(CURLOPT_REDIR_PROTOCOLS);
REGISTER_CURL_CONSTANT(CURLOPT_SOCKS5_GSSAPI_NEC);
REGISTER_CURL_CONSTANT(CURLOPT_SOCKS5_GSSAPI_SERVICE);
REGISTER_CURL_CONSTANT(CURLOPT_TFTP_BLKSIZE);
REGISTER_CURL_CONSTANT(CURLPROTO_ALL);
REGISTER_CURL_CONSTANT(CURLPROTO_DICT);
REGISTER_CURL_CONSTANT(CURLPROTO_FILE);
REGISTER_CURL_CONSTANT(CURLPROTO_FTP);
REGISTER_CURL_CONSTANT(CURLPROTO_FTPS);
REGISTER_CURL_CONSTANT(CURLPROTO_HTTP);
REGISTER_CURL_CONSTANT(CURLPROTO_HTTPS);
REGISTER_CURL_CONSTANT(CURLPROTO_LDAP);
REGISTER_CURL_CONSTANT(CURLPROTO_LDAPS);
REGISTER_CURL_CONSTANT(CURLPROTO_SCP);
REGISTER_CURL_CONSTANT(CURLPROTO_SFTP);
REGISTER_CURL_CONSTANT(CURLPROTO_TELNET);
REGISTER_CURL_CONSTANT(CURLPROTO_TFTP);
#endif
#if LIBCURL_VERSION_NUM >= 0x071306 /* Available since 7.19.6 */
REGISTER_CURL_CONSTANT(CURLOPT_SSH_KNOWNHOSTS);
#endif
#if LIBCURL_VERSION_NUM >= 0x071400 /* Available since 7.20.0 */
REGISTER_CURL_CONSTANT(CURLINFO_RTSP_CLIENT_CSEQ);
REGISTER_CURL_CONSTANT(CURLINFO_RTSP_CSEQ_RECV);
REGISTER_CURL_CONSTANT(CURLINFO_RTSP_SERVER_CSEQ);
REGISTER_CURL_CONSTANT(CURLINFO_RTSP_SESSION_ID);
REGISTER_CURL_CONSTANT(CURLOPT_FTP_USE_PRET);
REGISTER_CURL_CONSTANT(CURLOPT_MAIL_FROM);
REGISTER_CURL_CONSTANT(CURLOPT_MAIL_RCPT);
REGISTER_CURL_CONSTANT(CURLOPT_RTSP_CLIENT_CSEQ);
REGISTER_CURL_CONSTANT(CURLOPT_RTSP_REQUEST);
REGISTER_CURL_CONSTANT(CURLOPT_RTSP_SERVER_CSEQ);
REGISTER_CURL_CONSTANT(CURLOPT_RTSP_SESSION_ID);
REGISTER_CURL_CONSTANT(CURLOPT_RTSP_STREAM_URI);
REGISTER_CURL_CONSTANT(CURLOPT_RTSP_TRANSPORT);
REGISTER_CURL_CONSTANT(CURLPROTO_IMAP);
REGISTER_CURL_CONSTANT(CURLPROTO_IMAPS);
REGISTER_CURL_CONSTANT(CURLPROTO_POP3);
REGISTER_CURL_CONSTANT(CURLPROTO_POP3S);
REGISTER_CURL_CONSTANT(CURLPROTO_RTSP);
REGISTER_CURL_CONSTANT(CURLPROTO_SMTP);
REGISTER_CURL_CONSTANT(CURLPROTO_SMTPS);
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_ANNOUNCE);
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_DESCRIBE);
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_GET_PARAMETER);
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_OPTIONS);
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_PAUSE);
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_PLAY);
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_RECEIVE);
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_RECORD);
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_SETUP);
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_SET_PARAMETER);
REGISTER_CURL_CONSTANT(CURL_RTSPREQ_TEARDOWN);
#endif
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
REGISTER_CURL_CONSTANT(CURLINFO_LOCAL_IP);
REGISTER_CURL_CONSTANT(CURLINFO_LOCAL_PORT);
REGISTER_CURL_CONSTANT(CURLINFO_PRIMARY_PORT);
REGISTER_CURL_CONSTANT(CURLOPT_FNMATCH_FUNCTION);
REGISTER_CURL_CONSTANT(CURLOPT_WILDCARDMATCH);
REGISTER_CURL_CONSTANT(CURLPROTO_RTMP);
REGISTER_CURL_CONSTANT(CURLPROTO_RTMPE);
REGISTER_CURL_CONSTANT(CURLPROTO_RTMPS);
REGISTER_CURL_CONSTANT(CURLPROTO_RTMPT);
REGISTER_CURL_CONSTANT(CURLPROTO_RTMPTE);
REGISTER_CURL_CONSTANT(CURLPROTO_RTMPTS);
REGISTER_CURL_CONSTANT(CURL_FNMATCHFUNC_FAIL);
REGISTER_CURL_CONSTANT(CURL_FNMATCHFUNC_MATCH);
REGISTER_CURL_CONSTANT(CURL_FNMATCHFUNC_NOMATCH);
#endif
#if LIBCURL_VERSION_NUM >= 0x071502 /* Available since 7.21.2 */
REGISTER_CURL_CONSTANT(CURLPROTO_GOPHER);
#endif
#if LIBCURL_VERSION_NUM >= 0x071503 /* Available since 7.21.3 */
REGISTER_CURL_CONSTANT(CURLAUTH_ONLY);
REGISTER_CURL_CONSTANT(CURLOPT_RESOLVE);
#endif
#if LIBCURL_VERSION_NUM >= 0x071504 /* Available since 7.21.4 */
REGISTER_CURL_CONSTANT(CURLOPT_TLSAUTH_PASSWORD);
REGISTER_CURL_CONSTANT(CURLOPT_TLSAUTH_TYPE);
REGISTER_CURL_CONSTANT(CURLOPT_TLSAUTH_USERNAME);
REGISTER_CURL_CONSTANT(CURL_TLSAUTH_SRP);
#endif
#if LIBCURL_VERSION_NUM >= 0x071506 /* Available since 7.21.6 */
REGISTER_CURL_CONSTANT(CURLOPT_ACCEPT_ENCODING);
REGISTER_CURL_CONSTANT(CURLOPT_TRANSFER_ENCODING);
#endif
#if LIBCURL_VERSION_NUM >= 0x071600 /* Available since 7.22.0 */
REGISTER_CURL_CONSTANT(CURLGSSAPI_DELEGATION_FLAG);
REGISTER_CURL_CONSTANT(CURLGSSAPI_DELEGATION_POLICY_FLAG);
REGISTER_CURL_CONSTANT(CURLOPT_GSSAPI_DELEGATION);
#endif
#if LIBCURL_VERSION_NUM >= 0x071800 /* Available since 7.24.0 */
REGISTER_CURL_CONSTANT(CURLOPT_ACCEPTTIMEOUT_MS);
REGISTER_CURL_CONSTANT(CURLOPT_DNS_SERVERS);
#endif
#if LIBCURL_VERSION_NUM >= 0x071900 /* Available since 7.25.0 */
REGISTER_CURL_CONSTANT(CURLOPT_MAIL_AUTH);
REGISTER_CURL_CONSTANT(CURLOPT_SSL_OPTIONS);
REGISTER_CURL_CONSTANT(CURLOPT_TCP_KEEPALIVE);
REGISTER_CURL_CONSTANT(CURLOPT_TCP_KEEPIDLE);
REGISTER_CURL_CONSTANT(CURLOPT_TCP_KEEPINTVL);
REGISTER_CURL_CONSTANT(CURLSSLOPT_ALLOW_BEAST);
#endif
#if LIBCURL_VERSION_NUM >= 0x072200 /* Available since 7.34.0 */
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_TLSv1_0);
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_TLSv1_1);
REGISTER_CURL_CONSTANT(CURL_SSLVERSION_TLSv1_2);
#endif
#if CURLOPT_FTPASCII != 0
REGISTER_CURL_CONSTANT(CURLOPT_FTPASCII);
#endif
#if CURLOPT_MUTE != 0
REGISTER_CURL_CONSTANT(CURLOPT_MUTE);
#endif
#if CURLOPT_PASSWDFUNCTION != 0
REGISTER_CURL_CONSTANT(CURLOPT_PASSWDFUNCTION);
#endif
REGISTER_CURL_CONSTANT(CURLOPT_SAFE_UPLOAD);
#ifdef PHP_CURL_NEED_OPENSSL_TSL
if (!CRYPTO_get_id_callback()) {
int i, c = CRYPTO_num_locks();
php_curl_openssl_tsl = malloc(c * sizeof(MUTEX_T));
if (!php_curl_openssl_tsl) {
return FAILURE;
}
for (i = 0; i < c; ++i) {
php_curl_openssl_tsl[i] = tsrm_mutex_alloc();
}
CRYPTO_set_id_callback(php_curl_ssl_id);
CRYPTO_set_locking_callback(php_curl_ssl_lock);
}
#endif
#ifdef PHP_CURL_NEED_GNUTLS_TSL
gcry_control(GCRYCTL_SET_THREAD_CBS, &php_curl_gnutls_tsl);
#endif
if (curl_global_init(CURL_GLOBAL_SSL) != CURLE_OK) {
return FAILURE;
}
curlfile_register_class();
return SUCCESS;
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,034
|
PHP_MSHUTDOWN_FUNCTION(curl)
{
curl_global_cleanup();
#ifdef PHP_CURL_NEED_OPENSSL_TSL
if (php_curl_openssl_tsl) {
int i, c = CRYPTO_num_locks();
CRYPTO_set_id_callback(NULL);
CRYPTO_set_locking_callback(NULL);
for (i = 0; i < c; ++i) {
tsrm_mutex_free(php_curl_openssl_tsl[i]);
}
free(php_curl_openssl_tsl);
php_curl_openssl_tsl = NULL;
}
#endif
UNREGISTER_INI_ENTRIES();
return SUCCESS;
}
|
DoS
| 0
|
PHP_MSHUTDOWN_FUNCTION(curl)
{
curl_global_cleanup();
#ifdef PHP_CURL_NEED_OPENSSL_TSL
if (php_curl_openssl_tsl) {
int i, c = CRYPTO_num_locks();
CRYPTO_set_id_callback(NULL);
CRYPTO_set_locking_callback(NULL);
for (i = 0; i < c; ++i) {
tsrm_mutex_free(php_curl_openssl_tsl[i]);
}
free(php_curl_openssl_tsl);
php_curl_openssl_tsl = NULL;
}
#endif
UNREGISTER_INI_ENTRIES();
return SUCCESS;
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,035
|
void _php_curl_cleanup_handle(php_curl *ch)
{
smart_str_free(&ch->handlers->write->buf);
if (ch->header.str) {
zend_string_release(ch->header.str);
ch->header.str = NULL;
}
memset(ch->err.str, 0, CURL_ERROR_SIZE + 1);
ch->err.no = 0;
}
|
DoS
| 0
|
void _php_curl_cleanup_handle(php_curl *ch)
{
smart_str_free(&ch->handlers->write->buf);
if (ch->header.str) {
zend_string_release(ch->header.str);
ch->header.str = NULL;
}
memset(ch->err.str, 0, CURL_ERROR_SIZE + 1);
ch->err.no = 0;
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,036
|
static void _php_curl_close(zend_resource *rsrc)
{
php_curl *ch = (php_curl *) rsrc->ptr;
_php_curl_close_ex(ch);
}
|
DoS
| 0
|
static void _php_curl_close(zend_resource *rsrc)
{
php_curl *ch = (php_curl *) rsrc->ptr;
_php_curl_close_ex(ch);
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,037
|
static void _php_curl_close_ex(php_curl *ch)
{
#if PHP_CURL_DEBUG
fprintf(stderr, "DTOR CALLED, ch = %x\n", ch);
#endif
_php_curl_verify_handlers(ch, 0);
/*
* Libcurl is doing connection caching. When easy handle is cleaned up,
* if the handle was previously used by the curl_multi_api, the connection
* remains open un the curl multi handle is cleaned up. Some protocols are
* sending content like the FTP one, and libcurl try to use the
* WRITEFUNCTION or the HEADERFUNCTION. Since structures used in those
* callback are freed, we need to use an other callback to which avoid
* segfaults.
*
* Libcurl commit d021f2e8a00 fix this issue and should be part of 7.28.2
*/
curl_easy_setopt(ch->cp, CURLOPT_HEADERFUNCTION, curl_write_nothing);
curl_easy_setopt(ch->cp, CURLOPT_WRITEFUNCTION, curl_write_nothing);
curl_easy_cleanup(ch->cp);
/* cURL destructors should be invoked only by last curl handle */
if (--ch->clone == 0) {
zend_llist_clean(&ch->to_free->str);
zend_llist_clean(&ch->to_free->post);
zend_hash_destroy(ch->to_free->slist);
efree(ch->to_free->slist);
efree(ch->to_free);
}
smart_str_free(&ch->handlers->write->buf);
zval_ptr_dtor(&ch->handlers->write->func_name);
zval_ptr_dtor(&ch->handlers->read->func_name);
zval_ptr_dtor(&ch->handlers->write_header->func_name);
#if CURLOPT_PASSWDFUNCTION != 0
zval_ptr_dtor(&ch->handlers->passwd);
#endif
zval_ptr_dtor(&ch->handlers->std_err);
if (ch->header.str) {
zend_string_release(ch->header.str);
}
zval_ptr_dtor(&ch->handlers->write_header->stream);
zval_ptr_dtor(&ch->handlers->write->stream);
zval_ptr_dtor(&ch->handlers->read->stream);
efree(ch->handlers->write);
efree(ch->handlers->write_header);
efree(ch->handlers->read);
if (ch->handlers->progress) {
zval_ptr_dtor(&ch->handlers->progress->func_name);
efree(ch->handlers->progress);
}
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
if (ch->handlers->fnmatch) {
zval_ptr_dtor(&ch->handlers->fnmatch->func_name);
efree(ch->handlers->fnmatch);
}
#endif
efree(ch->handlers);
efree(ch);
}
|
DoS
| 0
|
static void _php_curl_close_ex(php_curl *ch)
{
#if PHP_CURL_DEBUG
fprintf(stderr, "DTOR CALLED, ch = %x\n", ch);
#endif
_php_curl_verify_handlers(ch, 0);
/*
* Libcurl is doing connection caching. When easy handle is cleaned up,
* if the handle was previously used by the curl_multi_api, the connection
* remains open un the curl multi handle is cleaned up. Some protocols are
* sending content like the FTP one, and libcurl try to use the
* WRITEFUNCTION or the HEADERFUNCTION. Since structures used in those
* callback are freed, we need to use an other callback to which avoid
* segfaults.
*
* Libcurl commit d021f2e8a00 fix this issue and should be part of 7.28.2
*/
curl_easy_setopt(ch->cp, CURLOPT_HEADERFUNCTION, curl_write_nothing);
curl_easy_setopt(ch->cp, CURLOPT_WRITEFUNCTION, curl_write_nothing);
curl_easy_cleanup(ch->cp);
/* cURL destructors should be invoked only by last curl handle */
if (--ch->clone == 0) {
zend_llist_clean(&ch->to_free->str);
zend_llist_clean(&ch->to_free->post);
zend_hash_destroy(ch->to_free->slist);
efree(ch->to_free->slist);
efree(ch->to_free);
}
smart_str_free(&ch->handlers->write->buf);
zval_ptr_dtor(&ch->handlers->write->func_name);
zval_ptr_dtor(&ch->handlers->read->func_name);
zval_ptr_dtor(&ch->handlers->write_header->func_name);
#if CURLOPT_PASSWDFUNCTION != 0
zval_ptr_dtor(&ch->handlers->passwd);
#endif
zval_ptr_dtor(&ch->handlers->std_err);
if (ch->header.str) {
zend_string_release(ch->header.str);
}
zval_ptr_dtor(&ch->handlers->write_header->stream);
zval_ptr_dtor(&ch->handlers->write->stream);
zval_ptr_dtor(&ch->handlers->read->stream);
efree(ch->handlers->write);
efree(ch->handlers->write_header);
efree(ch->handlers->read);
if (ch->handlers->progress) {
zval_ptr_dtor(&ch->handlers->progress->func_name);
efree(ch->handlers->progress);
}
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
if (ch->handlers->fnmatch) {
zval_ptr_dtor(&ch->handlers->fnmatch->func_name);
efree(ch->handlers->fnmatch);
}
#endif
efree(ch->handlers);
efree(ch);
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,038
|
static void _php_curl_reset_handlers(php_curl *ch)
{
if (!Z_ISUNDEF(ch->handlers->write->stream)) {
zval_ptr_dtor(&ch->handlers->write->stream);
ZVAL_UNDEF(&ch->handlers->write->stream);
}
ch->handlers->write->fp = NULL;
ch->handlers->write->method = PHP_CURL_STDOUT;
if (!Z_ISUNDEF(ch->handlers->write_header->stream)) {
zval_ptr_dtor(&ch->handlers->write_header->stream);
ZVAL_UNDEF(&ch->handlers->write_header->stream);
}
ch->handlers->write_header->fp = NULL;
ch->handlers->write_header->method = PHP_CURL_IGNORE;
if (!Z_ISUNDEF(ch->handlers->read->stream)) {
zval_ptr_dtor(&ch->handlers->read->stream);
ZVAL_UNDEF(&ch->handlers->read->stream);
}
ch->handlers->read->fp = NULL;
ch->handlers->read->res = NULL;
ch->handlers->read->method = PHP_CURL_DIRECT;
if (!Z_ISUNDEF(ch->handlers->std_err)) {
zval_ptr_dtor(&ch->handlers->std_err);
ZVAL_UNDEF(&ch->handlers->std_err);
}
if (ch->handlers->progress) {
zval_ptr_dtor(&ch->handlers->progress->func_name);
efree(ch->handlers->progress);
ch->handlers->progress = NULL;
}
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
if (ch->handlers->fnmatch) {
zval_ptr_dtor(&ch->handlers->fnmatch->func_name);
efree(ch->handlers->fnmatch);
ch->handlers->fnmatch = NULL;
}
#endif
}
|
DoS
| 0
|
static void _php_curl_reset_handlers(php_curl *ch)
{
if (!Z_ISUNDEF(ch->handlers->write->stream)) {
zval_ptr_dtor(&ch->handlers->write->stream);
ZVAL_UNDEF(&ch->handlers->write->stream);
}
ch->handlers->write->fp = NULL;
ch->handlers->write->method = PHP_CURL_STDOUT;
if (!Z_ISUNDEF(ch->handlers->write_header->stream)) {
zval_ptr_dtor(&ch->handlers->write_header->stream);
ZVAL_UNDEF(&ch->handlers->write_header->stream);
}
ch->handlers->write_header->fp = NULL;
ch->handlers->write_header->method = PHP_CURL_IGNORE;
if (!Z_ISUNDEF(ch->handlers->read->stream)) {
zval_ptr_dtor(&ch->handlers->read->stream);
ZVAL_UNDEF(&ch->handlers->read->stream);
}
ch->handlers->read->fp = NULL;
ch->handlers->read->res = NULL;
ch->handlers->read->method = PHP_CURL_DIRECT;
if (!Z_ISUNDEF(ch->handlers->std_err)) {
zval_ptr_dtor(&ch->handlers->std_err);
ZVAL_UNDEF(&ch->handlers->std_err);
}
if (ch->handlers->progress) {
zval_ptr_dtor(&ch->handlers->progress->func_name);
efree(ch->handlers->progress);
ch->handlers->progress = NULL;
}
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
if (ch->handlers->fnmatch) {
zval_ptr_dtor(&ch->handlers->fnmatch->func_name);
efree(ch->handlers->fnmatch);
ch->handlers->fnmatch = NULL;
}
#endif
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,039
|
static void _php_curl_set_default_options(php_curl *ch)
{
char *cainfo;
curl_easy_setopt(ch->cp, CURLOPT_NOPROGRESS, 1);
curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0);
curl_easy_setopt(ch->cp, CURLOPT_ERRORBUFFER, ch->err.str);
curl_easy_setopt(ch->cp, CURLOPT_WRITEFUNCTION, curl_write);
curl_easy_setopt(ch->cp, CURLOPT_FILE, (void *) ch);
curl_easy_setopt(ch->cp, CURLOPT_READFUNCTION, curl_read);
curl_easy_setopt(ch->cp, CURLOPT_INFILE, (void *) ch);
curl_easy_setopt(ch->cp, CURLOPT_HEADERFUNCTION, curl_write_header);
curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch);
curl_easy_setopt(ch->cp, CURLOPT_DNS_USE_GLOBAL_CACHE, 1);
curl_easy_setopt(ch->cp, CURLOPT_DNS_CACHE_TIMEOUT, 120);
curl_easy_setopt(ch->cp, CURLOPT_MAXREDIRS, 20); /* prevent infinite redirects */
cainfo = INI_STR("openssl.cafile");
if (!(cainfo && cainfo[0] != '\0')) {
cainfo = INI_STR("curl.cainfo");
}
if (cainfo && cainfo[0] != '\0') {
curl_easy_setopt(ch->cp, CURLOPT_CAINFO, cainfo);
}
#if defined(ZTS)
curl_easy_setopt(ch->cp, CURLOPT_NOSIGNAL, 1);
#endif
}
|
DoS
| 0
|
static void _php_curl_set_default_options(php_curl *ch)
{
char *cainfo;
curl_easy_setopt(ch->cp, CURLOPT_NOPROGRESS, 1);
curl_easy_setopt(ch->cp, CURLOPT_VERBOSE, 0);
curl_easy_setopt(ch->cp, CURLOPT_ERRORBUFFER, ch->err.str);
curl_easy_setopt(ch->cp, CURLOPT_WRITEFUNCTION, curl_write);
curl_easy_setopt(ch->cp, CURLOPT_FILE, (void *) ch);
curl_easy_setopt(ch->cp, CURLOPT_READFUNCTION, curl_read);
curl_easy_setopt(ch->cp, CURLOPT_INFILE, (void *) ch);
curl_easy_setopt(ch->cp, CURLOPT_HEADERFUNCTION, curl_write_header);
curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch);
curl_easy_setopt(ch->cp, CURLOPT_DNS_USE_GLOBAL_CACHE, 1);
curl_easy_setopt(ch->cp, CURLOPT_DNS_CACHE_TIMEOUT, 120);
curl_easy_setopt(ch->cp, CURLOPT_MAXREDIRS, 20); /* prevent infinite redirects */
cainfo = INI_STR("openssl.cafile");
if (!(cainfo && cainfo[0] != '\0')) {
cainfo = INI_STR("curl.cainfo");
}
if (cainfo && cainfo[0] != '\0') {
curl_easy_setopt(ch->cp, CURLOPT_CAINFO, cainfo);
}
#if defined(ZTS)
curl_easy_setopt(ch->cp, CURLOPT_NOSIGNAL, 1);
#endif
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,040
|
void _php_curl_verify_handlers(php_curl *ch, int reporterror) /* {{{ */
{
php_stream *stream;
if (!ch || !ch->handlers) {
return;
}
if (!Z_ISUNDEF(ch->handlers->std_err)) {
stream = zend_fetch_resource(&ch->handlers->std_err, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());
if (stream == NULL) {
if (reporterror) {
php_error_docref(NULL, E_WARNING, "CURLOPT_STDERR resource has gone away, resetting to stderr");
}
zval_ptr_dtor(&ch->handlers->std_err);
ZVAL_UNDEF(&ch->handlers->std_err);
curl_easy_setopt(ch->cp, CURLOPT_STDERR, stderr);
}
}
if (ch->handlers->read && !Z_ISUNDEF(ch->handlers->read->stream)) {
stream = zend_fetch_resource(&ch->handlers->read->stream, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());
if (stream == NULL) {
if (reporterror) {
php_error_docref(NULL, E_WARNING, "CURLOPT_INFILE resource has gone away, resetting to default");
}
zval_ptr_dtor(&ch->handlers->read->stream);
ZVAL_UNDEF(&ch->handlers->read->stream);
ch->handlers->read->res = NULL;
ch->handlers->read->fp = 0;
curl_easy_setopt(ch->cp, CURLOPT_INFILE, (void *) ch);
}
}
if (ch->handlers->write_header && !Z_ISUNDEF(ch->handlers->write_header->stream)) {
stream = zend_fetch_resource(&ch->handlers->write_header->stream, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());
if (stream == NULL) {
if (reporterror) {
php_error_docref(NULL, E_WARNING, "CURLOPT_WRITEHEADER resource has gone away, resetting to default");
}
zval_ptr_dtor(&ch->handlers->write_header->stream);
ZVAL_UNDEF(&ch->handlers->write_header->stream);
ch->handlers->write_header->fp = 0;
ch->handlers->write_header->method = PHP_CURL_IGNORE;
curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch);
}
}
if (ch->handlers->write && !Z_ISUNDEF(ch->handlers->write->stream)) {
stream = zend_fetch_resource(&ch->handlers->write->stream, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());
if (stream == NULL) {
if (reporterror) {
php_error_docref(NULL, E_WARNING, "CURLOPT_FILE resource has gone away, resetting to default");
}
zval_ptr_dtor(&ch->handlers->write->stream);
ZVAL_UNDEF(&ch->handlers->write->stream);
ch->handlers->write->fp = 0;
ch->handlers->write->method = PHP_CURL_STDOUT;
curl_easy_setopt(ch->cp, CURLOPT_FILE, (void *) ch);
}
}
return ;
}
/* }}} */
|
DoS
| 0
|
void _php_curl_verify_handlers(php_curl *ch, int reporterror) /* {{{ */
{
php_stream *stream;
if (!ch || !ch->handlers) {
return;
}
if (!Z_ISUNDEF(ch->handlers->std_err)) {
stream = zend_fetch_resource(&ch->handlers->std_err, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());
if (stream == NULL) {
if (reporterror) {
php_error_docref(NULL, E_WARNING, "CURLOPT_STDERR resource has gone away, resetting to stderr");
}
zval_ptr_dtor(&ch->handlers->std_err);
ZVAL_UNDEF(&ch->handlers->std_err);
curl_easy_setopt(ch->cp, CURLOPT_STDERR, stderr);
}
}
if (ch->handlers->read && !Z_ISUNDEF(ch->handlers->read->stream)) {
stream = zend_fetch_resource(&ch->handlers->read->stream, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());
if (stream == NULL) {
if (reporterror) {
php_error_docref(NULL, E_WARNING, "CURLOPT_INFILE resource has gone away, resetting to default");
}
zval_ptr_dtor(&ch->handlers->read->stream);
ZVAL_UNDEF(&ch->handlers->read->stream);
ch->handlers->read->res = NULL;
ch->handlers->read->fp = 0;
curl_easy_setopt(ch->cp, CURLOPT_INFILE, (void *) ch);
}
}
if (ch->handlers->write_header && !Z_ISUNDEF(ch->handlers->write_header->stream)) {
stream = zend_fetch_resource(&ch->handlers->write_header->stream, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());
if (stream == NULL) {
if (reporterror) {
php_error_docref(NULL, E_WARNING, "CURLOPT_WRITEHEADER resource has gone away, resetting to default");
}
zval_ptr_dtor(&ch->handlers->write_header->stream);
ZVAL_UNDEF(&ch->handlers->write_header->stream);
ch->handlers->write_header->fp = 0;
ch->handlers->write_header->method = PHP_CURL_IGNORE;
curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch);
}
}
if (ch->handlers->write && !Z_ISUNDEF(ch->handlers->write->stream)) {
stream = zend_fetch_resource(&ch->handlers->write->stream, -1, NULL, NULL, 2, php_file_le_stream(), php_file_le_pstream());
if (stream == NULL) {
if (reporterror) {
php_error_docref(NULL, E_WARNING, "CURLOPT_FILE resource has gone away, resetting to default");
}
zval_ptr_dtor(&ch->handlers->write->stream);
ZVAL_UNDEF(&ch->handlers->write->stream);
ch->handlers->write->fp = 0;
ch->handlers->write->method = PHP_CURL_STDOUT;
curl_easy_setopt(ch->cp, CURLOPT_FILE, (void *) ch);
}
}
return ;
}
/* }}} */
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,041
|
static php_curl *alloc_curl_handle()
{
php_curl *ch = ecalloc(1, sizeof(php_curl));
ch->to_free = ecalloc(1, sizeof(struct _php_curl_free));
ch->handlers = ecalloc(1, sizeof(php_curl_handlers));
ch->handlers->write = ecalloc(1, sizeof(php_curl_write));
ch->handlers->write_header = ecalloc(1, sizeof(php_curl_write));
ch->handlers->read = ecalloc(1, sizeof(php_curl_read));
ch->handlers->progress = NULL;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
ch->handlers->fnmatch = NULL;
#endif
ch->clone = 1;
memset(&ch->err, 0, sizeof(struct _php_curl_error));
zend_llist_init(&ch->to_free->str, sizeof(char *), (llist_dtor_func_t)curl_free_string, 0);
zend_llist_init(&ch->to_free->post, sizeof(struct HttpPost), (llist_dtor_func_t)curl_free_post, 0);
ch->safe_upload = 1; /* for now, for BC reason we allow unsafe API */
ch->to_free->slist = emalloc(sizeof(HashTable));
zend_hash_init(ch->to_free->slist, 4, NULL, curl_free_slist, 0);
return ch;
}
|
DoS
| 0
|
static php_curl *alloc_curl_handle()
{
php_curl *ch = ecalloc(1, sizeof(php_curl));
ch->to_free = ecalloc(1, sizeof(struct _php_curl_free));
ch->handlers = ecalloc(1, sizeof(php_curl_handlers));
ch->handlers->write = ecalloc(1, sizeof(php_curl_write));
ch->handlers->write_header = ecalloc(1, sizeof(php_curl_write));
ch->handlers->read = ecalloc(1, sizeof(php_curl_read));
ch->handlers->progress = NULL;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
ch->handlers->fnmatch = NULL;
#endif
ch->clone = 1;
memset(&ch->err, 0, sizeof(struct _php_curl_error));
zend_llist_init(&ch->to_free->str, sizeof(char *), (llist_dtor_func_t)curl_free_string, 0);
zend_llist_init(&ch->to_free->post, sizeof(struct HttpPost), (llist_dtor_func_t)curl_free_post, 0);
ch->safe_upload = 1; /* for now, for BC reason we allow unsafe API */
ch->to_free->slist = emalloc(sizeof(HashTable));
zend_hash_init(ch->to_free->slist, 4, NULL, curl_free_slist, 0);
return ch;
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,042
|
static void create_certinfo(struct curl_certinfo *ci, zval *listcode)
{
int i;
if (ci) {
zval certhash;
for (i=0; i<ci->num_of_certs; i++) {
struct curl_slist *slist;
array_init(&certhash);
for (slist = ci->certinfo[i]; slist; slist = slist->next) {
int len;
char s[64];
char *tmp;
strncpy(s, slist->data, 64);
tmp = memchr(s, ':', 64);
if(tmp) {
*tmp = '\0';
len = strlen(s);
if (!strcmp(s, "Subject") || !strcmp(s, "Issuer")) {
zval hash;
array_init(&hash);
split_certinfo(&slist->data[len+1], &hash);
add_assoc_zval(&certhash, s, &hash);
} else {
add_assoc_string(&certhash, s, &slist->data[len+1]);
}
} else {
php_error_docref(NULL, E_WARNING, "Could not extract hash key from certificate info");
}
}
add_next_index_zval(listcode, &certhash);
}
}
}
|
DoS
| 0
|
static void create_certinfo(struct curl_certinfo *ci, zval *listcode)
{
int i;
if (ci) {
zval certhash;
for (i=0; i<ci->num_of_certs; i++) {
struct curl_slist *slist;
array_init(&certhash);
for (slist = ci->certinfo[i]; slist; slist = slist->next) {
int len;
char s[64];
char *tmp;
strncpy(s, slist->data, 64);
tmp = memchr(s, ':', 64);
if(tmp) {
*tmp = '\0';
len = strlen(s);
if (!strcmp(s, "Subject") || !strcmp(s, "Issuer")) {
zval hash;
array_init(&hash);
split_certinfo(&slist->data[len+1], &hash);
add_assoc_zval(&certhash, s, &hash);
} else {
add_assoc_string(&certhash, s, &slist->data[len+1]);
}
} else {
php_error_docref(NULL, E_WARNING, "Could not extract hash key from certificate info");
}
}
add_next_index_zval(listcode, &certhash);
}
}
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,043
|
static int curl_debug(CURL *cp, curl_infotype type, char *buf, size_t buf_len, void *ctx) /* {{{ */
{
php_curl *ch = (php_curl *)ctx;
if (type == CURLINFO_HEADER_OUT) {
if (ch->header.str) {
zend_string_release(ch->header.str);
}
if (buf_len > 0) {
ch->header.str = zend_string_init(buf, buf_len, 0);
}
}
return 0;
}
/* }}} */
|
DoS
| 0
|
static int curl_debug(CURL *cp, curl_infotype type, char *buf, size_t buf_len, void *ctx) /* {{{ */
{
php_curl *ch = (php_curl *)ctx;
if (type == CURLINFO_HEADER_OUT) {
if (ch->header.str) {
zend_string_release(ch->header.str);
}
if (buf_len > 0) {
ch->header.str = zend_string_init(buf, buf_len, 0);
}
}
return 0;
}
/* }}} */
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,044
|
static int curl_fnmatch(void *ctx, const char *pattern, const char *string)
{
php_curl *ch = (php_curl *) ctx;
php_curl_fnmatch *t = ch->handlers->fnmatch;
int rval = CURL_FNMATCHFUNC_FAIL;
switch (t->method) {
case PHP_CURL_USER: {
zval argv[3];
zval retval;
int error;
zend_fcall_info fci;
ZVAL_RES(&argv[0], ch->res);
Z_ADDREF(argv[0]);
ZVAL_STRING(&argv[1], pattern);
ZVAL_STRING(&argv[2], string);
fci.size = sizeof(fci);
fci.function_table = EG(function_table);
ZVAL_COPY_VALUE(&fci.function_name, &t->func_name);
fci.object = NULL;
fci.retval = &retval;
fci.param_count = 3;
fci.params = argv;
fci.no_separation = 0;
fci.symbol_table = NULL;
ch->in_callback = 1;
error = zend_call_function(&fci, &t->fci_cache);
ch->in_callback = 0;
if (error == FAILURE) {
php_error_docref(NULL, E_WARNING, "Cannot call the CURLOPT_FNMATCH_FUNCTION");
} else if (!Z_ISUNDEF(retval)) {
if (Z_TYPE(retval) != IS_LONG) {
convert_to_long_ex(&retval);
}
rval = Z_LVAL(retval);
}
zval_ptr_dtor(&argv[0]);
zval_ptr_dtor(&argv[1]);
zval_ptr_dtor(&argv[2]);
break;
}
}
return rval;
}
|
DoS
| 0
|
static int curl_fnmatch(void *ctx, const char *pattern, const char *string)
{
php_curl *ch = (php_curl *) ctx;
php_curl_fnmatch *t = ch->handlers->fnmatch;
int rval = CURL_FNMATCHFUNC_FAIL;
switch (t->method) {
case PHP_CURL_USER: {
zval argv[3];
zval retval;
int error;
zend_fcall_info fci;
ZVAL_RES(&argv[0], ch->res);
Z_ADDREF(argv[0]);
ZVAL_STRING(&argv[1], pattern);
ZVAL_STRING(&argv[2], string);
fci.size = sizeof(fci);
fci.function_table = EG(function_table);
ZVAL_COPY_VALUE(&fci.function_name, &t->func_name);
fci.object = NULL;
fci.retval = &retval;
fci.param_count = 3;
fci.params = argv;
fci.no_separation = 0;
fci.symbol_table = NULL;
ch->in_callback = 1;
error = zend_call_function(&fci, &t->fci_cache);
ch->in_callback = 0;
if (error == FAILURE) {
php_error_docref(NULL, E_WARNING, "Cannot call the CURLOPT_FNMATCH_FUNCTION");
} else if (!Z_ISUNDEF(retval)) {
if (Z_TYPE(retval) != IS_LONG) {
convert_to_long_ex(&retval);
}
rval = Z_LVAL(retval);
}
zval_ptr_dtor(&argv[0]);
zval_ptr_dtor(&argv[1]);
zval_ptr_dtor(&argv[2]);
break;
}
}
return rval;
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,045
|
static void curl_free_slist(zval *el)
{
curl_slist_free_all(((struct curl_slist *)Z_PTR_P(el)));
}
|
DoS
| 0
|
static void curl_free_slist(zval *el)
{
curl_slist_free_all(((struct curl_slist *)Z_PTR_P(el)));
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,046
|
static void curl_free_string(void **string)
{
efree((char *)*string);
}
|
DoS
| 0
|
static void curl_free_string(void **string)
{
efree((char *)*string);
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,047
|
static size_t curl_passwd(void *ctx, char *prompt, char *buf, int buflen)
{
php_curl *ch = (php_curl *) ctx;
zval *func = &ch->handlers->passwd;
zval argv[3];
zval retval;
int error;
int ret = -1;
ZVAL_RES(&argv[0], ch->res);
Z_ADDREF(argv[0]);
ZVAL_STRING(&argv[1], prompt);
ZVAL_LONG(&argv[2], buflen);
error = call_user_function(EG(function_table), NULL, func, &retval, 2, argv);
if (error == FAILURE) {
php_error_docref(NULL, E_WARNING, "Could not call the CURLOPT_PASSWDFUNCTION");
} else if (Z_TYPE(retval) == IS_STRING) {
if (Z_STRLEN(retval) > buflen) {
php_error_docref(NULL, E_WARNING, "Returned password is too long for libcurl to handle");
} else {
memcpy(buf, Z_STRVAL(retval), Z_STRLEN(retval) + 1);
}
} else {
php_error_docref(NULL, E_WARNING, "User handler '%s' did not return a string", Z_STRVAL_P(func));
}
zval_ptr_dtor(&argv[0]);
zval_ptr_dtor(&argv[1]);
zval_ptr_dtor(&argv[2]);
zval_ptr_dtor(&retval);
return ret;
}
|
DoS
| 0
|
static size_t curl_passwd(void *ctx, char *prompt, char *buf, int buflen)
{
php_curl *ch = (php_curl *) ctx;
zval *func = &ch->handlers->passwd;
zval argv[3];
zval retval;
int error;
int ret = -1;
ZVAL_RES(&argv[0], ch->res);
Z_ADDREF(argv[0]);
ZVAL_STRING(&argv[1], prompt);
ZVAL_LONG(&argv[2], buflen);
error = call_user_function(EG(function_table), NULL, func, &retval, 2, argv);
if (error == FAILURE) {
php_error_docref(NULL, E_WARNING, "Could not call the CURLOPT_PASSWDFUNCTION");
} else if (Z_TYPE(retval) == IS_STRING) {
if (Z_STRLEN(retval) > buflen) {
php_error_docref(NULL, E_WARNING, "Returned password is too long for libcurl to handle");
} else {
memcpy(buf, Z_STRVAL(retval), Z_STRLEN(retval) + 1);
}
} else {
php_error_docref(NULL, E_WARNING, "User handler '%s' did not return a string", Z_STRVAL_P(func));
}
zval_ptr_dtor(&argv[0]);
zval_ptr_dtor(&argv[1]);
zval_ptr_dtor(&argv[2]);
zval_ptr_dtor(&retval);
return ret;
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,048
|
static size_t curl_progress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
{
php_curl *ch = (php_curl *)clientp;
php_curl_progress *t = ch->handlers->progress;
size_t rval = 0;
#if PHP_CURL_DEBUG
fprintf(stderr, "curl_progress() called\n");
fprintf(stderr, "clientp = %x, dltotal = %f, dlnow = %f, ultotal = %f, ulnow = %f\n", clientp, dltotal, dlnow, ultotal, ulnow);
#endif
switch (t->method) {
case PHP_CURL_USER: {
zval argv[5];
zval retval;
int error;
zend_fcall_info fci;
ZVAL_RES(&argv[0], ch->res);
Z_ADDREF(argv[0]);
ZVAL_LONG(&argv[1], (zend_long)dltotal);
ZVAL_LONG(&argv[2], (zend_long)dlnow);
ZVAL_LONG(&argv[3], (zend_long)ultotal);
ZVAL_LONG(&argv[4], (zend_long)ulnow);
fci.size = sizeof(fci);
fci.function_table = EG(function_table);
ZVAL_COPY_VALUE(&fci.function_name, &t->func_name);
fci.object = NULL;
fci.retval = &retval;
fci.param_count = 5;
fci.params = argv;
fci.no_separation = 0;
fci.symbol_table = NULL;
ch->in_callback = 1;
error = zend_call_function(&fci, &t->fci_cache);
ch->in_callback = 0;
if (error == FAILURE) {
php_error_docref(NULL, E_WARNING, "Cannot call the CURLOPT_PROGRESSFUNCTION");
} else if (!Z_ISUNDEF(retval)) {
if (Z_TYPE(retval) != IS_LONG) {
convert_to_long_ex(&retval);
}
if (0 != Z_LVAL(retval)) {
rval = 1;
}
}
zval_ptr_dtor(&argv[0]);
zval_ptr_dtor(&argv[1]);
zval_ptr_dtor(&argv[2]);
zval_ptr_dtor(&argv[3]);
zval_ptr_dtor(&argv[4]);
break;
}
}
return rval;
}
|
DoS
| 0
|
static size_t curl_progress(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
{
php_curl *ch = (php_curl *)clientp;
php_curl_progress *t = ch->handlers->progress;
size_t rval = 0;
#if PHP_CURL_DEBUG
fprintf(stderr, "curl_progress() called\n");
fprintf(stderr, "clientp = %x, dltotal = %f, dlnow = %f, ultotal = %f, ulnow = %f\n", clientp, dltotal, dlnow, ultotal, ulnow);
#endif
switch (t->method) {
case PHP_CURL_USER: {
zval argv[5];
zval retval;
int error;
zend_fcall_info fci;
ZVAL_RES(&argv[0], ch->res);
Z_ADDREF(argv[0]);
ZVAL_LONG(&argv[1], (zend_long)dltotal);
ZVAL_LONG(&argv[2], (zend_long)dlnow);
ZVAL_LONG(&argv[3], (zend_long)ultotal);
ZVAL_LONG(&argv[4], (zend_long)ulnow);
fci.size = sizeof(fci);
fci.function_table = EG(function_table);
ZVAL_COPY_VALUE(&fci.function_name, &t->func_name);
fci.object = NULL;
fci.retval = &retval;
fci.param_count = 5;
fci.params = argv;
fci.no_separation = 0;
fci.symbol_table = NULL;
ch->in_callback = 1;
error = zend_call_function(&fci, &t->fci_cache);
ch->in_callback = 0;
if (error == FAILURE) {
php_error_docref(NULL, E_WARNING, "Cannot call the CURLOPT_PROGRESSFUNCTION");
} else if (!Z_ISUNDEF(retval)) {
if (Z_TYPE(retval) != IS_LONG) {
convert_to_long_ex(&retval);
}
if (0 != Z_LVAL(retval)) {
rval = 1;
}
}
zval_ptr_dtor(&argv[0]);
zval_ptr_dtor(&argv[1]);
zval_ptr_dtor(&argv[2]);
zval_ptr_dtor(&argv[3]);
zval_ptr_dtor(&argv[4]);
break;
}
}
return rval;
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,049
|
static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
{
php_curl *ch = (php_curl *) ctx;
php_curl_write *t = ch->handlers->write;
size_t length = size * nmemb;
#if PHP_CURL_DEBUG
fprintf(stderr, "curl_write() called\n");
fprintf(stderr, "data = %s, size = %d, nmemb = %d, ctx = %x\n", data, size, nmemb, ctx);
#endif
switch (t->method) {
case PHP_CURL_STDOUT:
PHPWRITE(data, length);
break;
case PHP_CURL_FILE:
return fwrite(data, size, nmemb, t->fp);
case PHP_CURL_RETURN:
if (length > 0) {
smart_str_appendl(&t->buf, data, (int) length);
}
break;
case PHP_CURL_USER: {
zval argv[2];
zval retval;
int error;
zend_fcall_info fci;
ZVAL_RES(&argv[0], ch->res);
Z_ADDREF(argv[0]);
ZVAL_STRINGL(&argv[1], data, length);
fci.size = sizeof(fci);
fci.function_table = EG(function_table);
fci.object = NULL;
ZVAL_COPY_VALUE(&fci.function_name, &t->func_name);
fci.retval = &retval;
fci.param_count = 2;
fci.params = argv;
fci.no_separation = 0;
fci.symbol_table = NULL;
ch->in_callback = 1;
error = zend_call_function(&fci, &t->fci_cache);
ch->in_callback = 0;
if (error == FAILURE) {
php_error_docref(NULL, E_WARNING, "Could not call the CURLOPT_WRITEFUNCTION");
length = -1;
} else if (!Z_ISUNDEF(retval)) {
if (Z_TYPE(retval) != IS_LONG) {
convert_to_long_ex(&retval);
}
length = Z_LVAL(retval);
}
zval_ptr_dtor(&argv[0]);
zval_ptr_dtor(&argv[1]);
break;
}
}
return length;
}
|
DoS
| 0
|
static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
{
php_curl *ch = (php_curl *) ctx;
php_curl_write *t = ch->handlers->write;
size_t length = size * nmemb;
#if PHP_CURL_DEBUG
fprintf(stderr, "curl_write() called\n");
fprintf(stderr, "data = %s, size = %d, nmemb = %d, ctx = %x\n", data, size, nmemb, ctx);
#endif
switch (t->method) {
case PHP_CURL_STDOUT:
PHPWRITE(data, length);
break;
case PHP_CURL_FILE:
return fwrite(data, size, nmemb, t->fp);
case PHP_CURL_RETURN:
if (length > 0) {
smart_str_appendl(&t->buf, data, (int) length);
}
break;
case PHP_CURL_USER: {
zval argv[2];
zval retval;
int error;
zend_fcall_info fci;
ZVAL_RES(&argv[0], ch->res);
Z_ADDREF(argv[0]);
ZVAL_STRINGL(&argv[1], data, length);
fci.size = sizeof(fci);
fci.function_table = EG(function_table);
fci.object = NULL;
ZVAL_COPY_VALUE(&fci.function_name, &t->func_name);
fci.retval = &retval;
fci.param_count = 2;
fci.params = argv;
fci.no_separation = 0;
fci.symbol_table = NULL;
ch->in_callback = 1;
error = zend_call_function(&fci, &t->fci_cache);
ch->in_callback = 0;
if (error == FAILURE) {
php_error_docref(NULL, E_WARNING, "Could not call the CURLOPT_WRITEFUNCTION");
length = -1;
} else if (!Z_ISUNDEF(retval)) {
if (Z_TYPE(retval) != IS_LONG) {
convert_to_long_ex(&retval);
}
length = Z_LVAL(retval);
}
zval_ptr_dtor(&argv[0]);
zval_ptr_dtor(&argv[1]);
break;
}
}
return length;
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,050
|
static size_t curl_write_nothing(char *data, size_t size, size_t nmemb, void *ctx)
{
return size * nmemb;
}
|
DoS
| 0
|
static size_t curl_write_nothing(char *data, size_t size, size_t nmemb, void *ctx)
{
return size * nmemb;
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,051
|
static int php_curl_option_str(php_curl *ch, zend_long option, const char *str, const int len, zend_bool make_copy)
{
CURLcode error = CURLE_OK;
if (strlen(str) != len) {
php_error_docref(NULL, E_WARNING, "Curl option contains invalid characters (\\0)");
return FAILURE;
}
#if LIBCURL_VERSION_NUM >= 0x071100
if (make_copy) {
#endif
char *copystr;
/* Strings passed to libcurl as 'char *' arguments, are copied by the library since 7.17.0 */
copystr = estrndup(str, len);
error = curl_easy_setopt(ch->cp, option, copystr);
zend_llist_add_element(&ch->to_free->str, ©str);
#if LIBCURL_VERSION_NUM >= 0x071100
} else {
error = curl_easy_setopt(ch->cp, option, str);
}
#endif
SAVE_CURL_ERROR(ch, error)
return error == CURLE_OK ? SUCCESS : FAILURE;
}
|
DoS
| 0
|
static int php_curl_option_str(php_curl *ch, zend_long option, const char *str, const int len, zend_bool make_copy)
{
CURLcode error = CURLE_OK;
if (strlen(str) != len) {
php_error_docref(NULL, E_WARNING, "Curl option contains invalid characters (\\0)");
return FAILURE;
}
#if LIBCURL_VERSION_NUM >= 0x071100
if (make_copy) {
#endif
char *copystr;
/* Strings passed to libcurl as 'char *' arguments, are copied by the library since 7.17.0 */
copystr = estrndup(str, len);
error = curl_easy_setopt(ch->cp, option, copystr);
zend_llist_add_element(&ch->to_free->str, ©str);
#if LIBCURL_VERSION_NUM >= 0x071100
} else {
error = curl_easy_setopt(ch->cp, option, str);
}
#endif
SAVE_CURL_ERROR(ch, error)
return error == CURLE_OK ? SUCCESS : FAILURE;
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,052
|
static int php_curl_ssl_mutex_create(void **m)
{
if (*((MUTEX_T *) m) = tsrm_mutex_alloc()) {
return SUCCESS;
} else {
return FAILURE;
}
}
|
DoS
| 0
|
static int php_curl_ssl_mutex_create(void **m)
{
if (*((MUTEX_T *) m) = tsrm_mutex_alloc()) {
return SUCCESS;
} else {
return FAILURE;
}
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,053
|
static int php_curl_ssl_mutex_lock(void **m)
{
return tsrm_mutex_lock(*((MUTEX_T *) m));
}
|
DoS
| 0
|
static int php_curl_ssl_mutex_lock(void **m)
{
return tsrm_mutex_lock(*((MUTEX_T *) m));
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,054
|
static int php_curl_ssl_mutex_unlock(void **m)
{
return tsrm_mutex_unlock(*((MUTEX_T *) m));
}
|
DoS
| 0
|
static int php_curl_ssl_mutex_unlock(void **m)
{
return tsrm_mutex_unlock(*((MUTEX_T *) m));
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,055
|
static void split_certinfo(char *string, zval *hash)
{
char *org = estrdup(string);
char *s = org;
char *split;
if(org) {
do {
char *key;
char *val;
char *tmp;
split = strstr(s, "; ");
if(split)
*split = '\0';
key = s;
tmp = memchr(key, '=', 64);
if(tmp) {
*tmp = '\0';
val = tmp+1;
add_assoc_string(hash, key, val);
}
s = split+2;
} while(split);
efree(org);
}
}
|
DoS
| 0
|
static void split_certinfo(char *string, zval *hash)
{
char *org = estrdup(string);
char *s = org;
char *split;
if(org) {
do {
char *key;
char *val;
char *tmp;
split = strstr(s, "; ");
if(split)
*split = '\0';
key = s;
tmp = memchr(key, '=', 64);
if(tmp) {
*tmp = '\0';
val = tmp+1;
add_assoc_string(hash, key, val);
}
s = split+2;
} while(split);
efree(org);
}
}
|
@@ -2721,6 +2721,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue) /* {{{
curl_easy_setopt(ch->cp, CURLOPT_SHARE, sh->share);
}
}
+ break;
#if LIBCURL_VERSION_NUM >= 0x071500 /* Available since 7.21.0 */
case CURLOPT_FNMATCH_FUNCTION:
| null | null | null |
4,056
|
PHP_FUNCTION(pg_connect)
{
php_pgsql_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,0);
}
|
DoS
| 0
|
PHP_FUNCTION(pg_connect)
{
php_pgsql_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,0);
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,057
|
PHP_FUNCTION(pg_connect_poll)
{
zval *pgsql_link;
int id = -1;
PGconn *pgsql;
int ret;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pgsql_link) == FAILURE) {
return;
}
if (pgsql_link == NULL) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
ret = PQconnectPoll(pgsql);
RETURN_LONG(ret);
}
|
DoS
| 0
|
PHP_FUNCTION(pg_connect_poll)
{
zval *pgsql_link;
int id = -1;
PGconn *pgsql;
int ret;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pgsql_link) == FAILURE) {
return;
}
if (pgsql_link == NULL) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
ret = PQconnectPoll(pgsql);
RETURN_LONG(ret);
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,058
|
PHP_FUNCTION(pg_pconnect)
{
php_pgsql_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,1);
}
|
DoS
| 0
|
PHP_FUNCTION(pg_pconnect)
{
php_pgsql_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,1);
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,059
|
PHP_FUNCTION(pg_close)
{
zval *pgsql_link = NULL;
int id = -1, argc = ZEND_NUM_ARGS();
PGconn *pgsql;
if (zend_parse_parameters(argc, "|r", &pgsql_link) == FAILURE) {
return;
}
if (argc == 0) {
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
if (id==-1) { /* explicit resource number */
zend_list_close(Z_RES_P(pgsql_link));
}
if (id!=-1
|| (pgsql_link && Z_RES_P(pgsql_link) == PGG(default_link))) {
zend_list_close(PGG(default_link));
PGG(default_link) = NULL;
}
RETURN_TRUE;
}
|
DoS
| 0
|
PHP_FUNCTION(pg_close)
{
zval *pgsql_link = NULL;
int id = -1, argc = ZEND_NUM_ARGS();
PGconn *pgsql;
if (zend_parse_parameters(argc, "|r", &pgsql_link) == FAILURE) {
return;
}
if (argc == 0) {
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
if (id==-1) { /* explicit resource number */
zend_list_close(Z_RES_P(pgsql_link));
}
if (id!=-1
|| (pgsql_link && Z_RES_P(pgsql_link) == PGG(default_link))) {
zend_list_close(PGG(default_link));
PGG(default_link) = NULL;
}
RETURN_TRUE;
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,060
|
PHP_FUNCTION(pg_dbname)
{
php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_DBNAME);
}
|
DoS
| 0
|
PHP_FUNCTION(pg_dbname)
{
php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_DBNAME);
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,061
|
PHP_FUNCTION(pg_options)
{
php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_OPTIONS);
}
|
DoS
| 0
|
PHP_FUNCTION(pg_options)
{
php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_OPTIONS);
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,062
|
PHP_FUNCTION(pg_port)
{
php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_PORT);
}
|
DoS
| 0
|
PHP_FUNCTION(pg_port)
{
php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_PORT);
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,063
|
PHP_FUNCTION(pg_tty)
{
php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_TTY);
}
|
DoS
| 0
|
PHP_FUNCTION(pg_tty)
{
php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_TTY);
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,064
|
PHP_FUNCTION(pg_version)
{
php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_VERSION);
}
|
DoS
| 0
|
PHP_FUNCTION(pg_version)
{
php_pgsql_get_link_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_VERSION);
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,065
|
PHP_FUNCTION(pg_parameter_status)
{
zval *pgsql_link;
int id;
PGconn *pgsql;
char *param;
size_t len;
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "rs", &pgsql_link, ¶m, &len) == SUCCESS) {
id = -1;
} else if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", ¶m, &len) == SUCCESS) {
pgsql_link = NULL;
id = FETCH_DEFAULT_LINK();
} else {
RETURN_FALSE;
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
param = (char*)PQparameterStatus(pgsql, param);
if (param) {
RETURN_STRING(param);
} else {
RETURN_FALSE;
}
}
|
DoS
| 0
|
PHP_FUNCTION(pg_parameter_status)
{
zval *pgsql_link;
int id;
PGconn *pgsql;
char *param;
size_t len;
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "rs", &pgsql_link, ¶m, &len) == SUCCESS) {
id = -1;
} else if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", ¶m, &len) == SUCCESS) {
pgsql_link = NULL;
id = FETCH_DEFAULT_LINK();
} else {
RETURN_FALSE;
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
param = (char*)PQparameterStatus(pgsql, param);
if (param) {
RETURN_STRING(param);
} else {
RETURN_FALSE;
}
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,066
|
PHP_FUNCTION(pg_ping)
{
zval *pgsql_link;
int id;
PGconn *pgsql;
PGresult *res;
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "r", &pgsql_link) == SUCCESS) {
id = -1;
} else {
pgsql_link = NULL;
id = FETCH_DEFAULT_LINK();
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
/* ping connection */
res = PQexec(pgsql, "SELECT 1;");
PQclear(res);
/* check status. */
if (PQstatus(pgsql) == CONNECTION_OK)
RETURN_TRUE;
/* reset connection if it's broken */
PQreset(pgsql);
if (PQstatus(pgsql) == CONNECTION_OK) {
RETURN_TRUE;
}
RETURN_FALSE;
}
|
DoS
| 0
|
PHP_FUNCTION(pg_ping)
{
zval *pgsql_link;
int id;
PGconn *pgsql;
PGresult *res;
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "r", &pgsql_link) == SUCCESS) {
id = -1;
} else {
pgsql_link = NULL;
id = FETCH_DEFAULT_LINK();
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
/* ping connection */
res = PQexec(pgsql, "SELECT 1;");
PQclear(res);
/* check status. */
if (PQstatus(pgsql) == CONNECTION_OK)
RETURN_TRUE;
/* reset connection if it's broken */
PQreset(pgsql);
if (PQstatus(pgsql) == CONNECTION_OK) {
RETURN_TRUE;
}
RETURN_FALSE;
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,067
|
PHP_FUNCTION(pg_query)
{
zval *pgsql_link = NULL;
char *query;
int id = -1, argc = ZEND_NUM_ARGS();
size_t query_len;
int leftover = 0;
PGconn *pgsql;
PGresult *pgsql_result;
ExecStatusType status;
pgsql_result_handle *pg_result;
if (argc == 1) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &query, &query_len) == FAILURE) {
return;
}
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
} else {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs", &pgsql_link, &query, &query_len) == FAILURE) {
return;
}
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
if (PQ_SETNONBLOCKING(pgsql, 0)) {
php_error_docref(NULL, E_NOTICE,"Cannot set connection to blocking mode");
RETURN_FALSE;
}
while ((pgsql_result = PQgetResult(pgsql))) {
PQclear(pgsql_result);
leftover = 1;
}
if (leftover) {
php_error_docref(NULL, E_NOTICE, "Found results on this connection. Use pg_get_result() to get these results first");
}
pgsql_result = PQexec(pgsql, query);
if ((PGG(auto_reset_persistent) & 2) && PQstatus(pgsql) != CONNECTION_OK) {
PQclear(pgsql_result);
PQreset(pgsql);
pgsql_result = PQexec(pgsql, query);
}
if (pgsql_result) {
status = PQresultStatus(pgsql_result);
} else {
status = (ExecStatusType) PQstatus(pgsql);
}
switch (status) {
case PGRES_EMPTY_QUERY:
case PGRES_BAD_RESPONSE:
case PGRES_NONFATAL_ERROR:
case PGRES_FATAL_ERROR:
PHP_PQ_ERROR("Query failed: %s", pgsql);
PQclear(pgsql_result);
RETURN_FALSE;
break;
case PGRES_COMMAND_OK: /* successful command that did not return rows */
default:
if (pgsql_result) {
pg_result = (pgsql_result_handle *) emalloc(sizeof(pgsql_result_handle));
pg_result->conn = pgsql;
pg_result->result = pgsql_result;
pg_result->row = 0;
ZEND_REGISTER_RESOURCE(return_value, pg_result, le_result);
} else {
PQclear(pgsql_result);
RETURN_FALSE;
}
break;
}
}
|
DoS
| 0
|
PHP_FUNCTION(pg_query)
{
zval *pgsql_link = NULL;
char *query;
int id = -1, argc = ZEND_NUM_ARGS();
size_t query_len;
int leftover = 0;
PGconn *pgsql;
PGresult *pgsql_result;
ExecStatusType status;
pgsql_result_handle *pg_result;
if (argc == 1) {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &query, &query_len) == FAILURE) {
return;
}
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
} else {
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs", &pgsql_link, &query, &query_len) == FAILURE) {
return;
}
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
if (PQ_SETNONBLOCKING(pgsql, 0)) {
php_error_docref(NULL, E_NOTICE,"Cannot set connection to blocking mode");
RETURN_FALSE;
}
while ((pgsql_result = PQgetResult(pgsql))) {
PQclear(pgsql_result);
leftover = 1;
}
if (leftover) {
php_error_docref(NULL, E_NOTICE, "Found results on this connection. Use pg_get_result() to get these results first");
}
pgsql_result = PQexec(pgsql, query);
if ((PGG(auto_reset_persistent) & 2) && PQstatus(pgsql) != CONNECTION_OK) {
PQclear(pgsql_result);
PQreset(pgsql);
pgsql_result = PQexec(pgsql, query);
}
if (pgsql_result) {
status = PQresultStatus(pgsql_result);
} else {
status = (ExecStatusType) PQstatus(pgsql);
}
switch (status) {
case PGRES_EMPTY_QUERY:
case PGRES_BAD_RESPONSE:
case PGRES_NONFATAL_ERROR:
case PGRES_FATAL_ERROR:
PHP_PQ_ERROR("Query failed: %s", pgsql);
PQclear(pgsql_result);
RETURN_FALSE;
break;
case PGRES_COMMAND_OK: /* successful command that did not return rows */
default:
if (pgsql_result) {
pg_result = (pgsql_result_handle *) emalloc(sizeof(pgsql_result_handle));
pg_result->conn = pgsql;
pg_result->result = pgsql_result;
pg_result->row = 0;
ZEND_REGISTER_RESOURCE(return_value, pg_result, le_result);
} else {
PQclear(pgsql_result);
RETURN_FALSE;
}
break;
}
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,068
|
PHP_FUNCTION(pg_query_params)
{
zval *pgsql_link = NULL;
zval *pv_param_arr, *tmp;
char *query;
size_t query_len;
int id = -1, argc = ZEND_NUM_ARGS();
int leftover = 0;
int num_params = 0;
char **params = NULL;
PGconn *pgsql;
PGresult *pgsql_result;
ExecStatusType status;
pgsql_result_handle *pg_result;
if (argc == 2) {
if (zend_parse_parameters(argc, "sa", &query, &query_len, &pv_param_arr) == FAILURE) {
return;
}
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
} else {
if (zend_parse_parameters(argc, "rsa", &pgsql_link, &query, &query_len, &pv_param_arr) == FAILURE) {
return;
}
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
if (PQ_SETNONBLOCKING(pgsql, 0)) {
php_error_docref(NULL, E_NOTICE,"Cannot set connection to blocking mode");
RETURN_FALSE;
}
while ((pgsql_result = PQgetResult(pgsql))) {
PQclear(pgsql_result);
leftover = 1;
}
if (leftover) {
php_error_docref(NULL, E_NOTICE, "Found results on this connection. Use pg_get_result() to get these results first");
}
num_params = zend_hash_num_elements(Z_ARRVAL_P(pv_param_arr));
if (num_params > 0) {
int i = 0;
params = (char **)safe_emalloc(sizeof(char *), num_params, 0);
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(pv_param_arr), tmp) {
if (Z_TYPE_P(tmp) == IS_NULL) {
params[i] = NULL;
} else {
zval tmp_val;
ZVAL_COPY(&tmp_val, tmp);
convert_to_cstring(&tmp_val);
if (Z_TYPE(tmp_val) != IS_STRING) {
php_error_docref(NULL, E_WARNING,"Error converting parameter");
zval_ptr_dtor(&tmp_val);
_php_pgsql_free_params(params, num_params);
RETURN_FALSE;
}
params[i] = estrndup(Z_STRVAL(tmp_val), Z_STRLEN(tmp_val));
zval_ptr_dtor(&tmp_val);
}
i++;
} ZEND_HASH_FOREACH_END();
}
pgsql_result = PQexecParams(pgsql, query, num_params,
NULL, (const char * const *)params, NULL, NULL, 0);
if ((PGG(auto_reset_persistent) & 2) && PQstatus(pgsql) != CONNECTION_OK) {
PQclear(pgsql_result);
PQreset(pgsql);
pgsql_result = PQexecParams(pgsql, query, num_params,
NULL, (const char * const *)params, NULL, NULL, 0);
}
if (pgsql_result) {
status = PQresultStatus(pgsql_result);
} else {
status = (ExecStatusType) PQstatus(pgsql);
}
_php_pgsql_free_params(params, num_params);
switch (status) {
case PGRES_EMPTY_QUERY:
case PGRES_BAD_RESPONSE:
case PGRES_NONFATAL_ERROR:
case PGRES_FATAL_ERROR:
PHP_PQ_ERROR("Query failed: %s", pgsql);
PQclear(pgsql_result);
RETURN_FALSE;
break;
case PGRES_COMMAND_OK: /* successful command that did not return rows */
default:
if (pgsql_result) {
pg_result = (pgsql_result_handle *) emalloc(sizeof(pgsql_result_handle));
pg_result->conn = pgsql;
pg_result->result = pgsql_result;
pg_result->row = 0;
ZEND_REGISTER_RESOURCE(return_value, pg_result, le_result);
} else {
PQclear(pgsql_result);
RETURN_FALSE;
}
break;
}
}
|
DoS
| 0
|
PHP_FUNCTION(pg_query_params)
{
zval *pgsql_link = NULL;
zval *pv_param_arr, *tmp;
char *query;
size_t query_len;
int id = -1, argc = ZEND_NUM_ARGS();
int leftover = 0;
int num_params = 0;
char **params = NULL;
PGconn *pgsql;
PGresult *pgsql_result;
ExecStatusType status;
pgsql_result_handle *pg_result;
if (argc == 2) {
if (zend_parse_parameters(argc, "sa", &query, &query_len, &pv_param_arr) == FAILURE) {
return;
}
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
} else {
if (zend_parse_parameters(argc, "rsa", &pgsql_link, &query, &query_len, &pv_param_arr) == FAILURE) {
return;
}
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
if (PQ_SETNONBLOCKING(pgsql, 0)) {
php_error_docref(NULL, E_NOTICE,"Cannot set connection to blocking mode");
RETURN_FALSE;
}
while ((pgsql_result = PQgetResult(pgsql))) {
PQclear(pgsql_result);
leftover = 1;
}
if (leftover) {
php_error_docref(NULL, E_NOTICE, "Found results on this connection. Use pg_get_result() to get these results first");
}
num_params = zend_hash_num_elements(Z_ARRVAL_P(pv_param_arr));
if (num_params > 0) {
int i = 0;
params = (char **)safe_emalloc(sizeof(char *), num_params, 0);
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(pv_param_arr), tmp) {
if (Z_TYPE_P(tmp) == IS_NULL) {
params[i] = NULL;
} else {
zval tmp_val;
ZVAL_COPY(&tmp_val, tmp);
convert_to_cstring(&tmp_val);
if (Z_TYPE(tmp_val) != IS_STRING) {
php_error_docref(NULL, E_WARNING,"Error converting parameter");
zval_ptr_dtor(&tmp_val);
_php_pgsql_free_params(params, num_params);
RETURN_FALSE;
}
params[i] = estrndup(Z_STRVAL(tmp_val), Z_STRLEN(tmp_val));
zval_ptr_dtor(&tmp_val);
}
i++;
} ZEND_HASH_FOREACH_END();
}
pgsql_result = PQexecParams(pgsql, query, num_params,
NULL, (const char * const *)params, NULL, NULL, 0);
if ((PGG(auto_reset_persistent) & 2) && PQstatus(pgsql) != CONNECTION_OK) {
PQclear(pgsql_result);
PQreset(pgsql);
pgsql_result = PQexecParams(pgsql, query, num_params,
NULL, (const char * const *)params, NULL, NULL, 0);
}
if (pgsql_result) {
status = PQresultStatus(pgsql_result);
} else {
status = (ExecStatusType) PQstatus(pgsql);
}
_php_pgsql_free_params(params, num_params);
switch (status) {
case PGRES_EMPTY_QUERY:
case PGRES_BAD_RESPONSE:
case PGRES_NONFATAL_ERROR:
case PGRES_FATAL_ERROR:
PHP_PQ_ERROR("Query failed: %s", pgsql);
PQclear(pgsql_result);
RETURN_FALSE;
break;
case PGRES_COMMAND_OK: /* successful command that did not return rows */
default:
if (pgsql_result) {
pg_result = (pgsql_result_handle *) emalloc(sizeof(pgsql_result_handle));
pg_result->conn = pgsql;
pg_result->result = pgsql_result;
pg_result->row = 0;
ZEND_REGISTER_RESOURCE(return_value, pg_result, le_result);
} else {
PQclear(pgsql_result);
RETURN_FALSE;
}
break;
}
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,069
|
PHP_FUNCTION(pg_prepare)
{
zval *pgsql_link = NULL;
char *query, *stmtname;
size_t query_len, stmtname_len;
int id = -1, argc = ZEND_NUM_ARGS();
int leftover = 0;
PGconn *pgsql;
PGresult *pgsql_result;
ExecStatusType status;
pgsql_result_handle *pg_result;
if (argc == 2) {
if (zend_parse_parameters(argc, "ss", &stmtname, &stmtname_len, &query, &query_len) == FAILURE) {
return;
}
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
} else {
if (zend_parse_parameters(argc, "rss", &pgsql_link, &stmtname, &stmtname_len, &query, &query_len) == FAILURE) {
return;
}
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
if (PQ_SETNONBLOCKING(pgsql, 0)) {
php_error_docref(NULL, E_NOTICE,"Cannot set connection to blocking mode");
RETURN_FALSE;
}
while ((pgsql_result = PQgetResult(pgsql))) {
PQclear(pgsql_result);
leftover = 1;
}
if (leftover) {
php_error_docref(NULL, E_NOTICE, "Found results on this connection. Use pg_get_result() to get these results first");
}
pgsql_result = PQprepare(pgsql, stmtname, query, 0, NULL);
if ((PGG(auto_reset_persistent) & 2) && PQstatus(pgsql) != CONNECTION_OK) {
PQclear(pgsql_result);
PQreset(pgsql);
pgsql_result = PQprepare(pgsql, stmtname, query, 0, NULL);
}
if (pgsql_result) {
status = PQresultStatus(pgsql_result);
} else {
status = (ExecStatusType) PQstatus(pgsql);
}
switch (status) {
case PGRES_EMPTY_QUERY:
case PGRES_BAD_RESPONSE:
case PGRES_NONFATAL_ERROR:
case PGRES_FATAL_ERROR:
PHP_PQ_ERROR("Query failed: %s", pgsql);
PQclear(pgsql_result);
RETURN_FALSE;
break;
case PGRES_COMMAND_OK: /* successful command that did not return rows */
default:
if (pgsql_result) {
pg_result = (pgsql_result_handle *) emalloc(sizeof(pgsql_result_handle));
pg_result->conn = pgsql;
pg_result->result = pgsql_result;
pg_result->row = 0;
ZEND_REGISTER_RESOURCE(return_value, pg_result, le_result);
} else {
PQclear(pgsql_result);
RETURN_FALSE;
}
break;
}
}
|
DoS
| 0
|
PHP_FUNCTION(pg_prepare)
{
zval *pgsql_link = NULL;
char *query, *stmtname;
size_t query_len, stmtname_len;
int id = -1, argc = ZEND_NUM_ARGS();
int leftover = 0;
PGconn *pgsql;
PGresult *pgsql_result;
ExecStatusType status;
pgsql_result_handle *pg_result;
if (argc == 2) {
if (zend_parse_parameters(argc, "ss", &stmtname, &stmtname_len, &query, &query_len) == FAILURE) {
return;
}
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
} else {
if (zend_parse_parameters(argc, "rss", &pgsql_link, &stmtname, &stmtname_len, &query, &query_len) == FAILURE) {
return;
}
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
if (PQ_SETNONBLOCKING(pgsql, 0)) {
php_error_docref(NULL, E_NOTICE,"Cannot set connection to blocking mode");
RETURN_FALSE;
}
while ((pgsql_result = PQgetResult(pgsql))) {
PQclear(pgsql_result);
leftover = 1;
}
if (leftover) {
php_error_docref(NULL, E_NOTICE, "Found results on this connection. Use pg_get_result() to get these results first");
}
pgsql_result = PQprepare(pgsql, stmtname, query, 0, NULL);
if ((PGG(auto_reset_persistent) & 2) && PQstatus(pgsql) != CONNECTION_OK) {
PQclear(pgsql_result);
PQreset(pgsql);
pgsql_result = PQprepare(pgsql, stmtname, query, 0, NULL);
}
if (pgsql_result) {
status = PQresultStatus(pgsql_result);
} else {
status = (ExecStatusType) PQstatus(pgsql);
}
switch (status) {
case PGRES_EMPTY_QUERY:
case PGRES_BAD_RESPONSE:
case PGRES_NONFATAL_ERROR:
case PGRES_FATAL_ERROR:
PHP_PQ_ERROR("Query failed: %s", pgsql);
PQclear(pgsql_result);
RETURN_FALSE;
break;
case PGRES_COMMAND_OK: /* successful command that did not return rows */
default:
if (pgsql_result) {
pg_result = (pgsql_result_handle *) emalloc(sizeof(pgsql_result_handle));
pg_result->conn = pgsql;
pg_result->result = pgsql_result;
pg_result->row = 0;
ZEND_REGISTER_RESOURCE(return_value, pg_result, le_result);
} else {
PQclear(pgsql_result);
RETURN_FALSE;
}
break;
}
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,070
|
PHP_FUNCTION(pg_execute)
{
zval *pgsql_link = NULL;
zval *pv_param_arr, *tmp;
char *stmtname;
size_t stmtname_len;
int id = -1, argc = ZEND_NUM_ARGS();
int leftover = 0;
int num_params = 0;
char **params = NULL;
PGconn *pgsql;
PGresult *pgsql_result;
ExecStatusType status;
pgsql_result_handle *pg_result;
if (argc == 2) {
if (zend_parse_parameters(argc, "sa/", &stmtname, &stmtname_len, &pv_param_arr)==FAILURE) {
return;
}
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
} else {
if (zend_parse_parameters(argc, "rsa/", &pgsql_link, &stmtname, &stmtname_len, &pv_param_arr) == FAILURE) {
return;
}
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
if (PQ_SETNONBLOCKING(pgsql, 0)) {
php_error_docref(NULL, E_NOTICE,"Cannot set connection to blocking mode");
RETURN_FALSE;
}
while ((pgsql_result = PQgetResult(pgsql))) {
PQclear(pgsql_result);
leftover = 1;
}
if (leftover) {
php_error_docref(NULL, E_NOTICE, "Found results on this connection. Use pg_get_result() to get these results first");
}
num_params = zend_hash_num_elements(Z_ARRVAL_P(pv_param_arr));
if (num_params > 0) {
int i = 0;
params = (char **)safe_emalloc(sizeof(char *), num_params, 0);
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(pv_param_arr), tmp) {
if (Z_TYPE_P(tmp) == IS_NULL) {
params[i] = NULL;
} else {
zval tmp_val;
ZVAL_COPY(&tmp_val, tmp);
convert_to_string(&tmp_val);
if (Z_TYPE(tmp_val) != IS_STRING) {
php_error_docref(NULL, E_WARNING,"Error converting parameter");
zval_ptr_dtor(&tmp_val);
_php_pgsql_free_params(params, num_params);
RETURN_FALSE;
}
params[i] = estrndup(Z_STRVAL(tmp_val), Z_STRLEN(tmp_val));
zval_ptr_dtor(&tmp_val);
}
i++;
} ZEND_HASH_FOREACH_END();
}
pgsql_result = PQexecPrepared(pgsql, stmtname, num_params,
(const char * const *)params, NULL, NULL, 0);
if ((PGG(auto_reset_persistent) & 2) && PQstatus(pgsql) != CONNECTION_OK) {
PQclear(pgsql_result);
PQreset(pgsql);
pgsql_result = PQexecPrepared(pgsql, stmtname, num_params,
(const char * const *)params, NULL, NULL, 0);
}
if (pgsql_result) {
status = PQresultStatus(pgsql_result);
} else {
status = (ExecStatusType) PQstatus(pgsql);
}
_php_pgsql_free_params(params, num_params);
switch (status) {
case PGRES_EMPTY_QUERY:
case PGRES_BAD_RESPONSE:
case PGRES_NONFATAL_ERROR:
case PGRES_FATAL_ERROR:
PHP_PQ_ERROR("Query failed: %s", pgsql);
PQclear(pgsql_result);
RETURN_FALSE;
break;
case PGRES_COMMAND_OK: /* successful command that did not return rows */
default:
if (pgsql_result) {
pg_result = (pgsql_result_handle *) emalloc(sizeof(pgsql_result_handle));
pg_result->conn = pgsql;
pg_result->result = pgsql_result;
pg_result->row = 0;
ZEND_REGISTER_RESOURCE(return_value, pg_result, le_result);
} else {
PQclear(pgsql_result);
RETURN_FALSE;
}
break;
}
}
|
DoS
| 0
|
PHP_FUNCTION(pg_execute)
{
zval *pgsql_link = NULL;
zval *pv_param_arr, *tmp;
char *stmtname;
size_t stmtname_len;
int id = -1, argc = ZEND_NUM_ARGS();
int leftover = 0;
int num_params = 0;
char **params = NULL;
PGconn *pgsql;
PGresult *pgsql_result;
ExecStatusType status;
pgsql_result_handle *pg_result;
if (argc == 2) {
if (zend_parse_parameters(argc, "sa/", &stmtname, &stmtname_len, &pv_param_arr)==FAILURE) {
return;
}
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
} else {
if (zend_parse_parameters(argc, "rsa/", &pgsql_link, &stmtname, &stmtname_len, &pv_param_arr) == FAILURE) {
return;
}
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
if (PQ_SETNONBLOCKING(pgsql, 0)) {
php_error_docref(NULL, E_NOTICE,"Cannot set connection to blocking mode");
RETURN_FALSE;
}
while ((pgsql_result = PQgetResult(pgsql))) {
PQclear(pgsql_result);
leftover = 1;
}
if (leftover) {
php_error_docref(NULL, E_NOTICE, "Found results on this connection. Use pg_get_result() to get these results first");
}
num_params = zend_hash_num_elements(Z_ARRVAL_P(pv_param_arr));
if (num_params > 0) {
int i = 0;
params = (char **)safe_emalloc(sizeof(char *), num_params, 0);
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(pv_param_arr), tmp) {
if (Z_TYPE_P(tmp) == IS_NULL) {
params[i] = NULL;
} else {
zval tmp_val;
ZVAL_COPY(&tmp_val, tmp);
convert_to_string(&tmp_val);
if (Z_TYPE(tmp_val) != IS_STRING) {
php_error_docref(NULL, E_WARNING,"Error converting parameter");
zval_ptr_dtor(&tmp_val);
_php_pgsql_free_params(params, num_params);
RETURN_FALSE;
}
params[i] = estrndup(Z_STRVAL(tmp_val), Z_STRLEN(tmp_val));
zval_ptr_dtor(&tmp_val);
}
i++;
} ZEND_HASH_FOREACH_END();
}
pgsql_result = PQexecPrepared(pgsql, stmtname, num_params,
(const char * const *)params, NULL, NULL, 0);
if ((PGG(auto_reset_persistent) & 2) && PQstatus(pgsql) != CONNECTION_OK) {
PQclear(pgsql_result);
PQreset(pgsql);
pgsql_result = PQexecPrepared(pgsql, stmtname, num_params,
(const char * const *)params, NULL, NULL, 0);
}
if (pgsql_result) {
status = PQresultStatus(pgsql_result);
} else {
status = (ExecStatusType) PQstatus(pgsql);
}
_php_pgsql_free_params(params, num_params);
switch (status) {
case PGRES_EMPTY_QUERY:
case PGRES_BAD_RESPONSE:
case PGRES_NONFATAL_ERROR:
case PGRES_FATAL_ERROR:
PHP_PQ_ERROR("Query failed: %s", pgsql);
PQclear(pgsql_result);
RETURN_FALSE;
break;
case PGRES_COMMAND_OK: /* successful command that did not return rows */
default:
if (pgsql_result) {
pg_result = (pgsql_result_handle *) emalloc(sizeof(pgsql_result_handle));
pg_result->conn = pgsql;
pg_result->result = pgsql_result;
pg_result->row = 0;
ZEND_REGISTER_RESOURCE(return_value, pg_result, le_result);
} else {
PQclear(pgsql_result);
RETURN_FALSE;
}
break;
}
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,071
|
PHP_FUNCTION(pg_num_rows)
{
php_pgsql_get_result_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_NUM_ROWS);
}
|
DoS
| 0
|
PHP_FUNCTION(pg_num_rows)
{
php_pgsql_get_result_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_NUM_ROWS);
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,072
|
PHP_FUNCTION(pg_num_fields)
{
php_pgsql_get_result_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_NUM_FIELDS);
}
|
DoS
| 0
|
PHP_FUNCTION(pg_num_fields)
{
php_pgsql_get_result_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_NUM_FIELDS);
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,073
|
PHP_FUNCTION(pg_affected_rows)
{
php_pgsql_get_result_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_CMD_TUPLES);
}
|
DoS
| 0
|
PHP_FUNCTION(pg_affected_rows)
{
php_pgsql_get_result_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_CMD_TUPLES);
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,074
|
PHP_FUNCTION(pg_last_notice)
{
zval *pgsql_link = NULL;
PGconn *pg_link;
int id = -1;
php_pgsql_notice *notice;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pgsql_link) == FAILURE) {
return;
}
if (pgsql_link == NULL) {
RETURN_FALSE;
}
/* Just to check if user passed valid resoruce */
ZEND_FETCH_RESOURCE2(pg_link, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
if ((notice = zend_hash_index_find_ptr(&PGG(notices), (zend_ulong)Z_RES_HANDLE_P(pgsql_link))) == NULL) {
RETURN_FALSE;
}
RETURN_STRINGL(notice->message, notice->len);
}
|
DoS
| 0
|
PHP_FUNCTION(pg_last_notice)
{
zval *pgsql_link = NULL;
PGconn *pg_link;
int id = -1;
php_pgsql_notice *notice;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pgsql_link) == FAILURE) {
return;
}
if (pgsql_link == NULL) {
RETURN_FALSE;
}
/* Just to check if user passed valid resoruce */
ZEND_FETCH_RESOURCE2(pg_link, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
if ((notice = zend_hash_index_find_ptr(&PGG(notices), (zend_ulong)Z_RES_HANDLE_P(pgsql_link))) == NULL) {
RETURN_FALSE;
}
RETURN_STRINGL(notice->message, notice->len);
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,075
|
PHP_FUNCTION(pg_field_table)
{
zval *result;
pgsql_result_handle *pg_result;
zend_long fnum = -1;
zend_bool return_oid = 0;
Oid oid;
smart_str hash_key = {0};
char *table_name;
zend_resource *field_table;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl|b", &result, &fnum, &return_oid) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, result, -1, "PostgreSQL result", le_result);
if (fnum < 0 || fnum >= PQnfields(pg_result->result)) {
php_error_docref(NULL, E_WARNING, "Bad field offset specified");
RETURN_FALSE;
}
oid = PQftable(pg_result->result, (int)fnum);
if (InvalidOid == oid) {
RETURN_FALSE;
}
if (return_oid) {
#if UINT_MAX > ZEND_LONG_MAX /* Oid is unsigned int, we don't need this code, where LONG is wider */
if (oid > ZEND_LONG_MAX) {
smart_str oidstr = {0};
smart_str_append_unsigned(&oidstr, oid);
smart_str_0(&oidstr);
RETURN_STR(oidstr.s);
} else
#endif
RETURN_LONG((zend_long)oid);
}
/* try to lookup the table name in the resource list */
smart_str_appends(&hash_key, "pgsql_table_oid_");
smart_str_append_unsigned(&hash_key, oid);
smart_str_0(&hash_key);
if ((field_table = zend_hash_find_ptr(&EG(regular_list), hash_key.s)) != NULL) {
smart_str_free(&hash_key);
RETURN_STRING((char *)field_table->ptr);
} else { /* Not found, lookup by querying PostgreSQL system tables */
PGresult *tmp_res;
smart_str querystr = {0};
zend_resource new_field_table;
smart_str_appends(&querystr, "select relname from pg_class where oid=");
smart_str_append_unsigned(&querystr, oid);
smart_str_0(&querystr);
if ((tmp_res = PQexec(pg_result->conn, querystr.s->val)) == NULL || PQresultStatus(tmp_res) != PGRES_TUPLES_OK) {
if (tmp_res) {
PQclear(tmp_res);
}
smart_str_free(&querystr);
smart_str_free(&hash_key);
RETURN_FALSE;
}
smart_str_free(&querystr);
if ((table_name = PQgetvalue(tmp_res, 0, 0)) == NULL) {
PQclear(tmp_res);
smart_str_free(&hash_key);
RETURN_FALSE;
}
new_field_table.type = le_string;
new_field_table.ptr = estrdup(table_name);
zend_hash_update_mem(&EG(regular_list), hash_key.s, (void *)&new_field_table, sizeof(zend_resource));
smart_str_free(&hash_key);
PQclear(tmp_res);
RETURN_STRING(table_name);
}
}
|
DoS
| 0
|
PHP_FUNCTION(pg_field_table)
{
zval *result;
pgsql_result_handle *pg_result;
zend_long fnum = -1;
zend_bool return_oid = 0;
Oid oid;
smart_str hash_key = {0};
char *table_name;
zend_resource *field_table;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl|b", &result, &fnum, &return_oid) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, result, -1, "PostgreSQL result", le_result);
if (fnum < 0 || fnum >= PQnfields(pg_result->result)) {
php_error_docref(NULL, E_WARNING, "Bad field offset specified");
RETURN_FALSE;
}
oid = PQftable(pg_result->result, (int)fnum);
if (InvalidOid == oid) {
RETURN_FALSE;
}
if (return_oid) {
#if UINT_MAX > ZEND_LONG_MAX /* Oid is unsigned int, we don't need this code, where LONG is wider */
if (oid > ZEND_LONG_MAX) {
smart_str oidstr = {0};
smart_str_append_unsigned(&oidstr, oid);
smart_str_0(&oidstr);
RETURN_STR(oidstr.s);
} else
#endif
RETURN_LONG((zend_long)oid);
}
/* try to lookup the table name in the resource list */
smart_str_appends(&hash_key, "pgsql_table_oid_");
smart_str_append_unsigned(&hash_key, oid);
smart_str_0(&hash_key);
if ((field_table = zend_hash_find_ptr(&EG(regular_list), hash_key.s)) != NULL) {
smart_str_free(&hash_key);
RETURN_STRING((char *)field_table->ptr);
} else { /* Not found, lookup by querying PostgreSQL system tables */
PGresult *tmp_res;
smart_str querystr = {0};
zend_resource new_field_table;
smart_str_appends(&querystr, "select relname from pg_class where oid=");
smart_str_append_unsigned(&querystr, oid);
smart_str_0(&querystr);
if ((tmp_res = PQexec(pg_result->conn, querystr.s->val)) == NULL || PQresultStatus(tmp_res) != PGRES_TUPLES_OK) {
if (tmp_res) {
PQclear(tmp_res);
}
smart_str_free(&querystr);
smart_str_free(&hash_key);
RETURN_FALSE;
}
smart_str_free(&querystr);
if ((table_name = PQgetvalue(tmp_res, 0, 0)) == NULL) {
PQclear(tmp_res);
smart_str_free(&hash_key);
RETURN_FALSE;
}
new_field_table.type = le_string;
new_field_table.ptr = estrdup(table_name);
zend_hash_update_mem(&EG(regular_list), hash_key.s, (void *)&new_field_table, sizeof(zend_resource));
smart_str_free(&hash_key);
PQclear(tmp_res);
RETURN_STRING(table_name);
}
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,076
|
PHP_FUNCTION(pg_field_name)
{
php_pgsql_get_field_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_FIELD_NAME);
}
|
DoS
| 0
|
PHP_FUNCTION(pg_field_name)
{
php_pgsql_get_field_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_FIELD_NAME);
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,077
|
PHP_FUNCTION(pg_field_size)
{
php_pgsql_get_field_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_FIELD_SIZE);
}
|
DoS
| 0
|
PHP_FUNCTION(pg_field_size)
{
php_pgsql_get_field_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_FIELD_SIZE);
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,078
|
PHP_FUNCTION(pg_field_type)
{
php_pgsql_get_field_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_FIELD_TYPE);
}
|
DoS
| 0
|
PHP_FUNCTION(pg_field_type)
{
php_pgsql_get_field_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_FIELD_TYPE);
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,079
|
PHP_FUNCTION(pg_field_type_oid)
{
php_pgsql_get_field_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_FIELD_TYPE_OID);
}
|
DoS
| 0
|
PHP_FUNCTION(pg_field_type_oid)
{
php_pgsql_get_field_info(INTERNAL_FUNCTION_PARAM_PASSTHRU,PHP_PG_FIELD_TYPE_OID);
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,080
|
PHP_FUNCTION(pg_field_num)
{
zval *result;
char *field;
size_t field_len;
PGresult *pgsql_result;
pgsql_result_handle *pg_result;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs", &result, &field, &field_len) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, result, -1, "PostgreSQL result", le_result);
pgsql_result = pg_result->result;
RETURN_LONG(PQfnumber(pgsql_result, field));
}
|
DoS
| 0
|
PHP_FUNCTION(pg_field_num)
{
zval *result;
char *field;
size_t field_len;
PGresult *pgsql_result;
pgsql_result_handle *pg_result;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rs", &result, &field, &field_len) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, result, -1, "PostgreSQL result", le_result);
pgsql_result = pg_result->result;
RETURN_LONG(PQfnumber(pgsql_result, field));
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,081
|
PHP_FUNCTION(pg_fetch_result)
{
zval *result, *field=NULL;
zend_long row;
PGresult *pgsql_result;
pgsql_result_handle *pg_result;
int field_offset, pgsql_row, argc = ZEND_NUM_ARGS();
if (argc == 2) {
if (zend_parse_parameters(argc, "rz", &result, &field) == FAILURE) {
return;
}
} else {
if (zend_parse_parameters(argc, "rlz", &result, &row, &field) == FAILURE) {
return;
}
}
ZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, result, -1, "PostgreSQL result", le_result);
pgsql_result = pg_result->result;
if (argc == 2) {
if (pg_result->row < 0) {
pg_result->row = 0;
}
pgsql_row = pg_result->row;
if (pgsql_row >= PQntuples(pgsql_result)) {
RETURN_FALSE;
}
} else {
if (row < 0 || row >= PQntuples(pgsql_result)) {
php_error_docref(NULL, E_WARNING, "Unable to jump to row %pd on PostgreSQL result index %pd",
row, Z_LVAL_P(result));
RETURN_FALSE;
}
pgsql_row = (int)row;
}
switch (Z_TYPE_P(field)) {
case IS_STRING:
field_offset = PQfnumber(pgsql_result, Z_STRVAL_P(field));
if (field_offset < 0 || field_offset >= PQnfields(pgsql_result)) {
php_error_docref(NULL, E_WARNING, "Bad column offset specified");
RETURN_FALSE;
}
break;
default:
convert_to_long_ex(field);
if (Z_LVAL_P(field) < 0 || Z_LVAL_P(field) >= PQnfields(pgsql_result)) {
php_error_docref(NULL, E_WARNING, "Bad column offset specified");
RETURN_FALSE;
}
field_offset = (int)Z_LVAL_P(field);
break;
}
if (PQgetisnull(pgsql_result, pgsql_row, field_offset)) {
RETVAL_NULL();
} else {
RETVAL_STRINGL(PQgetvalue(pgsql_result, pgsql_row, field_offset),
PQgetlength(pgsql_result, pgsql_row, field_offset));
}
}
|
DoS
| 0
|
PHP_FUNCTION(pg_fetch_result)
{
zval *result, *field=NULL;
zend_long row;
PGresult *pgsql_result;
pgsql_result_handle *pg_result;
int field_offset, pgsql_row, argc = ZEND_NUM_ARGS();
if (argc == 2) {
if (zend_parse_parameters(argc, "rz", &result, &field) == FAILURE) {
return;
}
} else {
if (zend_parse_parameters(argc, "rlz", &result, &row, &field) == FAILURE) {
return;
}
}
ZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, result, -1, "PostgreSQL result", le_result);
pgsql_result = pg_result->result;
if (argc == 2) {
if (pg_result->row < 0) {
pg_result->row = 0;
}
pgsql_row = pg_result->row;
if (pgsql_row >= PQntuples(pgsql_result)) {
RETURN_FALSE;
}
} else {
if (row < 0 || row >= PQntuples(pgsql_result)) {
php_error_docref(NULL, E_WARNING, "Unable to jump to row %pd on PostgreSQL result index %pd",
row, Z_LVAL_P(result));
RETURN_FALSE;
}
pgsql_row = (int)row;
}
switch (Z_TYPE_P(field)) {
case IS_STRING:
field_offset = PQfnumber(pgsql_result, Z_STRVAL_P(field));
if (field_offset < 0 || field_offset >= PQnfields(pgsql_result)) {
php_error_docref(NULL, E_WARNING, "Bad column offset specified");
RETURN_FALSE;
}
break;
default:
convert_to_long_ex(field);
if (Z_LVAL_P(field) < 0 || Z_LVAL_P(field) >= PQnfields(pgsql_result)) {
php_error_docref(NULL, E_WARNING, "Bad column offset specified");
RETURN_FALSE;
}
field_offset = (int)Z_LVAL_P(field);
break;
}
if (PQgetisnull(pgsql_result, pgsql_row, field_offset)) {
RETVAL_NULL();
} else {
RETVAL_STRINGL(PQgetvalue(pgsql_result, pgsql_row, field_offset),
PQgetlength(pgsql_result, pgsql_row, field_offset));
}
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,082
|
PHP_FUNCTION(pg_fetch_row)
{
php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, PGSQL_NUM, 0);
}
|
DoS
| 0
|
PHP_FUNCTION(pg_fetch_row)
{
php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, PGSQL_NUM, 0);
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,083
|
PHP_FUNCTION(pg_fetch_array)
{
php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, PGSQL_BOTH, 0);
}
|
DoS
| 0
|
PHP_FUNCTION(pg_fetch_array)
{
php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAM_PASSTHRU, PGSQL_BOTH, 0);
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,084
|
PHP_FUNCTION(pg_fetch_all)
{
zval *result;
PGresult *pgsql_result;
pgsql_result_handle *pg_result;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &result) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, result, -1, "PostgreSQL result", le_result);
pgsql_result = pg_result->result;
array_init(return_value);
if (php_pgsql_result2array(pgsql_result, return_value) == FAILURE) {
zval_dtor(return_value);
RETURN_FALSE;
}
}
|
DoS
| 0
|
PHP_FUNCTION(pg_fetch_all)
{
zval *result;
PGresult *pgsql_result;
pgsql_result_handle *pg_result;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &result) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, result, -1, "PostgreSQL result", le_result);
pgsql_result = pg_result->result;
array_init(return_value);
if (php_pgsql_result2array(pgsql_result, return_value) == FAILURE) {
zval_dtor(return_value);
RETURN_FALSE;
}
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,085
|
PHP_FUNCTION(pg_result_seek)
{
zval *result;
zend_long row;
pgsql_result_handle *pg_result;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &result, &row) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, result, -1, "PostgreSQL result", le_result);
if (row < 0 || row >= PQntuples(pg_result->result)) {
RETURN_FALSE;
}
/* seek to offset */
pg_result->row = (int)row;
RETURN_TRUE;
}
|
DoS
| 0
|
PHP_FUNCTION(pg_result_seek)
{
zval *result;
zend_long row;
pgsql_result_handle *pg_result;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "rl", &result, &row) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, result, -1, "PostgreSQL result", le_result);
if (row < 0 || row >= PQntuples(pg_result->result)) {
RETURN_FALSE;
}
/* seek to offset */
pg_result->row = (int)row;
RETURN_TRUE;
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,086
|
PHP_FUNCTION(pg_field_prtlen)
{
php_pgsql_data_info(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_PG_DATA_LENGTH);
}
|
DoS
| 0
|
PHP_FUNCTION(pg_field_prtlen)
{
php_pgsql_data_info(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_PG_DATA_LENGTH);
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,087
|
PHP_FUNCTION(pg_free_result)
{
zval *result;
pgsql_result_handle *pg_result;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &result) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, result, -1, "PostgreSQL result", le_result);
if (Z_RES_P(result) == NULL) {
RETURN_FALSE;
}
zend_list_close(Z_RES_P(result));
RETURN_TRUE;
}
|
DoS
| 0
|
PHP_FUNCTION(pg_free_result)
{
zval *result;
pgsql_result_handle *pg_result;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &result) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, result, -1, "PostgreSQL result", le_result);
if (Z_RES_P(result) == NULL) {
RETURN_FALSE;
}
zend_list_close(Z_RES_P(result));
RETURN_TRUE;
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,088
|
PHP_FUNCTION(pg_last_oid)
{
zval *result;
PGresult *pgsql_result;
pgsql_result_handle *pg_result;
#ifdef HAVE_PQOIDVALUE
Oid oid;
#endif
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &result) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, result, -1, "PostgreSQL result", le_result);
pgsql_result = pg_result->result;
#ifdef HAVE_PQOIDVALUE
oid = PQoidValue(pgsql_result);
if (oid == InvalidOid) {
RETURN_FALSE;
}
PGSQL_RETURN_OID(oid);
#else
Z_STRVAL_P(return_value) = (char *) PQoidStatus(pgsql_result);
if (Z_STRVAL_P(return_value)) {
RETURN_STRING(Z_STRVAL_P(return_value));
}
RETURN_EMPTY_STRING();
#endif
}
|
DoS
| 0
|
PHP_FUNCTION(pg_last_oid)
{
zval *result;
PGresult *pgsql_result;
pgsql_result_handle *pg_result;
#ifdef HAVE_PQOIDVALUE
Oid oid;
#endif
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &result) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(pg_result, pgsql_result_handle *, result, -1, "PostgreSQL result", le_result);
pgsql_result = pg_result->result;
#ifdef HAVE_PQOIDVALUE
oid = PQoidValue(pgsql_result);
if (oid == InvalidOid) {
RETURN_FALSE;
}
PGSQL_RETURN_OID(oid);
#else
Z_STRVAL_P(return_value) = (char *) PQoidStatus(pgsql_result);
if (Z_STRVAL_P(return_value)) {
RETURN_STRING(Z_STRVAL_P(return_value));
}
RETURN_EMPTY_STRING();
#endif
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,089
|
PHP_FUNCTION(pg_trace)
{
char *z_filename, *mode = "w";
size_t z_filename_len, mode_len;
zval *pgsql_link = NULL;
int id = -1, argc = ZEND_NUM_ARGS();
PGconn *pgsql;
FILE *fp = NULL;
php_stream *stream;
id = FETCH_DEFAULT_LINK();
if (zend_parse_parameters(argc, "s|sr", &z_filename, &z_filename_len, &mode, &mode_len, &pgsql_link) == FAILURE) {
return;
}
if (argc < 3) {
CHECK_DEFAULT_LINK(id);
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
stream = php_stream_open_wrapper(z_filename, mode, REPORT_ERRORS, NULL);
if (!stream) {
RETURN_FALSE;
}
if (FAILURE == php_stream_cast(stream, PHP_STREAM_AS_STDIO, (void**)&fp, REPORT_ERRORS)) {
php_stream_close(stream);
RETURN_FALSE;
}
php_stream_auto_cleanup(stream);
PQtrace(pgsql, fp);
RETURN_TRUE;
}
|
DoS
| 0
|
PHP_FUNCTION(pg_trace)
{
char *z_filename, *mode = "w";
size_t z_filename_len, mode_len;
zval *pgsql_link = NULL;
int id = -1, argc = ZEND_NUM_ARGS();
PGconn *pgsql;
FILE *fp = NULL;
php_stream *stream;
id = FETCH_DEFAULT_LINK();
if (zend_parse_parameters(argc, "s|sr", &z_filename, &z_filename_len, &mode, &mode_len, &pgsql_link) == FAILURE) {
return;
}
if (argc < 3) {
CHECK_DEFAULT_LINK(id);
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
stream = php_stream_open_wrapper(z_filename, mode, REPORT_ERRORS, NULL);
if (!stream) {
RETURN_FALSE;
}
if (FAILURE == php_stream_cast(stream, PHP_STREAM_AS_STDIO, (void**)&fp, REPORT_ERRORS)) {
php_stream_close(stream);
RETURN_FALSE;
}
php_stream_auto_cleanup(stream);
PQtrace(pgsql, fp);
RETURN_TRUE;
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,090
|
PHP_FUNCTION(pg_untrace)
{
zval *pgsql_link = NULL;
int id = -1, argc = ZEND_NUM_ARGS();
PGconn *pgsql;
if (zend_parse_parameters(argc, "|r", &pgsql_link) == FAILURE) {
return;
}
if (argc == 0) {
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
PQuntrace(pgsql);
RETURN_TRUE;
}
|
DoS
| 0
|
PHP_FUNCTION(pg_untrace)
{
zval *pgsql_link = NULL;
int id = -1, argc = ZEND_NUM_ARGS();
PGconn *pgsql;
if (zend_parse_parameters(argc, "|r", &pgsql_link) == FAILURE) {
return;
}
if (argc == 0) {
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
PQuntrace(pgsql);
RETURN_TRUE;
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,091
|
PHP_FUNCTION(pg_lo_create)
{
zval *pgsql_link = NULL, *oid = NULL;
PGconn *pgsql;
Oid pgsql_oid, wanted_oid = InvalidOid;
int id = -1, argc = ZEND_NUM_ARGS();
if (zend_parse_parameters(argc, "|zz", &pgsql_link, &oid) == FAILURE) {
return;
}
if ((argc == 1) && (Z_TYPE_P(pgsql_link) != IS_RESOURCE)) {
oid = pgsql_link;
pgsql_link = NULL;
}
if (pgsql_link == NULL) {
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
if (id == -1) {
RETURN_FALSE;
}
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
if (oid) {
#ifndef HAVE_PG_LO_CREATE
php_error_docref(NULL, E_NOTICE, "Passing OID value is not supported. Upgrade your PostgreSQL");
#else
switch (Z_TYPE_P(oid)) {
case IS_STRING:
{
char *end_ptr;
wanted_oid = (Oid)strtoul(Z_STRVAL_P(oid), &end_ptr, 10);
if ((Z_STRVAL_P(oid)+Z_STRLEN_P(oid)) != end_ptr) {
/* wrong integer format */
php_error_docref(NULL, E_NOTICE, "invalid OID value passed");
RETURN_FALSE;
}
}
break;
case IS_LONG:
if (Z_LVAL_P(oid) < (zend_long)InvalidOid) {
php_error_docref(NULL, E_NOTICE, "invalid OID value passed");
RETURN_FALSE;
}
wanted_oid = (Oid)Z_LVAL_P(oid);
break;
default:
php_error_docref(NULL, E_NOTICE, "invalid OID value passed");
RETURN_FALSE;
}
if ((pgsql_oid = lo_create(pgsql, wanted_oid)) == InvalidOid) {
php_error_docref(NULL, E_WARNING, "Unable to create PostgreSQL large object");
RETURN_FALSE;
}
PGSQL_RETURN_OID(pgsql_oid);
#endif
}
if ((pgsql_oid = lo_creat(pgsql, INV_READ|INV_WRITE)) == InvalidOid) {
php_error_docref(NULL, E_WARNING, "Unable to create PostgreSQL large object");
RETURN_FALSE;
}
PGSQL_RETURN_OID(pgsql_oid);
}
|
DoS
| 0
|
PHP_FUNCTION(pg_lo_create)
{
zval *pgsql_link = NULL, *oid = NULL;
PGconn *pgsql;
Oid pgsql_oid, wanted_oid = InvalidOid;
int id = -1, argc = ZEND_NUM_ARGS();
if (zend_parse_parameters(argc, "|zz", &pgsql_link, &oid) == FAILURE) {
return;
}
if ((argc == 1) && (Z_TYPE_P(pgsql_link) != IS_RESOURCE)) {
oid = pgsql_link;
pgsql_link = NULL;
}
if (pgsql_link == NULL) {
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
if (id == -1) {
RETURN_FALSE;
}
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
if (oid) {
#ifndef HAVE_PG_LO_CREATE
php_error_docref(NULL, E_NOTICE, "Passing OID value is not supported. Upgrade your PostgreSQL");
#else
switch (Z_TYPE_P(oid)) {
case IS_STRING:
{
char *end_ptr;
wanted_oid = (Oid)strtoul(Z_STRVAL_P(oid), &end_ptr, 10);
if ((Z_STRVAL_P(oid)+Z_STRLEN_P(oid)) != end_ptr) {
/* wrong integer format */
php_error_docref(NULL, E_NOTICE, "invalid OID value passed");
RETURN_FALSE;
}
}
break;
case IS_LONG:
if (Z_LVAL_P(oid) < (zend_long)InvalidOid) {
php_error_docref(NULL, E_NOTICE, "invalid OID value passed");
RETURN_FALSE;
}
wanted_oid = (Oid)Z_LVAL_P(oid);
break;
default:
php_error_docref(NULL, E_NOTICE, "invalid OID value passed");
RETURN_FALSE;
}
if ((pgsql_oid = lo_create(pgsql, wanted_oid)) == InvalidOid) {
php_error_docref(NULL, E_WARNING, "Unable to create PostgreSQL large object");
RETURN_FALSE;
}
PGSQL_RETURN_OID(pgsql_oid);
#endif
}
if ((pgsql_oid = lo_creat(pgsql, INV_READ|INV_WRITE)) == InvalidOid) {
php_error_docref(NULL, E_WARNING, "Unable to create PostgreSQL large object");
RETURN_FALSE;
}
PGSQL_RETURN_OID(pgsql_oid);
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,092
|
PHP_FUNCTION(pg_lo_open)
{
zval *pgsql_link = NULL;
zend_long oid_long;
char *oid_string, *end_ptr, *mode_string;
size_t oid_strlen, mode_strlen;
PGconn *pgsql;
Oid oid;
int id = -1, pgsql_mode=0, pgsql_lofd;
int create = 0;
pgLofp *pgsql_lofp;
int argc = ZEND_NUM_ARGS();
/* accept string type since Oid is unsigned int */
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"rss", &pgsql_link, &oid_string, &oid_strlen, &mode_string, &mode_strlen) == SUCCESS) {
oid = (Oid)strtoul(oid_string, &end_ptr, 10);
if ((oid_string+oid_strlen) != end_ptr) {
/* wrong integer format */
php_error_docref(NULL, E_NOTICE, "Wrong OID value passed");
RETURN_FALSE;
}
}
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"rls", &pgsql_link, &oid_long, &mode_string, &mode_strlen) == SUCCESS) {
if (oid_long <= InvalidOid) {
php_error_docref(NULL, E_NOTICE, "Invalid OID specified");
RETURN_FALSE;
}
oid = (Oid)oid_long;
}
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"ss", &oid_string, &oid_strlen, &mode_string, &mode_strlen) == SUCCESS) {
oid = (Oid)strtoul(oid_string, &end_ptr, 10);
if ((oid_string+oid_strlen) != end_ptr) {
/* wrong integer format */
php_error_docref(NULL, E_NOTICE, "Wrong OID value passed");
RETURN_FALSE;
}
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
}
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"ls", &oid_long, &mode_string, &mode_strlen) == SUCCESS) {
if (oid_long <= InvalidOid) {
php_error_docref(NULL, E_NOTICE, "Invalid OID specified");
RETURN_FALSE;
}
oid = (Oid)oid_long;
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
}
else {
php_error_docref(NULL, E_WARNING, "Requires 1 or 2 arguments");
RETURN_FALSE;
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
/* r/w/+ is little bit more PHP-like than INV_READ/INV_WRITE and a lot of
faster to type. Unfortunately, doesn't behave the same way as fopen()...
(Jouni)
*/
if (strchr(mode_string, 'r') == mode_string) {
pgsql_mode |= INV_READ;
if (strchr(mode_string, '+') == mode_string+1) {
pgsql_mode |= INV_WRITE;
}
}
if (strchr(mode_string, 'w') == mode_string) {
pgsql_mode |= INV_WRITE;
create = 1;
if (strchr(mode_string, '+') == mode_string+1) {
pgsql_mode |= INV_READ;
}
}
pgsql_lofp = (pgLofp *) emalloc(sizeof(pgLofp));
if ((pgsql_lofd = lo_open(pgsql, oid, pgsql_mode)) == -1) {
if (create) {
if ((oid = lo_creat(pgsql, INV_READ|INV_WRITE)) == 0) {
efree(pgsql_lofp);
php_error_docref(NULL, E_WARNING, "Unable to create PostgreSQL large object");
RETURN_FALSE;
} else {
if ((pgsql_lofd = lo_open(pgsql, oid, pgsql_mode)) == -1) {
if (lo_unlink(pgsql, oid) == -1) {
efree(pgsql_lofp);
php_error_docref(NULL, E_WARNING, "Something is really messed up! Your database is badly corrupted in a way NOT related to PHP");
RETURN_FALSE;
}
efree(pgsql_lofp);
php_error_docref(NULL, E_WARNING, "Unable to open PostgreSQL large object");
RETURN_FALSE;
} else {
pgsql_lofp->conn = pgsql;
pgsql_lofp->lofd = pgsql_lofd;
ZEND_REGISTER_RESOURCE(return_value, pgsql_lofp, le_lofp);
}
}
} else {
efree(pgsql_lofp);
php_error_docref(NULL, E_WARNING, "Unable to open PostgreSQL large object");
RETURN_FALSE;
}
} else {
pgsql_lofp->conn = pgsql;
pgsql_lofp->lofd = pgsql_lofd;
ZEND_REGISTER_RESOURCE(return_value, pgsql_lofp, le_lofp);
}
}
|
DoS
| 0
|
PHP_FUNCTION(pg_lo_open)
{
zval *pgsql_link = NULL;
zend_long oid_long;
char *oid_string, *end_ptr, *mode_string;
size_t oid_strlen, mode_strlen;
PGconn *pgsql;
Oid oid;
int id = -1, pgsql_mode=0, pgsql_lofd;
int create = 0;
pgLofp *pgsql_lofp;
int argc = ZEND_NUM_ARGS();
/* accept string type since Oid is unsigned int */
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"rss", &pgsql_link, &oid_string, &oid_strlen, &mode_string, &mode_strlen) == SUCCESS) {
oid = (Oid)strtoul(oid_string, &end_ptr, 10);
if ((oid_string+oid_strlen) != end_ptr) {
/* wrong integer format */
php_error_docref(NULL, E_NOTICE, "Wrong OID value passed");
RETURN_FALSE;
}
}
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"rls", &pgsql_link, &oid_long, &mode_string, &mode_strlen) == SUCCESS) {
if (oid_long <= InvalidOid) {
php_error_docref(NULL, E_NOTICE, "Invalid OID specified");
RETURN_FALSE;
}
oid = (Oid)oid_long;
}
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"ss", &oid_string, &oid_strlen, &mode_string, &mode_strlen) == SUCCESS) {
oid = (Oid)strtoul(oid_string, &end_ptr, 10);
if ((oid_string+oid_strlen) != end_ptr) {
/* wrong integer format */
php_error_docref(NULL, E_NOTICE, "Wrong OID value passed");
RETURN_FALSE;
}
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
}
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"ls", &oid_long, &mode_string, &mode_strlen) == SUCCESS) {
if (oid_long <= InvalidOid) {
php_error_docref(NULL, E_NOTICE, "Invalid OID specified");
RETURN_FALSE;
}
oid = (Oid)oid_long;
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
}
else {
php_error_docref(NULL, E_WARNING, "Requires 1 or 2 arguments");
RETURN_FALSE;
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
/* r/w/+ is little bit more PHP-like than INV_READ/INV_WRITE and a lot of
faster to type. Unfortunately, doesn't behave the same way as fopen()...
(Jouni)
*/
if (strchr(mode_string, 'r') == mode_string) {
pgsql_mode |= INV_READ;
if (strchr(mode_string, '+') == mode_string+1) {
pgsql_mode |= INV_WRITE;
}
}
if (strchr(mode_string, 'w') == mode_string) {
pgsql_mode |= INV_WRITE;
create = 1;
if (strchr(mode_string, '+') == mode_string+1) {
pgsql_mode |= INV_READ;
}
}
pgsql_lofp = (pgLofp *) emalloc(sizeof(pgLofp));
if ((pgsql_lofd = lo_open(pgsql, oid, pgsql_mode)) == -1) {
if (create) {
if ((oid = lo_creat(pgsql, INV_READ|INV_WRITE)) == 0) {
efree(pgsql_lofp);
php_error_docref(NULL, E_WARNING, "Unable to create PostgreSQL large object");
RETURN_FALSE;
} else {
if ((pgsql_lofd = lo_open(pgsql, oid, pgsql_mode)) == -1) {
if (lo_unlink(pgsql, oid) == -1) {
efree(pgsql_lofp);
php_error_docref(NULL, E_WARNING, "Something is really messed up! Your database is badly corrupted in a way NOT related to PHP");
RETURN_FALSE;
}
efree(pgsql_lofp);
php_error_docref(NULL, E_WARNING, "Unable to open PostgreSQL large object");
RETURN_FALSE;
} else {
pgsql_lofp->conn = pgsql;
pgsql_lofp->lofd = pgsql_lofd;
ZEND_REGISTER_RESOURCE(return_value, pgsql_lofp, le_lofp);
}
}
} else {
efree(pgsql_lofp);
php_error_docref(NULL, E_WARNING, "Unable to open PostgreSQL large object");
RETURN_FALSE;
}
} else {
pgsql_lofp->conn = pgsql;
pgsql_lofp->lofd = pgsql_lofd;
ZEND_REGISTER_RESOURCE(return_value, pgsql_lofp, le_lofp);
}
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,093
|
PHP_FUNCTION(pg_lo_close)
{
zval *pgsql_lofp;
pgLofp *pgsql;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pgsql_lofp) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(pgsql, pgLofp *, pgsql_lofp, -1, "PostgreSQL large object", le_lofp);
if (lo_close((PGconn *)pgsql->conn, pgsql->lofd) < 0) {
php_error_docref(NULL, E_WARNING, "Unable to close PostgreSQL large object descriptor %d", pgsql->lofd);
RETVAL_FALSE;
} else {
RETVAL_TRUE;
}
zend_list_close(Z_RES_P(pgsql_lofp));
return;
}
|
DoS
| 0
|
PHP_FUNCTION(pg_lo_close)
{
zval *pgsql_lofp;
pgLofp *pgsql;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pgsql_lofp) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(pgsql, pgLofp *, pgsql_lofp, -1, "PostgreSQL large object", le_lofp);
if (lo_close((PGconn *)pgsql->conn, pgsql->lofd) < 0) {
php_error_docref(NULL, E_WARNING, "Unable to close PostgreSQL large object descriptor %d", pgsql->lofd);
RETVAL_FALSE;
} else {
RETVAL_TRUE;
}
zend_list_close(Z_RES_P(pgsql_lofp));
return;
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,094
|
PHP_FUNCTION(pg_lo_read)
{
zval *pgsql_id;
zend_long len;
size_t buf_len = PGSQL_LO_READ_BUF_SIZE;
int nbytes, argc = ZEND_NUM_ARGS();
zend_string *buf;
pgLofp *pgsql;
if (zend_parse_parameters(argc, "r|l", &pgsql_id, &len) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(pgsql, pgLofp *, pgsql_id, -1, "PostgreSQL large object", le_lofp);
if (argc > 1) {
buf_len = len < 0 ? 0 : len;
}
buf = zend_string_alloc(buf_len, 0);
if ((nbytes = lo_read((PGconn *)pgsql->conn, pgsql->lofd, buf->val, buf->len))<0) {
zend_string_free(buf);
RETURN_FALSE;
}
buf->len = nbytes;
buf->val[buf->len] = '\0';
RETURN_STR(buf);
}
|
DoS
| 0
|
PHP_FUNCTION(pg_lo_read)
{
zval *pgsql_id;
zend_long len;
size_t buf_len = PGSQL_LO_READ_BUF_SIZE;
int nbytes, argc = ZEND_NUM_ARGS();
zend_string *buf;
pgLofp *pgsql;
if (zend_parse_parameters(argc, "r|l", &pgsql_id, &len) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(pgsql, pgLofp *, pgsql_id, -1, "PostgreSQL large object", le_lofp);
if (argc > 1) {
buf_len = len < 0 ? 0 : len;
}
buf = zend_string_alloc(buf_len, 0);
if ((nbytes = lo_read((PGconn *)pgsql->conn, pgsql->lofd, buf->val, buf->len))<0) {
zend_string_free(buf);
RETURN_FALSE;
}
buf->len = nbytes;
buf->val[buf->len] = '\0';
RETURN_STR(buf);
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,095
|
PHP_FUNCTION(pg_lo_write)
{
zval *pgsql_id;
char *str;
zend_long z_len;
size_t str_len, nbytes;
size_t len;
pgLofp *pgsql;
int argc = ZEND_NUM_ARGS();
if (zend_parse_parameters(argc, "rs|l", &pgsql_id, &str, &str_len, &z_len) == FAILURE) {
return;
}
if (argc > 2) {
if (z_len > (zend_long)str_len) {
php_error_docref(NULL, E_WARNING, "Cannot write more than buffer size %d. Tried to write %pd", str_len, z_len);
RETURN_FALSE;
}
if (z_len < 0) {
php_error_docref(NULL, E_WARNING, "Buffer size must be larger than 0, but %pd was specified", z_len);
RETURN_FALSE;
}
len = z_len;
}
else {
len = str_len;
}
ZEND_FETCH_RESOURCE(pgsql, pgLofp *, pgsql_id, -1, "PostgreSQL large object", le_lofp);
if ((nbytes = lo_write((PGconn *)pgsql->conn, pgsql->lofd, str, len)) == -1) {
RETURN_FALSE;
}
RETURN_LONG(nbytes);
}
|
DoS
| 0
|
PHP_FUNCTION(pg_lo_write)
{
zval *pgsql_id;
char *str;
zend_long z_len;
size_t str_len, nbytes;
size_t len;
pgLofp *pgsql;
int argc = ZEND_NUM_ARGS();
if (zend_parse_parameters(argc, "rs|l", &pgsql_id, &str, &str_len, &z_len) == FAILURE) {
return;
}
if (argc > 2) {
if (z_len > (zend_long)str_len) {
php_error_docref(NULL, E_WARNING, "Cannot write more than buffer size %d. Tried to write %pd", str_len, z_len);
RETURN_FALSE;
}
if (z_len < 0) {
php_error_docref(NULL, E_WARNING, "Buffer size must be larger than 0, but %pd was specified", z_len);
RETURN_FALSE;
}
len = z_len;
}
else {
len = str_len;
}
ZEND_FETCH_RESOURCE(pgsql, pgLofp *, pgsql_id, -1, "PostgreSQL large object", le_lofp);
if ((nbytes = lo_write((PGconn *)pgsql->conn, pgsql->lofd, str, len)) == -1) {
RETURN_FALSE;
}
RETURN_LONG(nbytes);
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,096
|
PHP_FUNCTION(pg_lo_read_all)
{
zval *pgsql_id;
int tbytes;
volatile int nbytes;
char buf[PGSQL_LO_READ_BUF_SIZE];
pgLofp *pgsql;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pgsql_id) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(pgsql, pgLofp *, pgsql_id, -1, "PostgreSQL large object", le_lofp);
tbytes = 0;
while ((nbytes = lo_read((PGconn *)pgsql->conn, pgsql->lofd, buf, PGSQL_LO_READ_BUF_SIZE))>0) {
PHPWRITE(buf, nbytes);
tbytes += nbytes;
}
RETURN_LONG(tbytes);
}
|
DoS
| 0
|
PHP_FUNCTION(pg_lo_read_all)
{
zval *pgsql_id;
int tbytes;
volatile int nbytes;
char buf[PGSQL_LO_READ_BUF_SIZE];
pgLofp *pgsql;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "r", &pgsql_id) == FAILURE) {
return;
}
ZEND_FETCH_RESOURCE(pgsql, pgLofp *, pgsql_id, -1, "PostgreSQL large object", le_lofp);
tbytes = 0;
while ((nbytes = lo_read((PGconn *)pgsql->conn, pgsql->lofd, buf, PGSQL_LO_READ_BUF_SIZE))>0) {
PHPWRITE(buf, nbytes);
tbytes += nbytes;
}
RETURN_LONG(tbytes);
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,097
|
PHP_FUNCTION(pg_lo_import)
{
zval *pgsql_link = NULL, *oid = NULL;
char *file_in;
int id = -1;
size_t name_len;
int argc = ZEND_NUM_ARGS();
PGconn *pgsql;
Oid returned_oid;
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"rp|z", &pgsql_link, &file_in, &name_len, &oid) == SUCCESS) {
;
}
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"p|z", &file_in, &name_len, &oid) == SUCCESS) {
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
}
/* old calling convention, deprecated since PHP 4.2 */
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"pr", &file_in, &name_len, &pgsql_link ) == SUCCESS) {
php_error_docref(NULL, E_NOTICE, "Old API is used");
}
else {
WRONG_PARAM_COUNT;
}
if (php_check_open_basedir(file_in)) {
RETURN_FALSE;
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
if (oid) {
#ifndef HAVE_PG_LO_IMPORT_WITH_OID
php_error_docref(NULL, E_NOTICE, "OID value passing not supported");
#else
Oid wanted_oid;
switch (Z_TYPE_P(oid)) {
case IS_STRING:
{
char *end_ptr;
wanted_oid = (Oid)strtoul(Z_STRVAL_P(oid), &end_ptr, 10);
if ((Z_STRVAL_P(oid)+Z_STRLEN_P(oid)) != end_ptr) {
/* wrong integer format */
php_error_docref(NULL, E_NOTICE, "invalid OID value passed");
RETURN_FALSE;
}
}
break;
case IS_LONG:
if (Z_LVAL_P(oid) < (zend_long)InvalidOid) {
php_error_docref(NULL, E_NOTICE, "invalid OID value passed");
RETURN_FALSE;
}
wanted_oid = (Oid)Z_LVAL_P(oid);
break;
default:
php_error_docref(NULL, E_NOTICE, "invalid OID value passed");
RETURN_FALSE;
}
returned_oid = lo_import_with_oid(pgsql, file_in, wanted_oid);
if (returned_oid == InvalidOid) {
RETURN_FALSE;
}
PGSQL_RETURN_OID(returned_oid);
#endif
}
returned_oid = lo_import(pgsql, file_in);
if (returned_oid == InvalidOid) {
RETURN_FALSE;
}
PGSQL_RETURN_OID(returned_oid);
}
|
DoS
| 0
|
PHP_FUNCTION(pg_lo_import)
{
zval *pgsql_link = NULL, *oid = NULL;
char *file_in;
int id = -1;
size_t name_len;
int argc = ZEND_NUM_ARGS();
PGconn *pgsql;
Oid returned_oid;
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"rp|z", &pgsql_link, &file_in, &name_len, &oid) == SUCCESS) {
;
}
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"p|z", &file_in, &name_len, &oid) == SUCCESS) {
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
}
/* old calling convention, deprecated since PHP 4.2 */
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"pr", &file_in, &name_len, &pgsql_link ) == SUCCESS) {
php_error_docref(NULL, E_NOTICE, "Old API is used");
}
else {
WRONG_PARAM_COUNT;
}
if (php_check_open_basedir(file_in)) {
RETURN_FALSE;
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
if (oid) {
#ifndef HAVE_PG_LO_IMPORT_WITH_OID
php_error_docref(NULL, E_NOTICE, "OID value passing not supported");
#else
Oid wanted_oid;
switch (Z_TYPE_P(oid)) {
case IS_STRING:
{
char *end_ptr;
wanted_oid = (Oid)strtoul(Z_STRVAL_P(oid), &end_ptr, 10);
if ((Z_STRVAL_P(oid)+Z_STRLEN_P(oid)) != end_ptr) {
/* wrong integer format */
php_error_docref(NULL, E_NOTICE, "invalid OID value passed");
RETURN_FALSE;
}
}
break;
case IS_LONG:
if (Z_LVAL_P(oid) < (zend_long)InvalidOid) {
php_error_docref(NULL, E_NOTICE, "invalid OID value passed");
RETURN_FALSE;
}
wanted_oid = (Oid)Z_LVAL_P(oid);
break;
default:
php_error_docref(NULL, E_NOTICE, "invalid OID value passed");
RETURN_FALSE;
}
returned_oid = lo_import_with_oid(pgsql, file_in, wanted_oid);
if (returned_oid == InvalidOid) {
RETURN_FALSE;
}
PGSQL_RETURN_OID(returned_oid);
#endif
}
returned_oid = lo_import(pgsql, file_in);
if (returned_oid == InvalidOid) {
RETURN_FALSE;
}
PGSQL_RETURN_OID(returned_oid);
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,098
|
PHP_FUNCTION(pg_lo_export)
{
zval *pgsql_link = NULL;
char *file_out, *oid_string, *end_ptr;
size_t oid_strlen;
int id = -1;
size_t name_len;
zend_long oid_long;
Oid oid;
PGconn *pgsql;
int argc = ZEND_NUM_ARGS();
/* allow string to handle large OID value correctly */
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"rlp", &pgsql_link, &oid_long, &file_out, &name_len) == SUCCESS) {
if (oid_long <= InvalidOid) {
php_error_docref(NULL, E_NOTICE, "Invalid OID specified");
RETURN_FALSE;
}
oid = (Oid)oid_long;
}
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"rss", &pgsql_link, &oid_string, &oid_strlen, &file_out, &name_len) == SUCCESS) {
oid = (Oid)strtoul(oid_string, &end_ptr, 10);
if ((oid_string+oid_strlen) != end_ptr) {
/* wrong integer format */
php_error_docref(NULL, E_NOTICE, "Wrong OID value passed");
RETURN_FALSE;
}
}
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"lp", &oid_long, &file_out, &name_len) == SUCCESS) {
if (oid_long <= InvalidOid) {
php_error_docref(NULL, E_NOTICE, "Invalid OID specified");
RETURN_FALSE;
}
oid = (Oid)oid_long;
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
}
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"sp", &oid_string, &oid_strlen, &file_out, &name_len) == SUCCESS) {
oid = (Oid)strtoul(oid_string, &end_ptr, 10);
if ((oid_string+oid_strlen) != end_ptr) {
/* wrong integer format */
php_error_docref(NULL, E_NOTICE, "Wrong OID value passed");
RETURN_FALSE;
}
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
}
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"spr", &oid_string, &oid_strlen, &file_out, &name_len, &pgsql_link) == SUCCESS) {
oid = (Oid)strtoul(oid_string, &end_ptr, 10);
if ((oid_string+oid_strlen) != end_ptr) {
/* wrong integer format */
php_error_docref(NULL, E_NOTICE, "Wrong OID value passed");
RETURN_FALSE;
}
}
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"lpr", &oid_long, &file_out, &name_len, &pgsql_link) == SUCCESS) {
php_error_docref(NULL, E_NOTICE, "Old API is used");
if (oid_long <= InvalidOid) {
php_error_docref(NULL, E_NOTICE, "Invalid OID specified");
RETURN_FALSE;
}
oid = (Oid)oid_long;
}
else {
php_error_docref(NULL, E_WARNING, "Requires 2 or 3 arguments");
RETURN_FALSE;
}
if (php_check_open_basedir(file_out)) {
RETURN_FALSE;
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
if (lo_export(pgsql, oid, file_out) == -1) {
RETURN_FALSE;
}
RETURN_TRUE;
}
|
DoS
| 0
|
PHP_FUNCTION(pg_lo_export)
{
zval *pgsql_link = NULL;
char *file_out, *oid_string, *end_ptr;
size_t oid_strlen;
int id = -1;
size_t name_len;
zend_long oid_long;
Oid oid;
PGconn *pgsql;
int argc = ZEND_NUM_ARGS();
/* allow string to handle large OID value correctly */
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"rlp", &pgsql_link, &oid_long, &file_out, &name_len) == SUCCESS) {
if (oid_long <= InvalidOid) {
php_error_docref(NULL, E_NOTICE, "Invalid OID specified");
RETURN_FALSE;
}
oid = (Oid)oid_long;
}
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"rss", &pgsql_link, &oid_string, &oid_strlen, &file_out, &name_len) == SUCCESS) {
oid = (Oid)strtoul(oid_string, &end_ptr, 10);
if ((oid_string+oid_strlen) != end_ptr) {
/* wrong integer format */
php_error_docref(NULL, E_NOTICE, "Wrong OID value passed");
RETURN_FALSE;
}
}
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"lp", &oid_long, &file_out, &name_len) == SUCCESS) {
if (oid_long <= InvalidOid) {
php_error_docref(NULL, E_NOTICE, "Invalid OID specified");
RETURN_FALSE;
}
oid = (Oid)oid_long;
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
}
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"sp", &oid_string, &oid_strlen, &file_out, &name_len) == SUCCESS) {
oid = (Oid)strtoul(oid_string, &end_ptr, 10);
if ((oid_string+oid_strlen) != end_ptr) {
/* wrong integer format */
php_error_docref(NULL, E_NOTICE, "Wrong OID value passed");
RETURN_FALSE;
}
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
}
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"spr", &oid_string, &oid_strlen, &file_out, &name_len, &pgsql_link) == SUCCESS) {
oid = (Oid)strtoul(oid_string, &end_ptr, 10);
if ((oid_string+oid_strlen) != end_ptr) {
/* wrong integer format */
php_error_docref(NULL, E_NOTICE, "Wrong OID value passed");
RETURN_FALSE;
}
}
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc,
"lpr", &oid_long, &file_out, &name_len, &pgsql_link) == SUCCESS) {
php_error_docref(NULL, E_NOTICE, "Old API is used");
if (oid_long <= InvalidOid) {
php_error_docref(NULL, E_NOTICE, "Invalid OID specified");
RETURN_FALSE;
}
oid = (Oid)oid_long;
}
else {
php_error_docref(NULL, E_WARNING, "Requires 2 or 3 arguments");
RETURN_FALSE;
}
if (php_check_open_basedir(file_out)) {
RETURN_FALSE;
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
if (lo_export(pgsql, oid, file_out) == -1) {
RETURN_FALSE;
}
RETURN_TRUE;
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
4,099
|
PHP_FUNCTION(pg_set_error_verbosity)
{
zval *pgsql_link = NULL;
zend_long verbosity;
int id = -1, argc = ZEND_NUM_ARGS();
PGconn *pgsql;
if (argc == 1) {
if (zend_parse_parameters(argc, "l", &verbosity) == FAILURE) {
return;
}
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
} else {
if (zend_parse_parameters(argc, "rl", &pgsql_link, &verbosity) == FAILURE) {
return;
}
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
if (verbosity & (PQERRORS_TERSE|PQERRORS_DEFAULT|PQERRORS_VERBOSE)) {
RETURN_LONG(PQsetErrorVerbosity(pgsql, verbosity));
} else {
RETURN_FALSE;
}
}
|
DoS
| 0
|
PHP_FUNCTION(pg_set_error_verbosity)
{
zval *pgsql_link = NULL;
zend_long verbosity;
int id = -1, argc = ZEND_NUM_ARGS();
PGconn *pgsql;
if (argc == 1) {
if (zend_parse_parameters(argc, "l", &verbosity) == FAILURE) {
return;
}
id = FETCH_DEFAULT_LINK();
CHECK_DEFAULT_LINK(id);
} else {
if (zend_parse_parameters(argc, "rl", &pgsql_link, &verbosity) == FAILURE) {
return;
}
}
if (pgsql_link == NULL && id == -1) {
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
if (verbosity & (PQERRORS_TERSE|PQERRORS_DEFAULT|PQERRORS_VERBOSE)) {
RETURN_LONG(PQsetErrorVerbosity(pgsql, verbosity));
} else {
RETURN_FALSE;
}
}
|
@@ -6445,6 +6445,9 @@ static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const c
/* schame.table should be "schame"."table" */
table_copy = estrdup(table);
token = php_strtok_r(table_copy, ".", &tmp);
+ if (token == NULL) {
+ token = table;
+ }
len = strlen(token);
if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) {
smart_str_appendl(querystr, token, len);
| null | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.