idx
int64
func_before
string
Vulnerability Classification
string
vul
int64
func_after
string
patch
string
CWE ID
string
lines_before
string
lines_after
string
8,800
push_compress_filter2(IOBUF out,compress_filter_context_t *zfx, int algo,int rel) { if(algo>=0) zfx->algo=algo; else zfx->algo=DEFAULT_COMPRESS_ALGO; switch(zfx->algo) { case COMPRESS_ALGO_NONE: break; case COMPRESS_ALGO_ZIP: case COMPRESS_ALGO_ZLIB: iobuf_push_filter2(out,compress_filter,zfx,rel); break; #ifdef HAVE_BZIP2 case COMPRESS_ALGO_BZIP2: iobuf_push_filter2(out,compress_filter_bz2,zfx,rel); break; #endif default: BUG(); } }
DoS
0
push_compress_filter2(IOBUF out,compress_filter_context_t *zfx, int algo,int rel) { if(algo>=0) zfx->algo=algo; else zfx->algo=DEFAULT_COMPRESS_ALGO; switch(zfx->algo) { case COMPRESS_ALGO_NONE: break; case COMPRESS_ALGO_ZIP: case COMPRESS_ALGO_ZLIB: iobuf_push_filter2(out,compress_filter,zfx,rel); break; #ifdef HAVE_BZIP2 case COMPRESS_ALGO_BZIP2: iobuf_push_filter2(out,compress_filter_bz2,zfx,rel); break; #endif default: BUG(); } }
@@ -161,7 +161,8 @@ do_uncompress( compress_filter_context_t *zfx, z_stream *zs, IOBUF a, size_t *ret_len ) { int zrc; - int rc=0; + int rc = 0; + int leave = 0; size_t n; int nread, count; int refill = !zs->avail_in; @@ -179,13 +180,14 @@ do_uncompress( compress_filter_context_t *zfx, z_stream *zs, nread = iobuf_read( a, zfx->inbuf + n, count ); if( nread == -1 ) nread = 0; n += nread; - /* If we use the undocumented feature to suppress - * the zlib header, we have to give inflate an - * extra dummy byte to read */ - if( nread < count && zfx->algo == 1 ) { - *(zfx->inbuf + n) = 0xFF; /* is it really needed ? */ - zfx->algo1hack = 1; + /* Algo 1 has no zlib header which requires us to to give + * inflate an extra dummy byte to read. To be on the safe + * side we allow for up to 4 ff bytes. */ + if( nread < count && zfx->algo == 1 && zfx->algo1hack < 4) { + *(zfx->inbuf + n) = 0xFF; + zfx->algo1hack++; n++; + leave = 1; } zs->avail_in = n; } @@ -205,7 +207,8 @@ do_uncompress( compress_filter_context_t *zfx, z_stream *zs, else log_fatal("zlib inflate problem: rc=%d\n", zrc ); } - } while( zs->avail_out && zrc != Z_STREAM_END && zrc != Z_BUF_ERROR ); + } while (zs->avail_out && zrc != Z_STREAM_END && zrc != Z_BUF_ERROR + && !leave); *ret_len = zfx->outbufsize - zs->avail_out; if( DBG_FILTER )
CWE-20
null
null
8,801
release_context (compress_filter_context_t *ctx) { xfree (ctx); }
DoS
0
release_context (compress_filter_context_t *ctx) { xfree (ctx); }
@@ -161,7 +161,8 @@ do_uncompress( compress_filter_context_t *zfx, z_stream *zs, IOBUF a, size_t *ret_len ) { int zrc; - int rc=0; + int rc = 0; + int leave = 0; size_t n; int nread, count; int refill = !zs->avail_in; @@ -179,13 +180,14 @@ do_uncompress( compress_filter_context_t *zfx, z_stream *zs, nread = iobuf_read( a, zfx->inbuf + n, count ); if( nread == -1 ) nread = 0; n += nread; - /* If we use the undocumented feature to suppress - * the zlib header, we have to give inflate an - * extra dummy byte to read */ - if( nread < count && zfx->algo == 1 ) { - *(zfx->inbuf + n) = 0xFF; /* is it really needed ? */ - zfx->algo1hack = 1; + /* Algo 1 has no zlib header which requires us to to give + * inflate an extra dummy byte to read. To be on the safe + * side we allow for up to 4 ff bytes. */ + if( nread < count && zfx->algo == 1 && zfx->algo1hack < 4) { + *(zfx->inbuf + n) = 0xFF; + zfx->algo1hack++; n++; + leave = 1; } zs->avail_in = n; } @@ -205,7 +207,8 @@ do_uncompress( compress_filter_context_t *zfx, z_stream *zs, else log_fatal("zlib inflate problem: rc=%d\n", zrc ); } - } while( zs->avail_out && zrc != Z_STREAM_END && zrc != Z_BUF_ERROR ); + } while (zs->avail_out && zrc != Z_STREAM_END && zrc != Z_BUF_ERROR + && !leave); *ret_len = zfx->outbufsize - zs->avail_out; if( DBG_FILTER )
CWE-20
null
null
8,802
static NTSTATUS check_guest_password(auth_serversupplied_info **server_info) { struct auth_context *auth_context; auth_usersupplied_info *user_info = NULL; NTSTATUS nt_status; unsigned char chal[8]; ZERO_STRUCT(chal); DEBUG(3,("Got anonymous request\n")); if (!NT_STATUS_IS_OK(nt_status = make_auth_context_fixed(&auth_context, chal))) { return nt_status; } if (!make_user_info_guest(&user_info)) { (auth_context->free)(&auth_context); return NT_STATUS_NO_MEMORY; } nt_status = auth_context->check_ntlm_password(auth_context, user_info, server_info); (auth_context->free)(&auth_context); free_user_info(&user_info); return nt_status; }
DoS Overflow
0
static NTSTATUS check_guest_password(auth_serversupplied_info **server_info) { struct auth_context *auth_context; auth_usersupplied_info *user_info = NULL; NTSTATUS nt_status; unsigned char chal[8]; ZERO_STRUCT(chal); DEBUG(3,("Got anonymous request\n")); if (!NT_STATUS_IS_OK(nt_status = make_auth_context_fixed(&auth_context, chal))) { return nt_status; } if (!make_user_info_guest(&user_info)) { (auth_context->free)(&auth_context); return NT_STATUS_NO_MEMORY; } nt_status = auth_context->check_ntlm_password(auth_context, user_info, server_info); (auth_context->free)(&auth_context); free_user_info(&user_info); return nt_status; }
@@ -1213,7 +1213,7 @@ static void reply_sesssetup_and_X_spnego(struct smb_request *req) file_save("negotiate.dat", blob1.data, blob1.length); #endif - p2 = (char *)req->buf + data_blob_len; + p2 = (char *)req->buf + blob1.length; p2 += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p2, STR_TERMINATE);
CWE-119
null
null
8,803
static NTSTATUS check_spnego_blob_complete(struct smbd_server_connection *sconn, uint16 smbpid, uint16 vuid, DATA_BLOB *pblob) { struct pending_auth_data *pad = NULL; ASN1_DATA *data; size_t needed_len = 0; pad = get_pending_auth_data(sconn, smbpid); /* Ensure we have some data. */ if (pblob->length == 0) { /* Caller can cope. */ DEBUG(2,("check_spnego_blob_complete: zero blob length !\n")); delete_partial_auth(sconn, pad); return NT_STATUS_OK; } /* Were we waiting for more data ? */ if (pad) { DATA_BLOB tmp_blob; size_t copy_len = MIN(65536, pblob->length); /* Integer wrap paranoia.... */ if (pad->partial_data.length + copy_len < pad->partial_data.length || pad->partial_data.length + copy_len < copy_len) { DEBUG(2,("check_spnego_blob_complete: integer wrap " "pad->partial_data.length = %u, " "copy_len = %u\n", (unsigned int)pad->partial_data.length, (unsigned int)copy_len )); delete_partial_auth(sconn, pad); return NT_STATUS_INVALID_PARAMETER; } DEBUG(10,("check_spnego_blob_complete: " "pad->partial_data.length = %u, " "pad->needed_len = %u, " "copy_len = %u, " "pblob->length = %u,\n", (unsigned int)pad->partial_data.length, (unsigned int)pad->needed_len, (unsigned int)copy_len, (unsigned int)pblob->length )); tmp_blob = data_blob(NULL, pad->partial_data.length + copy_len); /* Concatenate the two (up to copy_len) bytes. */ memcpy(tmp_blob.data, pad->partial_data.data, pad->partial_data.length); memcpy(tmp_blob.data + pad->partial_data.length, pblob->data, copy_len); /* Replace the partial data. */ data_blob_free(&pad->partial_data); pad->partial_data = tmp_blob; ZERO_STRUCT(tmp_blob); /* Are we done ? */ if (pblob->length >= pad->needed_len) { /* Yes, replace pblob. */ data_blob_free(pblob); *pblob = pad->partial_data; ZERO_STRUCT(pad->partial_data); delete_partial_auth(sconn, pad); return NT_STATUS_OK; } /* Still need more data. */ pad->needed_len -= copy_len; return NT_STATUS_MORE_PROCESSING_REQUIRED; } if ((pblob->data[0] != ASN1_APPLICATION(0)) && (pblob->data[0] != ASN1_CONTEXT(1))) { /* Not something we can determine the * length of. */ return NT_STATUS_OK; } /* This is a new SPNEGO sessionsetup - see if * the data given in this blob is enough. */ data = asn1_init(NULL); if (data == NULL) { return NT_STATUS_NO_MEMORY; } asn1_load(data, *pblob); asn1_start_tag(data, pblob->data[0]); if (data->has_error || data->nesting == NULL) { asn1_free(data); /* Let caller catch. */ return NT_STATUS_OK; } /* Integer wrap paranoia.... */ if (data->nesting->taglen + data->nesting->start < data->nesting->taglen || data->nesting->taglen + data->nesting->start < data->nesting->start) { DEBUG(2,("check_spnego_blob_complete: integer wrap " "data.nesting->taglen = %u, " "data.nesting->start = %u\n", (unsigned int)data->nesting->taglen, (unsigned int)data->nesting->start )); asn1_free(data); return NT_STATUS_INVALID_PARAMETER; } /* Total length of the needed asn1 is the tag length * plus the current offset. */ needed_len = data->nesting->taglen + data->nesting->start; asn1_free(data); DEBUG(10,("check_spnego_blob_complete: needed_len = %u, " "pblob->length = %u\n", (unsigned int)needed_len, (unsigned int)pblob->length )); if (needed_len <= pblob->length) { /* Nothing to do - blob is complete. */ return NT_STATUS_OK; } /* Refuse the blob if it's bigger than 64k. */ if (needed_len > 65536) { DEBUG(2,("check_spnego_blob_complete: needed_len " "too large (%u)\n", (unsigned int)needed_len )); return NT_STATUS_INVALID_PARAMETER; } /* We must store this blob until complete. */ if (!(pad = SMB_MALLOC_P(struct pending_auth_data))) { return NT_STATUS_NO_MEMORY; } pad->needed_len = needed_len - pblob->length; pad->partial_data = data_blob(pblob->data, pblob->length); if (pad->partial_data.data == NULL) { SAFE_FREE(pad); return NT_STATUS_NO_MEMORY; } pad->smbpid = smbpid; pad->vuid = vuid; DLIST_ADD(sconn->smb1.pd_list, pad); return NT_STATUS_MORE_PROCESSING_REQUIRED; }
DoS Overflow
0
static NTSTATUS check_spnego_blob_complete(struct smbd_server_connection *sconn, uint16 smbpid, uint16 vuid, DATA_BLOB *pblob) { struct pending_auth_data *pad = NULL; ASN1_DATA *data; size_t needed_len = 0; pad = get_pending_auth_data(sconn, smbpid); /* Ensure we have some data. */ if (pblob->length == 0) { /* Caller can cope. */ DEBUG(2,("check_spnego_blob_complete: zero blob length !\n")); delete_partial_auth(sconn, pad); return NT_STATUS_OK; } /* Were we waiting for more data ? */ if (pad) { DATA_BLOB tmp_blob; size_t copy_len = MIN(65536, pblob->length); /* Integer wrap paranoia.... */ if (pad->partial_data.length + copy_len < pad->partial_data.length || pad->partial_data.length + copy_len < copy_len) { DEBUG(2,("check_spnego_blob_complete: integer wrap " "pad->partial_data.length = %u, " "copy_len = %u\n", (unsigned int)pad->partial_data.length, (unsigned int)copy_len )); delete_partial_auth(sconn, pad); return NT_STATUS_INVALID_PARAMETER; } DEBUG(10,("check_spnego_blob_complete: " "pad->partial_data.length = %u, " "pad->needed_len = %u, " "copy_len = %u, " "pblob->length = %u,\n", (unsigned int)pad->partial_data.length, (unsigned int)pad->needed_len, (unsigned int)copy_len, (unsigned int)pblob->length )); tmp_blob = data_blob(NULL, pad->partial_data.length + copy_len); /* Concatenate the two (up to copy_len) bytes. */ memcpy(tmp_blob.data, pad->partial_data.data, pad->partial_data.length); memcpy(tmp_blob.data + pad->partial_data.length, pblob->data, copy_len); /* Replace the partial data. */ data_blob_free(&pad->partial_data); pad->partial_data = tmp_blob; ZERO_STRUCT(tmp_blob); /* Are we done ? */ if (pblob->length >= pad->needed_len) { /* Yes, replace pblob. */ data_blob_free(pblob); *pblob = pad->partial_data; ZERO_STRUCT(pad->partial_data); delete_partial_auth(sconn, pad); return NT_STATUS_OK; } /* Still need more data. */ pad->needed_len -= copy_len; return NT_STATUS_MORE_PROCESSING_REQUIRED; } if ((pblob->data[0] != ASN1_APPLICATION(0)) && (pblob->data[0] != ASN1_CONTEXT(1))) { /* Not something we can determine the * length of. */ return NT_STATUS_OK; } /* This is a new SPNEGO sessionsetup - see if * the data given in this blob is enough. */ data = asn1_init(NULL); if (data == NULL) { return NT_STATUS_NO_MEMORY; } asn1_load(data, *pblob); asn1_start_tag(data, pblob->data[0]); if (data->has_error || data->nesting == NULL) { asn1_free(data); /* Let caller catch. */ return NT_STATUS_OK; } /* Integer wrap paranoia.... */ if (data->nesting->taglen + data->nesting->start < data->nesting->taglen || data->nesting->taglen + data->nesting->start < data->nesting->start) { DEBUG(2,("check_spnego_blob_complete: integer wrap " "data.nesting->taglen = %u, " "data.nesting->start = %u\n", (unsigned int)data->nesting->taglen, (unsigned int)data->nesting->start )); asn1_free(data); return NT_STATUS_INVALID_PARAMETER; } /* Total length of the needed asn1 is the tag length * plus the current offset. */ needed_len = data->nesting->taglen + data->nesting->start; asn1_free(data); DEBUG(10,("check_spnego_blob_complete: needed_len = %u, " "pblob->length = %u\n", (unsigned int)needed_len, (unsigned int)pblob->length )); if (needed_len <= pblob->length) { /* Nothing to do - blob is complete. */ return NT_STATUS_OK; } /* Refuse the blob if it's bigger than 64k. */ if (needed_len > 65536) { DEBUG(2,("check_spnego_blob_complete: needed_len " "too large (%u)\n", (unsigned int)needed_len )); return NT_STATUS_INVALID_PARAMETER; } /* We must store this blob until complete. */ if (!(pad = SMB_MALLOC_P(struct pending_auth_data))) { return NT_STATUS_NO_MEMORY; } pad->needed_len = needed_len - pblob->length; pad->partial_data = data_blob(pblob->data, pblob->length); if (pad->partial_data.data == NULL) { SAFE_FREE(pad); return NT_STATUS_NO_MEMORY; } pad->smbpid = smbpid; pad->vuid = vuid; DLIST_ADD(sconn->smb1.pd_list, pad); return NT_STATUS_MORE_PROCESSING_REQUIRED; }
@@ -1213,7 +1213,7 @@ static void reply_sesssetup_and_X_spnego(struct smb_request *req) file_save("negotiate.dat", blob1.data, blob1.length); #endif - p2 = (char *)req->buf + data_blob_len; + p2 = (char *)req->buf + blob1.length; p2 += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p2, STR_TERMINATE);
CWE-119
null
null
8,804
static void delete_partial_auth(struct smbd_server_connection *sconn, struct pending_auth_data *pad) { if (!pad) { return; } DLIST_REMOVE(sconn->smb1.pd_list, pad); data_blob_free(&pad->partial_data); SAFE_FREE(pad); }
DoS Overflow
0
static void delete_partial_auth(struct smbd_server_connection *sconn, struct pending_auth_data *pad) { if (!pad) { return; } DLIST_REMOVE(sconn->smb1.pd_list, pad); data_blob_free(&pad->partial_data); SAFE_FREE(pad); }
@@ -1213,7 +1213,7 @@ static void reply_sesssetup_and_X_spnego(struct smb_request *req) file_save("negotiate.dat", blob1.data, blob1.length); #endif - p2 = (char *)req->buf + data_blob_len; + p2 = (char *)req->buf + blob1.length; p2 += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p2, STR_TERMINATE);
CWE-119
null
null
8,805
static struct pending_auth_data *get_pending_auth_data( struct smbd_server_connection *sconn, uint16_t smbpid) { struct pending_auth_data *pad; /* * NOTE: using the smbpid here is completely wrong... * see [MS-SMB] * 3.3.5.3 Receiving an SMB_COM_SESSION_SETUP_ANDX Request */ for (pad = sconn->smb1.pd_list; pad; pad = pad->next) { if (pad->smbpid == smbpid) { break; } } return pad; }
DoS Overflow
0
static struct pending_auth_data *get_pending_auth_data( struct smbd_server_connection *sconn, uint16_t smbpid) { struct pending_auth_data *pad; /* * NOTE: using the smbpid here is completely wrong... * see [MS-SMB] * 3.3.5.3 Receiving an SMB_COM_SESSION_SETUP_ANDX Request */ for (pad = sconn->smb1.pd_list; pad; pad = pad->next) { if (pad->smbpid == smbpid) { break; } } return pad; }
@@ -1213,7 +1213,7 @@ static void reply_sesssetup_and_X_spnego(struct smb_request *req) file_save("negotiate.dat", blob1.data, blob1.length); #endif - p2 = (char *)req->buf + data_blob_len; + p2 = (char *)req->buf + blob1.length; p2 += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p2, STR_TERMINATE);
CWE-119
null
null
8,806
NTSTATUS parse_spnego_mechanisms(DATA_BLOB blob_in, DATA_BLOB *pblob_out, char **kerb_mechOID) { char *OIDs[ASN1_MAX_OIDS]; int i; NTSTATUS ret = NT_STATUS_OK; *kerb_mechOID = NULL; /* parse out the OIDs and the first sec blob */ if (!parse_negTokenTarg(blob_in, OIDs, pblob_out)) { return NT_STATUS_LOGON_FAILURE; } /* only look at the first OID for determining the mechToken -- according to RFC2478, we should choose the one we want and renegotiate, but i smell a client bug here.. Problem observed when connecting to a member (samba box) of an AD domain as a user in a Samba domain. Samba member server sent back krb5/mskrb5/ntlmssp as mechtypes, but the client (2ksp3) replied with ntlmssp/mskrb5/krb5 and an NTLMSSP mechtoken. --jerry */ #ifdef HAVE_KRB5 if (strcmp(OID_KERBEROS5, OIDs[0]) == 0 || strcmp(OID_KERBEROS5_OLD, OIDs[0]) == 0) { *kerb_mechOID = SMB_STRDUP(OIDs[0]); if (*kerb_mechOID == NULL) { ret = NT_STATUS_NO_MEMORY; } } #endif for (i=0;OIDs[i];i++) { DEBUG(5,("parse_spnego_mechanisms: Got OID %s\n", OIDs[i])); talloc_free(OIDs[i]); } return ret; }
DoS Overflow
0
NTSTATUS parse_spnego_mechanisms(DATA_BLOB blob_in, DATA_BLOB *pblob_out, char **kerb_mechOID) { char *OIDs[ASN1_MAX_OIDS]; int i; NTSTATUS ret = NT_STATUS_OK; *kerb_mechOID = NULL; /* parse out the OIDs and the first sec blob */ if (!parse_negTokenTarg(blob_in, OIDs, pblob_out)) { return NT_STATUS_LOGON_FAILURE; } /* only look at the first OID for determining the mechToken -- according to RFC2478, we should choose the one we want and renegotiate, but i smell a client bug here.. Problem observed when connecting to a member (samba box) of an AD domain as a user in a Samba domain. Samba member server sent back krb5/mskrb5/ntlmssp as mechtypes, but the client (2ksp3) replied with ntlmssp/mskrb5/krb5 and an NTLMSSP mechtoken. --jerry */ #ifdef HAVE_KRB5 if (strcmp(OID_KERBEROS5, OIDs[0]) == 0 || strcmp(OID_KERBEROS5_OLD, OIDs[0]) == 0) { *kerb_mechOID = SMB_STRDUP(OIDs[0]); if (*kerb_mechOID == NULL) { ret = NT_STATUS_NO_MEMORY; } } #endif for (i=0;OIDs[i];i++) { DEBUG(5,("parse_spnego_mechanisms: Got OID %s\n", OIDs[i])); talloc_free(OIDs[i]); } return ret; }
@@ -1213,7 +1213,7 @@ static void reply_sesssetup_and_X_spnego(struct smb_request *req) file_save("negotiate.dat", blob1.data, blob1.length); #endif - p2 = (char *)req->buf + data_blob_len; + p2 = (char *)req->buf + blob1.length; p2 += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p2, STR_TERMINATE);
CWE-119
null
null
8,807
static int push_signature(uint8 **outbuf) { char *lanman; int result, tmp; result = 0; tmp = message_push_string(outbuf, "Unix", STR_TERMINATE); if (tmp == -1) return -1; result += tmp; if (asprintf(&lanman, "Samba %s", samba_version_string()) != -1) { tmp = message_push_string(outbuf, lanman, STR_TERMINATE); SAFE_FREE(lanman); } else { tmp = message_push_string(outbuf, "Samba", STR_TERMINATE); } if (tmp == -1) return -1; result += tmp; tmp = message_push_string(outbuf, lp_workgroup(), STR_TERMINATE); if (tmp == -1) return -1; result += tmp; return result; }
DoS Overflow
0
static int push_signature(uint8 **outbuf) { char *lanman; int result, tmp; result = 0; tmp = message_push_string(outbuf, "Unix", STR_TERMINATE); if (tmp == -1) return -1; result += tmp; if (asprintf(&lanman, "Samba %s", samba_version_string()) != -1) { tmp = message_push_string(outbuf, lanman, STR_TERMINATE); SAFE_FREE(lanman); } else { tmp = message_push_string(outbuf, "Samba", STR_TERMINATE); } if (tmp == -1) return -1; result += tmp; tmp = message_push_string(outbuf, lp_workgroup(), STR_TERMINATE); if (tmp == -1) return -1; result += tmp; return result; }
@@ -1213,7 +1213,7 @@ static void reply_sesssetup_and_X_spnego(struct smb_request *req) file_save("negotiate.dat", blob1.data, blob1.length); #endif - p2 = (char *)req->buf + data_blob_len; + p2 = (char *)req->buf + blob1.length; p2 += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p2, STR_TERMINATE);
CWE-119
null
null
8,808
void reply_sesssetup_and_X(struct smb_request *req) { int sess_vuid; int smb_bufsize; DATA_BLOB lm_resp; DATA_BLOB nt_resp; DATA_BLOB plaintext_password; char *tmp; const char *user; fstring sub_user; /* Sainitised username for substituion */ const char *domain; const char *native_os; const char *native_lanman; const char *primary_domain; auth_usersupplied_info *user_info = NULL; auth_serversupplied_info *server_info = NULL; uint16 smb_flag2 = req->flags2; NTSTATUS nt_status; struct smbd_server_connection *sconn = smbd_server_conn; bool doencrypt = sconn->smb1.negprot.encrypted_passwords; START_PROFILE(SMBsesssetupX); ZERO_STRUCT(lm_resp); ZERO_STRUCT(nt_resp); ZERO_STRUCT(plaintext_password); DEBUG(3,("wct=%d flg2=0x%x\n", req->wct, req->flags2)); /* a SPNEGO session setup has 12 command words, whereas a normal NT1 session setup has 13. See the cifs spec. */ if (req->wct == 12 && (req->flags2 & FLAGS2_EXTENDED_SECURITY)) { if (!sconn->smb1.negprot.spnego) { DEBUG(0,("reply_sesssetup_and_X: Rejecting attempt " "at SPNEGO session setup when it was not " "negotiated.\n")); reply_nterror(req, nt_status_squash( NT_STATUS_LOGON_FAILURE)); END_PROFILE(SMBsesssetupX); return; } if (SVAL(req->vwv+4, 0) == 0) { setup_new_vc_session(); } reply_sesssetup_and_X_spnego(req); END_PROFILE(SMBsesssetupX); return; } smb_bufsize = SVAL(req->vwv+2, 0); if (get_Protocol() < PROTOCOL_NT1) { uint16 passlen1 = SVAL(req->vwv+7, 0); /* Never do NT status codes with protocols before NT1 as we * don't get client caps. */ remove_from_common_flags2(FLAGS2_32_BIT_ERROR_CODES); if ((passlen1 > MAX_PASS_LEN) || (passlen1 > req->buflen)) { reply_nterror(req, nt_status_squash( NT_STATUS_INVALID_PARAMETER)); END_PROFILE(SMBsesssetupX); return; } if (doencrypt) { lm_resp = data_blob(req->buf, passlen1); } else { plaintext_password = data_blob(req->buf, passlen1+1); /* Ensure null termination */ plaintext_password.data[passlen1] = 0; } srvstr_pull_req_talloc(talloc_tos(), req, &tmp, req->buf + passlen1, STR_TERMINATE); user = tmp ? tmp : ""; domain = ""; } else { uint16 passlen1 = SVAL(req->vwv+7, 0); uint16 passlen2 = SVAL(req->vwv+8, 0); enum remote_arch_types ra_type = get_remote_arch(); const uint8_t *p = req->buf; const uint8_t *save_p = req->buf; uint16 byte_count; if(global_client_caps == 0) { global_client_caps = IVAL(req->vwv+11, 0); if (!(global_client_caps & CAP_STATUS32)) { remove_from_common_flags2( FLAGS2_32_BIT_ERROR_CODES); } /* client_caps is used as final determination if * client is NT or Win95. This is needed to return * the correct error codes in some circumstances. */ if(ra_type == RA_WINNT || ra_type == RA_WIN2K || ra_type == RA_WIN95) { if(!(global_client_caps & (CAP_NT_SMBS| CAP_STATUS32))) { set_remote_arch( RA_WIN95); } } } if (!doencrypt) { /* both Win95 and WinNT stuff up the password * lengths for non-encrypting systems. Uggh. if passlen1==24 its a win95 system, and its setting the password length incorrectly. Luckily it still works with the default code because Win95 will null terminate the password anyway if passlen1>0 and passlen2>0 then maybe its a NT box and its setting passlen2 to some random value which really stuffs things up. we need to fix that one. */ if (passlen1 > 0 && passlen2 > 0 && passlen2 != 24 && passlen2 != 1) { passlen2 = 0; } } /* check for nasty tricks */ if (passlen1 > MAX_PASS_LEN || passlen1 > smbreq_bufrem(req, p)) { reply_nterror(req, nt_status_squash( NT_STATUS_INVALID_PARAMETER)); END_PROFILE(SMBsesssetupX); return; } if (passlen2 > MAX_PASS_LEN || passlen2 > smbreq_bufrem(req, p+passlen1)) { reply_nterror(req, nt_status_squash( NT_STATUS_INVALID_PARAMETER)); END_PROFILE(SMBsesssetupX); return; } /* Save the lanman2 password and the NT md4 password. */ if ((doencrypt) && (passlen1 != 0) && (passlen1 != 24)) { doencrypt = False; } if (doencrypt) { lm_resp = data_blob(p, passlen1); nt_resp = data_blob(p+passlen1, passlen2); } else if (lp_security() != SEC_SHARE) { /* * In share level we should ignore any passwords, so * only read them if we're not. */ char *pass = NULL; bool unic= smb_flag2 & FLAGS2_UNICODE_STRINGS; if (unic && (passlen2 == 0) && passlen1) { /* Only a ascii plaintext password was sent. */ (void)srvstr_pull_talloc(talloc_tos(), req->inbuf, req->flags2, &pass, req->buf, passlen1, STR_TERMINATE|STR_ASCII); } else { (void)srvstr_pull_talloc(talloc_tos(), req->inbuf, req->flags2, &pass, req->buf, unic ? passlen2 : passlen1, STR_TERMINATE); } if (!pass) { reply_nterror(req, nt_status_squash( NT_STATUS_INVALID_PARAMETER)); END_PROFILE(SMBsesssetupX); return; } plaintext_password = data_blob(pass, strlen(pass)+1); } p += passlen1 + passlen2; p += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p, STR_TERMINATE); user = tmp ? tmp : ""; p += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p, STR_TERMINATE); domain = tmp ? tmp : ""; p += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p, STR_TERMINATE); native_os = tmp ? tmp : ""; p += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p, STR_TERMINATE); native_lanman = tmp ? tmp : ""; /* not documented or decoded by Ethereal but there is one more * string in the extra bytes which is the same as the * PrimaryDomain when using extended security. Windows NT 4 * and 2003 use this string to store the native lanman string. * Windows 9x does not include a string here at all so we have * to check if we have any extra bytes left */ byte_count = SVAL(req->vwv+13, 0); if ( PTR_DIFF(p, save_p) < byte_count) { p += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p, STR_TERMINATE); primary_domain = tmp ? tmp : ""; } else { primary_domain = talloc_strdup(talloc_tos(), "null"); } DEBUG(3,("Domain=[%s] NativeOS=[%s] NativeLanMan=[%s] " "PrimaryDomain=[%s]\n", domain, native_os, native_lanman, primary_domain)); if ( ra_type == RA_WIN2K ) { if ( strlen(native_lanman) == 0 ) ra_lanman_string( primary_domain ); else ra_lanman_string( native_lanman ); } } if (SVAL(req->vwv+4, 0) == 0) { setup_new_vc_session(); } DEBUG(3,("sesssetupX:name=[%s]\\[%s]@[%s]\n", domain, user, get_remote_machine_name())); if (*user) { if (sconn->smb1.negprot.spnego) { /* This has to be here, because this is a perfectly * valid behaviour for guest logons :-( */ DEBUG(0,("reply_sesssetup_and_X: Rejecting attempt " "at 'normal' session setup after " "negotiating spnego.\n")); reply_nterror(req, nt_status_squash( NT_STATUS_LOGON_FAILURE)); END_PROFILE(SMBsesssetupX); return; } fstrcpy(sub_user, user); } else { fstrcpy(sub_user, lp_guestaccount()); } sub_set_smb_name(sub_user); reload_services(True); if (lp_security() == SEC_SHARE) { /* In share level we should ignore any passwords */ data_blob_free(&lm_resp); data_blob_free(&nt_resp); data_blob_clear_free(&plaintext_password); map_username(sconn, sub_user); add_session_user(sconn, sub_user); add_session_workgroup(sconn, domain); /* Then force it to null for the benfit of the code below */ user = ""; } if (!*user) { nt_status = check_guest_password(&server_info); } else if (doencrypt) { struct auth_context *negprot_auth_context = NULL; negprot_auth_context = sconn->smb1.negprot.auth_context; if (!negprot_auth_context) { DEBUG(0, ("reply_sesssetup_and_X: Attempted encrypted " "session setup without negprot denied!\n")); reply_nterror(req, nt_status_squash( NT_STATUS_LOGON_FAILURE)); END_PROFILE(SMBsesssetupX); return; } nt_status = make_user_info_for_reply_enc(&user_info, user, domain, lm_resp, nt_resp); if (NT_STATUS_IS_OK(nt_status)) { nt_status = negprot_auth_context->check_ntlm_password( negprot_auth_context, user_info, &server_info); } } else { struct auth_context *plaintext_auth_context = NULL; nt_status = make_auth_context_subsystem( &plaintext_auth_context); if (NT_STATUS_IS_OK(nt_status)) { uint8_t chal[8]; plaintext_auth_context->get_ntlm_challenge( plaintext_auth_context, chal); if (!make_user_info_for_reply(&user_info, user, domain, chal, plaintext_password)) { nt_status = NT_STATUS_NO_MEMORY; } if (NT_STATUS_IS_OK(nt_status)) { nt_status = plaintext_auth_context->check_ntlm_password( plaintext_auth_context, user_info, &server_info); (plaintext_auth_context->free)( &plaintext_auth_context); } } } free_user_info(&user_info); if (!NT_STATUS_IS_OK(nt_status)) { nt_status = do_map_to_guest(nt_status, &server_info, user, domain); } if (!NT_STATUS_IS_OK(nt_status)) { data_blob_free(&nt_resp); data_blob_free(&lm_resp); data_blob_clear_free(&plaintext_password); reply_nterror(req, nt_status_squash(nt_status)); END_PROFILE(SMBsesssetupX); return; } /* Ensure we can't possible take a code path leading to a * null defref. */ if (!server_info) { reply_nterror(req, nt_status_squash(NT_STATUS_LOGON_FAILURE)); END_PROFILE(SMBsesssetupX); return; } if (!server_info->ptok) { nt_status = create_local_token(server_info); if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(10, ("create_local_token failed: %s\n", nt_errstr(nt_status))); data_blob_free(&nt_resp); data_blob_free(&lm_resp); data_blob_clear_free(&plaintext_password); reply_nterror(req, nt_status_squash(nt_status)); END_PROFILE(SMBsesssetupX); return; } } data_blob_clear_free(&plaintext_password); /* it's ok - setup a reply */ reply_outbuf(req, 3, 0); if (get_Protocol() >= PROTOCOL_NT1) { push_signature(&req->outbuf); /* perhaps grab OS version here?? */ } if (server_info->guest) { SSVAL(req->outbuf,smb_vwv2,1); } /* register the name and uid as being validated, so further connections to a uid can get through without a password, on the same VC */ if (lp_security() == SEC_SHARE) { sess_vuid = UID_FIELD_INVALID; TALLOC_FREE(server_info); } else { /* Ignore the initial vuid. */ sess_vuid = register_initial_vuid(sconn); if (sess_vuid == UID_FIELD_INVALID) { data_blob_free(&nt_resp); data_blob_free(&lm_resp); reply_nterror(req, nt_status_squash( NT_STATUS_LOGON_FAILURE)); END_PROFILE(SMBsesssetupX); return; } /* register_existing_vuid keeps the server info */ sess_vuid = register_existing_vuid(sconn, sess_vuid, server_info, nt_resp.data ? nt_resp : lm_resp, sub_user); if (sess_vuid == UID_FIELD_INVALID) { data_blob_free(&nt_resp); data_blob_free(&lm_resp); reply_nterror(req, nt_status_squash( NT_STATUS_LOGON_FAILURE)); END_PROFILE(SMBsesssetupX); return; } /* current_user_info is changed on new vuid */ reload_services( True ); } data_blob_free(&nt_resp); data_blob_free(&lm_resp); SSVAL(req->outbuf,smb_uid,sess_vuid); SSVAL(req->inbuf,smb_uid,sess_vuid); req->vuid = sess_vuid; if (!sconn->smb1.sessions.done_sesssetup) { sconn->smb1.sessions.max_send = MIN(sconn->smb1.sessions.max_send,smb_bufsize); } sconn->smb1.sessions.done_sesssetup = true; END_PROFILE(SMBsesssetupX); chain_reply(req); return; }
DoS Overflow
0
void reply_sesssetup_and_X(struct smb_request *req) { int sess_vuid; int smb_bufsize; DATA_BLOB lm_resp; DATA_BLOB nt_resp; DATA_BLOB plaintext_password; char *tmp; const char *user; fstring sub_user; /* Sainitised username for substituion */ const char *domain; const char *native_os; const char *native_lanman; const char *primary_domain; auth_usersupplied_info *user_info = NULL; auth_serversupplied_info *server_info = NULL; uint16 smb_flag2 = req->flags2; NTSTATUS nt_status; struct smbd_server_connection *sconn = smbd_server_conn; bool doencrypt = sconn->smb1.negprot.encrypted_passwords; START_PROFILE(SMBsesssetupX); ZERO_STRUCT(lm_resp); ZERO_STRUCT(nt_resp); ZERO_STRUCT(plaintext_password); DEBUG(3,("wct=%d flg2=0x%x\n", req->wct, req->flags2)); /* a SPNEGO session setup has 12 command words, whereas a normal NT1 session setup has 13. See the cifs spec. */ if (req->wct == 12 && (req->flags2 & FLAGS2_EXTENDED_SECURITY)) { if (!sconn->smb1.negprot.spnego) { DEBUG(0,("reply_sesssetup_and_X: Rejecting attempt " "at SPNEGO session setup when it was not " "negotiated.\n")); reply_nterror(req, nt_status_squash( NT_STATUS_LOGON_FAILURE)); END_PROFILE(SMBsesssetupX); return; } if (SVAL(req->vwv+4, 0) == 0) { setup_new_vc_session(); } reply_sesssetup_and_X_spnego(req); END_PROFILE(SMBsesssetupX); return; } smb_bufsize = SVAL(req->vwv+2, 0); if (get_Protocol() < PROTOCOL_NT1) { uint16 passlen1 = SVAL(req->vwv+7, 0); /* Never do NT status codes with protocols before NT1 as we * don't get client caps. */ remove_from_common_flags2(FLAGS2_32_BIT_ERROR_CODES); if ((passlen1 > MAX_PASS_LEN) || (passlen1 > req->buflen)) { reply_nterror(req, nt_status_squash( NT_STATUS_INVALID_PARAMETER)); END_PROFILE(SMBsesssetupX); return; } if (doencrypt) { lm_resp = data_blob(req->buf, passlen1); } else { plaintext_password = data_blob(req->buf, passlen1+1); /* Ensure null termination */ plaintext_password.data[passlen1] = 0; } srvstr_pull_req_talloc(talloc_tos(), req, &tmp, req->buf + passlen1, STR_TERMINATE); user = tmp ? tmp : ""; domain = ""; } else { uint16 passlen1 = SVAL(req->vwv+7, 0); uint16 passlen2 = SVAL(req->vwv+8, 0); enum remote_arch_types ra_type = get_remote_arch(); const uint8_t *p = req->buf; const uint8_t *save_p = req->buf; uint16 byte_count; if(global_client_caps == 0) { global_client_caps = IVAL(req->vwv+11, 0); if (!(global_client_caps & CAP_STATUS32)) { remove_from_common_flags2( FLAGS2_32_BIT_ERROR_CODES); } /* client_caps is used as final determination if * client is NT or Win95. This is needed to return * the correct error codes in some circumstances. */ if(ra_type == RA_WINNT || ra_type == RA_WIN2K || ra_type == RA_WIN95) { if(!(global_client_caps & (CAP_NT_SMBS| CAP_STATUS32))) { set_remote_arch( RA_WIN95); } } } if (!doencrypt) { /* both Win95 and WinNT stuff up the password * lengths for non-encrypting systems. Uggh. if passlen1==24 its a win95 system, and its setting the password length incorrectly. Luckily it still works with the default code because Win95 will null terminate the password anyway if passlen1>0 and passlen2>0 then maybe its a NT box and its setting passlen2 to some random value which really stuffs things up. we need to fix that one. */ if (passlen1 > 0 && passlen2 > 0 && passlen2 != 24 && passlen2 != 1) { passlen2 = 0; } } /* check for nasty tricks */ if (passlen1 > MAX_PASS_LEN || passlen1 > smbreq_bufrem(req, p)) { reply_nterror(req, nt_status_squash( NT_STATUS_INVALID_PARAMETER)); END_PROFILE(SMBsesssetupX); return; } if (passlen2 > MAX_PASS_LEN || passlen2 > smbreq_bufrem(req, p+passlen1)) { reply_nterror(req, nt_status_squash( NT_STATUS_INVALID_PARAMETER)); END_PROFILE(SMBsesssetupX); return; } /* Save the lanman2 password and the NT md4 password. */ if ((doencrypt) && (passlen1 != 0) && (passlen1 != 24)) { doencrypt = False; } if (doencrypt) { lm_resp = data_blob(p, passlen1); nt_resp = data_blob(p+passlen1, passlen2); } else if (lp_security() != SEC_SHARE) { /* * In share level we should ignore any passwords, so * only read them if we're not. */ char *pass = NULL; bool unic= smb_flag2 & FLAGS2_UNICODE_STRINGS; if (unic && (passlen2 == 0) && passlen1) { /* Only a ascii plaintext password was sent. */ (void)srvstr_pull_talloc(talloc_tos(), req->inbuf, req->flags2, &pass, req->buf, passlen1, STR_TERMINATE|STR_ASCII); } else { (void)srvstr_pull_talloc(talloc_tos(), req->inbuf, req->flags2, &pass, req->buf, unic ? passlen2 : passlen1, STR_TERMINATE); } if (!pass) { reply_nterror(req, nt_status_squash( NT_STATUS_INVALID_PARAMETER)); END_PROFILE(SMBsesssetupX); return; } plaintext_password = data_blob(pass, strlen(pass)+1); } p += passlen1 + passlen2; p += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p, STR_TERMINATE); user = tmp ? tmp : ""; p += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p, STR_TERMINATE); domain = tmp ? tmp : ""; p += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p, STR_TERMINATE); native_os = tmp ? tmp : ""; p += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p, STR_TERMINATE); native_lanman = tmp ? tmp : ""; /* not documented or decoded by Ethereal but there is one more * string in the extra bytes which is the same as the * PrimaryDomain when using extended security. Windows NT 4 * and 2003 use this string to store the native lanman string. * Windows 9x does not include a string here at all so we have * to check if we have any extra bytes left */ byte_count = SVAL(req->vwv+13, 0); if ( PTR_DIFF(p, save_p) < byte_count) { p += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p, STR_TERMINATE); primary_domain = tmp ? tmp : ""; } else { primary_domain = talloc_strdup(talloc_tos(), "null"); } DEBUG(3,("Domain=[%s] NativeOS=[%s] NativeLanMan=[%s] " "PrimaryDomain=[%s]\n", domain, native_os, native_lanman, primary_domain)); if ( ra_type == RA_WIN2K ) { if ( strlen(native_lanman) == 0 ) ra_lanman_string( primary_domain ); else ra_lanman_string( native_lanman ); } } if (SVAL(req->vwv+4, 0) == 0) { setup_new_vc_session(); } DEBUG(3,("sesssetupX:name=[%s]\\[%s]@[%s]\n", domain, user, get_remote_machine_name())); if (*user) { if (sconn->smb1.negprot.spnego) { /* This has to be here, because this is a perfectly * valid behaviour for guest logons :-( */ DEBUG(0,("reply_sesssetup_and_X: Rejecting attempt " "at 'normal' session setup after " "negotiating spnego.\n")); reply_nterror(req, nt_status_squash( NT_STATUS_LOGON_FAILURE)); END_PROFILE(SMBsesssetupX); return; } fstrcpy(sub_user, user); } else { fstrcpy(sub_user, lp_guestaccount()); } sub_set_smb_name(sub_user); reload_services(True); if (lp_security() == SEC_SHARE) { /* In share level we should ignore any passwords */ data_blob_free(&lm_resp); data_blob_free(&nt_resp); data_blob_clear_free(&plaintext_password); map_username(sconn, sub_user); add_session_user(sconn, sub_user); add_session_workgroup(sconn, domain); /* Then force it to null for the benfit of the code below */ user = ""; } if (!*user) { nt_status = check_guest_password(&server_info); } else if (doencrypt) { struct auth_context *negprot_auth_context = NULL; negprot_auth_context = sconn->smb1.negprot.auth_context; if (!negprot_auth_context) { DEBUG(0, ("reply_sesssetup_and_X: Attempted encrypted " "session setup without negprot denied!\n")); reply_nterror(req, nt_status_squash( NT_STATUS_LOGON_FAILURE)); END_PROFILE(SMBsesssetupX); return; } nt_status = make_user_info_for_reply_enc(&user_info, user, domain, lm_resp, nt_resp); if (NT_STATUS_IS_OK(nt_status)) { nt_status = negprot_auth_context->check_ntlm_password( negprot_auth_context, user_info, &server_info); } } else { struct auth_context *plaintext_auth_context = NULL; nt_status = make_auth_context_subsystem( &plaintext_auth_context); if (NT_STATUS_IS_OK(nt_status)) { uint8_t chal[8]; plaintext_auth_context->get_ntlm_challenge( plaintext_auth_context, chal); if (!make_user_info_for_reply(&user_info, user, domain, chal, plaintext_password)) { nt_status = NT_STATUS_NO_MEMORY; } if (NT_STATUS_IS_OK(nt_status)) { nt_status = plaintext_auth_context->check_ntlm_password( plaintext_auth_context, user_info, &server_info); (plaintext_auth_context->free)( &plaintext_auth_context); } } } free_user_info(&user_info); if (!NT_STATUS_IS_OK(nt_status)) { nt_status = do_map_to_guest(nt_status, &server_info, user, domain); } if (!NT_STATUS_IS_OK(nt_status)) { data_blob_free(&nt_resp); data_blob_free(&lm_resp); data_blob_clear_free(&plaintext_password); reply_nterror(req, nt_status_squash(nt_status)); END_PROFILE(SMBsesssetupX); return; } /* Ensure we can't possible take a code path leading to a * null defref. */ if (!server_info) { reply_nterror(req, nt_status_squash(NT_STATUS_LOGON_FAILURE)); END_PROFILE(SMBsesssetupX); return; } if (!server_info->ptok) { nt_status = create_local_token(server_info); if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(10, ("create_local_token failed: %s\n", nt_errstr(nt_status))); data_blob_free(&nt_resp); data_blob_free(&lm_resp); data_blob_clear_free(&plaintext_password); reply_nterror(req, nt_status_squash(nt_status)); END_PROFILE(SMBsesssetupX); return; } } data_blob_clear_free(&plaintext_password); /* it's ok - setup a reply */ reply_outbuf(req, 3, 0); if (get_Protocol() >= PROTOCOL_NT1) { push_signature(&req->outbuf); /* perhaps grab OS version here?? */ } if (server_info->guest) { SSVAL(req->outbuf,smb_vwv2,1); } /* register the name and uid as being validated, so further connections to a uid can get through without a password, on the same VC */ if (lp_security() == SEC_SHARE) { sess_vuid = UID_FIELD_INVALID; TALLOC_FREE(server_info); } else { /* Ignore the initial vuid. */ sess_vuid = register_initial_vuid(sconn); if (sess_vuid == UID_FIELD_INVALID) { data_blob_free(&nt_resp); data_blob_free(&lm_resp); reply_nterror(req, nt_status_squash( NT_STATUS_LOGON_FAILURE)); END_PROFILE(SMBsesssetupX); return; } /* register_existing_vuid keeps the server info */ sess_vuid = register_existing_vuid(sconn, sess_vuid, server_info, nt_resp.data ? nt_resp : lm_resp, sub_user); if (sess_vuid == UID_FIELD_INVALID) { data_blob_free(&nt_resp); data_blob_free(&lm_resp); reply_nterror(req, nt_status_squash( NT_STATUS_LOGON_FAILURE)); END_PROFILE(SMBsesssetupX); return; } /* current_user_info is changed on new vuid */ reload_services( True ); } data_blob_free(&nt_resp); data_blob_free(&lm_resp); SSVAL(req->outbuf,smb_uid,sess_vuid); SSVAL(req->inbuf,smb_uid,sess_vuid); req->vuid = sess_vuid; if (!sconn->smb1.sessions.done_sesssetup) { sconn->smb1.sessions.max_send = MIN(sconn->smb1.sessions.max_send,smb_bufsize); } sconn->smb1.sessions.done_sesssetup = true; END_PROFILE(SMBsesssetupX); chain_reply(req); return; }
@@ -1213,7 +1213,7 @@ static void reply_sesssetup_and_X_spnego(struct smb_request *req) file_save("negotiate.dat", blob1.data, blob1.length); #endif - p2 = (char *)req->buf + data_blob_len; + p2 = (char *)req->buf + blob1.length; p2 += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p2, STR_TERMINATE);
CWE-119
null
null
8,809
static void reply_sesssetup_blob(struct smb_request *req, DATA_BLOB blob, NTSTATUS nt_status) { if (!NT_STATUS_IS_OK(nt_status) && !NT_STATUS_EQUAL(nt_status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { reply_nterror(req, nt_status_squash(nt_status)); return; } nt_status = nt_status_squash(nt_status); SIVAL(req->outbuf, smb_rcls, NT_STATUS_V(nt_status)); SSVAL(req->outbuf, smb_vwv0, 0xFF); /* no chaining possible */ SSVAL(req->outbuf, smb_vwv3, blob.length); if ((message_push_blob(&req->outbuf, blob) == -1) || (push_signature(&req->outbuf) == -1)) { reply_nterror(req, NT_STATUS_NO_MEMORY); } }
DoS Overflow
0
static void reply_sesssetup_blob(struct smb_request *req, DATA_BLOB blob, NTSTATUS nt_status) { if (!NT_STATUS_IS_OK(nt_status) && !NT_STATUS_EQUAL(nt_status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { reply_nterror(req, nt_status_squash(nt_status)); return; } nt_status = nt_status_squash(nt_status); SIVAL(req->outbuf, smb_rcls, NT_STATUS_V(nt_status)); SSVAL(req->outbuf, smb_vwv0, 0xFF); /* no chaining possible */ SSVAL(req->outbuf, smb_vwv3, blob.length); if ((message_push_blob(&req->outbuf, blob) == -1) || (push_signature(&req->outbuf) == -1)) { reply_nterror(req, NT_STATUS_NO_MEMORY); } }
@@ -1213,7 +1213,7 @@ static void reply_sesssetup_and_X_spnego(struct smb_request *req) file_save("negotiate.dat", blob1.data, blob1.length); #endif - p2 = (char *)req->buf + data_blob_len; + p2 = (char *)req->buf + blob1.length; p2 += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p2, STR_TERMINATE);
CWE-119
null
null
8,810
static void reply_spnego_auth(struct smb_request *req, uint16 vuid, DATA_BLOB blob1, AUTH_NTLMSSP_STATE **auth_ntlmssp_state) { DATA_BLOB auth = data_blob_null; DATA_BLOB auth_reply = data_blob_null; DATA_BLOB secblob = data_blob_null; NTSTATUS status = NT_STATUS_LOGON_FAILURE; struct smbd_server_connection *sconn = smbd_server_conn; if (!spnego_parse_auth(blob1, &auth)) { #if 0 file_save("auth.dat", blob1.data, blob1.length); #endif /* Kill the intermediate vuid */ invalidate_vuid(sconn, vuid); reply_nterror(req, nt_status_squash( NT_STATUS_LOGON_FAILURE)); return; } if (auth.data[0] == ASN1_APPLICATION(0)) { /* Might be a second negTokenTarg packet */ char *kerb_mech = NULL; status = parse_spnego_mechanisms(auth, &secblob, &kerb_mech); if (!NT_STATUS_IS_OK(status)) { /* Kill the intermediate vuid */ invalidate_vuid(sconn, vuid); reply_nterror(req, nt_status_squash(status)); return; } DEBUG(3,("reply_spnego_auth: Got secblob of size %lu\n", (unsigned long)secblob.length)); #ifdef HAVE_KRB5 if (kerb_mech && ((lp_security()==SEC_ADS) || USE_KERBEROS_KEYTAB)) { bool destroy_vuid = True; reply_spnego_kerberos(req, &secblob, kerb_mech, vuid, &destroy_vuid); data_blob_free(&secblob); data_blob_free(&auth); if (destroy_vuid) { /* Kill the intermediate vuid */ invalidate_vuid(sconn, vuid); } SAFE_FREE(kerb_mech); return; } #endif /* Can't blunder into NTLMSSP auth if we have * a krb5 ticket. */ if (kerb_mech) { /* Kill the intermediate vuid */ invalidate_vuid(sconn, vuid); DEBUG(3,("reply_spnego_auth: network " "misconfiguration, client sent us a " "krb5 ticket and kerberos security " "not enabled\n")); reply_nterror(req, nt_status_squash( NT_STATUS_LOGON_FAILURE)); SAFE_FREE(kerb_mech); } } /* If we get here it wasn't a negTokenTarg auth packet. */ data_blob_free(&secblob); if (!*auth_ntlmssp_state) { status = auth_ntlmssp_start(auth_ntlmssp_state); if (!NT_STATUS_IS_OK(status)) { /* Kill the intermediate vuid */ invalidate_vuid(sconn, vuid); reply_nterror(req, nt_status_squash(status)); return; } } status = auth_ntlmssp_update(*auth_ntlmssp_state, auth, &auth_reply); data_blob_free(&auth); /* Don't send the mechid as we've already sent this (RFC4178). */ reply_spnego_ntlmssp(req, vuid, auth_ntlmssp_state, &auth_reply, status, NULL, true); data_blob_free(&auth_reply); /* and tell smbd that we have already replied to this packet */ return; }
DoS Overflow
0
static void reply_spnego_auth(struct smb_request *req, uint16 vuid, DATA_BLOB blob1, AUTH_NTLMSSP_STATE **auth_ntlmssp_state) { DATA_BLOB auth = data_blob_null; DATA_BLOB auth_reply = data_blob_null; DATA_BLOB secblob = data_blob_null; NTSTATUS status = NT_STATUS_LOGON_FAILURE; struct smbd_server_connection *sconn = smbd_server_conn; if (!spnego_parse_auth(blob1, &auth)) { #if 0 file_save("auth.dat", blob1.data, blob1.length); #endif /* Kill the intermediate vuid */ invalidate_vuid(sconn, vuid); reply_nterror(req, nt_status_squash( NT_STATUS_LOGON_FAILURE)); return; } if (auth.data[0] == ASN1_APPLICATION(0)) { /* Might be a second negTokenTarg packet */ char *kerb_mech = NULL; status = parse_spnego_mechanisms(auth, &secblob, &kerb_mech); if (!NT_STATUS_IS_OK(status)) { /* Kill the intermediate vuid */ invalidate_vuid(sconn, vuid); reply_nterror(req, nt_status_squash(status)); return; } DEBUG(3,("reply_spnego_auth: Got secblob of size %lu\n", (unsigned long)secblob.length)); #ifdef HAVE_KRB5 if (kerb_mech && ((lp_security()==SEC_ADS) || USE_KERBEROS_KEYTAB)) { bool destroy_vuid = True; reply_spnego_kerberos(req, &secblob, kerb_mech, vuid, &destroy_vuid); data_blob_free(&secblob); data_blob_free(&auth); if (destroy_vuid) { /* Kill the intermediate vuid */ invalidate_vuid(sconn, vuid); } SAFE_FREE(kerb_mech); return; } #endif /* Can't blunder into NTLMSSP auth if we have * a krb5 ticket. */ if (kerb_mech) { /* Kill the intermediate vuid */ invalidate_vuid(sconn, vuid); DEBUG(3,("reply_spnego_auth: network " "misconfiguration, client sent us a " "krb5 ticket and kerberos security " "not enabled\n")); reply_nterror(req, nt_status_squash( NT_STATUS_LOGON_FAILURE)); SAFE_FREE(kerb_mech); } } /* If we get here it wasn't a negTokenTarg auth packet. */ data_blob_free(&secblob); if (!*auth_ntlmssp_state) { status = auth_ntlmssp_start(auth_ntlmssp_state); if (!NT_STATUS_IS_OK(status)) { /* Kill the intermediate vuid */ invalidate_vuid(sconn, vuid); reply_nterror(req, nt_status_squash(status)); return; } } status = auth_ntlmssp_update(*auth_ntlmssp_state, auth, &auth_reply); data_blob_free(&auth); /* Don't send the mechid as we've already sent this (RFC4178). */ reply_spnego_ntlmssp(req, vuid, auth_ntlmssp_state, &auth_reply, status, NULL, true); data_blob_free(&auth_reply); /* and tell smbd that we have already replied to this packet */ return; }
@@ -1213,7 +1213,7 @@ static void reply_sesssetup_and_X_spnego(struct smb_request *req) file_save("negotiate.dat", blob1.data, blob1.length); #endif - p2 = (char *)req->buf + data_blob_len; + p2 = (char *)req->buf + blob1.length; p2 += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p2, STR_TERMINATE);
CWE-119
null
null
8,811
static void reply_spnego_downgrade_to_ntlmssp(struct smb_request *req, uint16 vuid) { DATA_BLOB response; reply_outbuf(req, 4, 0); SSVAL(req->outbuf,smb_uid,vuid); DEBUG(3,("reply_spnego_downgrade_to_ntlmssp: Got krb5 ticket in SPNEGO " "but set to downgrade to NTLMSSP\n")); response = spnego_gen_auth_response(NULL, NT_STATUS_MORE_PROCESSING_REQUIRED, OID_NTLMSSP); reply_sesssetup_blob(req, response, NT_STATUS_MORE_PROCESSING_REQUIRED); data_blob_free(&response); }
DoS Overflow
0
static void reply_spnego_downgrade_to_ntlmssp(struct smb_request *req, uint16 vuid) { DATA_BLOB response; reply_outbuf(req, 4, 0); SSVAL(req->outbuf,smb_uid,vuid); DEBUG(3,("reply_spnego_downgrade_to_ntlmssp: Got krb5 ticket in SPNEGO " "but set to downgrade to NTLMSSP\n")); response = spnego_gen_auth_response(NULL, NT_STATUS_MORE_PROCESSING_REQUIRED, OID_NTLMSSP); reply_sesssetup_blob(req, response, NT_STATUS_MORE_PROCESSING_REQUIRED); data_blob_free(&response); }
@@ -1213,7 +1213,7 @@ static void reply_sesssetup_and_X_spnego(struct smb_request *req) file_save("negotiate.dat", blob1.data, blob1.length); #endif - p2 = (char *)req->buf + data_blob_len; + p2 = (char *)req->buf + blob1.length; p2 += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p2, STR_TERMINATE);
CWE-119
null
null
8,812
static void reply_spnego_kerberos(struct smb_request *req, DATA_BLOB *secblob, const char *mechOID, uint16 vuid, bool *p_invalidate_vuid) { TALLOC_CTX *mem_ctx; DATA_BLOB ticket; char *client, *p, *domain; fstring netbios_domain_name; struct passwd *pw; fstring user; int sess_vuid = req->vuid; NTSTATUS ret = NT_STATUS_OK; struct PAC_DATA *pac_data = NULL; DATA_BLOB ap_rep, ap_rep_wrapped, response; auth_serversupplied_info *server_info = NULL; DATA_BLOB session_key = data_blob_null; uint8 tok_id[2]; DATA_BLOB nullblob = data_blob_null; fstring real_username; bool map_domainuser_to_guest = False; bool username_was_mapped; struct PAC_LOGON_INFO *logon_info = NULL; struct smbd_server_connection *sconn = smbd_server_conn; ZERO_STRUCT(ticket); ZERO_STRUCT(ap_rep); ZERO_STRUCT(ap_rep_wrapped); ZERO_STRUCT(response); /* Normally we will always invalidate the intermediate vuid. */ *p_invalidate_vuid = True; mem_ctx = talloc_init("reply_spnego_kerberos"); if (mem_ctx == NULL) { reply_nterror(req, nt_status_squash(NT_STATUS_NO_MEMORY)); return; } if (!spnego_parse_krb5_wrap(*secblob, &ticket, tok_id)) { talloc_destroy(mem_ctx); reply_nterror(req, nt_status_squash(NT_STATUS_LOGON_FAILURE)); return; } ret = ads_verify_ticket(mem_ctx, lp_realm(), 0, &ticket, &client, &pac_data, &ap_rep, &session_key, True); data_blob_free(&ticket); if (!NT_STATUS_IS_OK(ret)) { #if 0 /* Experiment that failed. * See "only happens with a KDC" comment below. */ if (NT_STATUS_EQUAL(ret, NT_STATUS_TIME_DIFFERENCE_AT_DC)) { /* * Windows in this case returns * NT_STATUS_MORE_PROCESSING_REQUIRED * with a negTokenTarg blob containing an krb5_error * struct ASN1 encoded containing KRB5KRB_AP_ERR_SKEW. * The client then fixes its clock and continues rather * than giving an error. JRA. * -- Looks like this only happens with a KDC. JRA. */ bool ok = make_krb5_skew_error(&ap_rep); if (!ok) { talloc_destroy(mem_ctx); return ERROR_NT(nt_status_squash( NT_STATUS_LOGON_FAILURE)); } ap_rep_wrapped = spnego_gen_krb5_wrap(ap_rep, TOK_ID_KRB_ERROR); response = spnego_gen_auth_response(&ap_rep_wrapped, ret, OID_KERBEROS5_OLD); reply_sesssetup_blob(conn, inbuf, outbuf, response, NT_STATUS_MORE_PROCESSING_REQUIRED); /* * In this one case we don't invalidate the * intermediate vuid as we're expecting the client * to re-use it for the next sessionsetupX packet. JRA. */ *p_invalidate_vuid = False; data_blob_free(&ap_rep); data_blob_free(&ap_rep_wrapped); data_blob_free(&response); talloc_destroy(mem_ctx); return -1; /* already replied */ } #else if (!NT_STATUS_EQUAL(ret, NT_STATUS_TIME_DIFFERENCE_AT_DC)) { ret = NT_STATUS_LOGON_FAILURE; } #endif DEBUG(1,("Failed to verify incoming ticket with error %s!\n", nt_errstr(ret))); talloc_destroy(mem_ctx); reply_nterror(req, nt_status_squash(ret)); return; } DEBUG(3,("Ticket name is [%s]\n", client)); p = strchr_m(client, '@'); if (!p) { DEBUG(3,("Doesn't look like a valid principal\n")); data_blob_free(&ap_rep); data_blob_free(&session_key); talloc_destroy(mem_ctx); reply_nterror(req,nt_status_squash(NT_STATUS_LOGON_FAILURE)); return; } *p = 0; /* save the PAC data if we have it */ if (pac_data) { logon_info = get_logon_info_from_pac(pac_data); if (logon_info) { netsamlogon_cache_store( client, &logon_info->info3 ); } } if (!strequal(p+1, lp_realm())) { DEBUG(3,("Ticket for foreign realm %s@%s\n", client, p+1)); if (!lp_allow_trusted_domains()) { data_blob_free(&ap_rep); data_blob_free(&session_key); talloc_destroy(mem_ctx); reply_nterror(req, nt_status_squash( NT_STATUS_LOGON_FAILURE)); return; } } /* this gives a fully qualified user name (ie. with full realm). that leads to very long usernames, but what else can we do? */ domain = p+1; if (logon_info && logon_info->info3.base.domain.string) { fstrcpy(netbios_domain_name, logon_info->info3.base.domain.string); domain = netbios_domain_name; DEBUG(10, ("Mapped to [%s] (using PAC)\n", domain)); } else { /* If we have winbind running, we can (and must) shorten the username by using the short netbios name. Otherwise we will have inconsistent user names. With Kerberos, we get the fully qualified realm, with ntlmssp we get the short name. And even w2k3 does use ntlmssp if you for example connect to an ip address. */ wbcErr wbc_status; struct wbcDomainInfo *info = NULL; DEBUG(10, ("Mapping [%s] to short name\n", domain)); wbc_status = wbcDomainInfo(domain, &info); if (WBC_ERROR_IS_OK(wbc_status)) { fstrcpy(netbios_domain_name, info->short_name); wbcFreeMemory(info); domain = netbios_domain_name; DEBUG(10, ("Mapped to [%s] (using Winbind)\n", domain)); } else { DEBUG(3, ("Could not find short name: %s\n", wbcErrorString(wbc_status))); } } fstr_sprintf(user, "%s%c%s", domain, *lp_winbind_separator(), client); /* lookup the passwd struct, create a new user if necessary */ username_was_mapped = map_username(sconn, user); pw = smb_getpwnam( mem_ctx, user, real_username, True ); if (pw) { /* if a real user check pam account restrictions */ /* only really perfomed if "obey pam restriction" is true */ /* do this before an eventual mapping to guest occurs */ ret = smb_pam_accountcheck(pw->pw_name); if ( !NT_STATUS_IS_OK(ret)) { DEBUG(1,("PAM account restriction " "prevents user login\n")); data_blob_free(&ap_rep); data_blob_free(&session_key); TALLOC_FREE(mem_ctx); reply_nterror(req, nt_status_squash(ret)); return; } } if (!pw) { /* this was originally the behavior of Samba 2.2, if a user did not have a local uid but has been authenticated, then map them to a guest account */ if (lp_map_to_guest() == MAP_TO_GUEST_ON_BAD_UID){ map_domainuser_to_guest = True; fstrcpy(user,lp_guestaccount()); pw = smb_getpwnam( mem_ctx, user, real_username, True ); } /* extra sanity check that the guest account is valid */ if ( !pw ) { DEBUG(1,("Username %s is invalid on this system\n", user)); data_blob_free(&ap_rep); data_blob_free(&session_key); TALLOC_FREE(mem_ctx); reply_nterror(req, nt_status_squash( NT_STATUS_LOGON_FAILURE)); return; } } /* setup the string used by %U */ sub_set_smb_name( real_username ); reload_services(True); if ( map_domainuser_to_guest ) { make_server_info_guest(NULL, &server_info); } else if (logon_info) { /* pass the unmapped username here since map_username() will be called again from inside make_server_info_info3() */ ret = make_server_info_info3(mem_ctx, client, domain, &server_info, &logon_info->info3); if ( !NT_STATUS_IS_OK(ret) ) { DEBUG(1,("make_server_info_info3 failed: %s!\n", nt_errstr(ret))); data_blob_free(&ap_rep); data_blob_free(&session_key); TALLOC_FREE(mem_ctx); reply_nterror(req, nt_status_squash(ret)); return; } } else { /* * We didn't get a PAC, we have to make up the user * ourselves. Try to ask the pdb backend to provide * SID consistency with ntlmssp session setup */ struct samu *sampass; sampass = samu_new(talloc_tos()); if (sampass == NULL) { ret = NT_STATUS_NO_MEMORY; data_blob_free(&ap_rep); data_blob_free(&session_key); TALLOC_FREE(mem_ctx); reply_nterror(req, nt_status_squash(ret)); return; } if (pdb_getsampwnam(sampass, real_username)) { DEBUG(10, ("found user %s in passdb, calling " "make_server_info_sam\n", real_username)); ret = make_server_info_sam(&server_info, sampass); } else { /* * User not in passdb, make it up artificially */ TALLOC_FREE(sampass); DEBUG(10, ("didn't find user %s in passdb, calling " "make_server_info_pw\n", real_username)); ret = make_server_info_pw(&server_info, real_username, pw); } if ( !NT_STATUS_IS_OK(ret) ) { DEBUG(1,("make_server_info_[sam|pw] failed: %s!\n", nt_errstr(ret))); data_blob_free(&ap_rep); data_blob_free(&session_key); TALLOC_FREE(mem_ctx); reply_nterror(req, nt_status_squash(ret)); return; } /* make_server_info_pw does not set the domain. Without this * we end up with the local netbios name in substitutions for * %D. */ if (server_info->sam_account != NULL) { pdb_set_domain(server_info->sam_account, domain, PDB_SET); } } server_info->nss_token |= username_was_mapped; /* we need to build the token for the user. make_server_info_guest() already does this */ if ( !server_info->ptok ) { ret = create_local_token( server_info ); if ( !NT_STATUS_IS_OK(ret) ) { DEBUG(10,("failed to create local token: %s\n", nt_errstr(ret))); data_blob_free(&ap_rep); data_blob_free(&session_key); TALLOC_FREE( mem_ctx ); TALLOC_FREE( server_info ); reply_nterror(req, nt_status_squash(ret)); return; } } if (!is_partial_auth_vuid(sconn, sess_vuid)) { sess_vuid = register_initial_vuid(sconn); } data_blob_free(&server_info->user_session_key); server_info->user_session_key = session_key; session_key = data_blob_null; /* register_existing_vuid keeps the server info */ /* register_existing_vuid takes ownership of session_key on success, * no need to free after this on success. A better interface would copy * it.... */ sess_vuid = register_existing_vuid(sconn, sess_vuid, server_info, nullblob, client); reply_outbuf(req, 4, 0); SSVAL(req->outbuf,smb_uid,sess_vuid); if (sess_vuid == UID_FIELD_INVALID ) { ret = NT_STATUS_LOGON_FAILURE; } else { /* current_user_info is changed on new vuid */ reload_services( True ); SSVAL(req->outbuf, smb_vwv3, 0); if (server_info->guest) { SSVAL(req->outbuf,smb_vwv2,1); } SSVAL(req->outbuf, smb_uid, sess_vuid); /* Successful logon. Keep this vuid. */ *p_invalidate_vuid = False; } /* wrap that up in a nice GSS-API wrapping */ if (NT_STATUS_IS_OK(ret)) { ap_rep_wrapped = spnego_gen_krb5_wrap(ap_rep, TOK_ID_KRB_AP_REP); } else { ap_rep_wrapped = data_blob_null; } response = spnego_gen_auth_response(&ap_rep_wrapped, ret, mechOID); reply_sesssetup_blob(req, response, ret); data_blob_free(&ap_rep); data_blob_free(&ap_rep_wrapped); data_blob_free(&response); TALLOC_FREE(mem_ctx); }
DoS Overflow
0
static void reply_spnego_kerberos(struct smb_request *req, DATA_BLOB *secblob, const char *mechOID, uint16 vuid, bool *p_invalidate_vuid) { TALLOC_CTX *mem_ctx; DATA_BLOB ticket; char *client, *p, *domain; fstring netbios_domain_name; struct passwd *pw; fstring user; int sess_vuid = req->vuid; NTSTATUS ret = NT_STATUS_OK; struct PAC_DATA *pac_data = NULL; DATA_BLOB ap_rep, ap_rep_wrapped, response; auth_serversupplied_info *server_info = NULL; DATA_BLOB session_key = data_blob_null; uint8 tok_id[2]; DATA_BLOB nullblob = data_blob_null; fstring real_username; bool map_domainuser_to_guest = False; bool username_was_mapped; struct PAC_LOGON_INFO *logon_info = NULL; struct smbd_server_connection *sconn = smbd_server_conn; ZERO_STRUCT(ticket); ZERO_STRUCT(ap_rep); ZERO_STRUCT(ap_rep_wrapped); ZERO_STRUCT(response); /* Normally we will always invalidate the intermediate vuid. */ *p_invalidate_vuid = True; mem_ctx = talloc_init("reply_spnego_kerberos"); if (mem_ctx == NULL) { reply_nterror(req, nt_status_squash(NT_STATUS_NO_MEMORY)); return; } if (!spnego_parse_krb5_wrap(*secblob, &ticket, tok_id)) { talloc_destroy(mem_ctx); reply_nterror(req, nt_status_squash(NT_STATUS_LOGON_FAILURE)); return; } ret = ads_verify_ticket(mem_ctx, lp_realm(), 0, &ticket, &client, &pac_data, &ap_rep, &session_key, True); data_blob_free(&ticket); if (!NT_STATUS_IS_OK(ret)) { #if 0 /* Experiment that failed. * See "only happens with a KDC" comment below. */ if (NT_STATUS_EQUAL(ret, NT_STATUS_TIME_DIFFERENCE_AT_DC)) { /* * Windows in this case returns * NT_STATUS_MORE_PROCESSING_REQUIRED * with a negTokenTarg blob containing an krb5_error * struct ASN1 encoded containing KRB5KRB_AP_ERR_SKEW. * The client then fixes its clock and continues rather * than giving an error. JRA. * -- Looks like this only happens with a KDC. JRA. */ bool ok = make_krb5_skew_error(&ap_rep); if (!ok) { talloc_destroy(mem_ctx); return ERROR_NT(nt_status_squash( NT_STATUS_LOGON_FAILURE)); } ap_rep_wrapped = spnego_gen_krb5_wrap(ap_rep, TOK_ID_KRB_ERROR); response = spnego_gen_auth_response(&ap_rep_wrapped, ret, OID_KERBEROS5_OLD); reply_sesssetup_blob(conn, inbuf, outbuf, response, NT_STATUS_MORE_PROCESSING_REQUIRED); /* * In this one case we don't invalidate the * intermediate vuid as we're expecting the client * to re-use it for the next sessionsetupX packet. JRA. */ *p_invalidate_vuid = False; data_blob_free(&ap_rep); data_blob_free(&ap_rep_wrapped); data_blob_free(&response); talloc_destroy(mem_ctx); return -1; /* already replied */ } #else if (!NT_STATUS_EQUAL(ret, NT_STATUS_TIME_DIFFERENCE_AT_DC)) { ret = NT_STATUS_LOGON_FAILURE; } #endif DEBUG(1,("Failed to verify incoming ticket with error %s!\n", nt_errstr(ret))); talloc_destroy(mem_ctx); reply_nterror(req, nt_status_squash(ret)); return; } DEBUG(3,("Ticket name is [%s]\n", client)); p = strchr_m(client, '@'); if (!p) { DEBUG(3,("Doesn't look like a valid principal\n")); data_blob_free(&ap_rep); data_blob_free(&session_key); talloc_destroy(mem_ctx); reply_nterror(req,nt_status_squash(NT_STATUS_LOGON_FAILURE)); return; } *p = 0; /* save the PAC data if we have it */ if (pac_data) { logon_info = get_logon_info_from_pac(pac_data); if (logon_info) { netsamlogon_cache_store( client, &logon_info->info3 ); } } if (!strequal(p+1, lp_realm())) { DEBUG(3,("Ticket for foreign realm %s@%s\n", client, p+1)); if (!lp_allow_trusted_domains()) { data_blob_free(&ap_rep); data_blob_free(&session_key); talloc_destroy(mem_ctx); reply_nterror(req, nt_status_squash( NT_STATUS_LOGON_FAILURE)); return; } } /* this gives a fully qualified user name (ie. with full realm). that leads to very long usernames, but what else can we do? */ domain = p+1; if (logon_info && logon_info->info3.base.domain.string) { fstrcpy(netbios_domain_name, logon_info->info3.base.domain.string); domain = netbios_domain_name; DEBUG(10, ("Mapped to [%s] (using PAC)\n", domain)); } else { /* If we have winbind running, we can (and must) shorten the username by using the short netbios name. Otherwise we will have inconsistent user names. With Kerberos, we get the fully qualified realm, with ntlmssp we get the short name. And even w2k3 does use ntlmssp if you for example connect to an ip address. */ wbcErr wbc_status; struct wbcDomainInfo *info = NULL; DEBUG(10, ("Mapping [%s] to short name\n", domain)); wbc_status = wbcDomainInfo(domain, &info); if (WBC_ERROR_IS_OK(wbc_status)) { fstrcpy(netbios_domain_name, info->short_name); wbcFreeMemory(info); domain = netbios_domain_name; DEBUG(10, ("Mapped to [%s] (using Winbind)\n", domain)); } else { DEBUG(3, ("Could not find short name: %s\n", wbcErrorString(wbc_status))); } } fstr_sprintf(user, "%s%c%s", domain, *lp_winbind_separator(), client); /* lookup the passwd struct, create a new user if necessary */ username_was_mapped = map_username(sconn, user); pw = smb_getpwnam( mem_ctx, user, real_username, True ); if (pw) { /* if a real user check pam account restrictions */ /* only really perfomed if "obey pam restriction" is true */ /* do this before an eventual mapping to guest occurs */ ret = smb_pam_accountcheck(pw->pw_name); if ( !NT_STATUS_IS_OK(ret)) { DEBUG(1,("PAM account restriction " "prevents user login\n")); data_blob_free(&ap_rep); data_blob_free(&session_key); TALLOC_FREE(mem_ctx); reply_nterror(req, nt_status_squash(ret)); return; } } if (!pw) { /* this was originally the behavior of Samba 2.2, if a user did not have a local uid but has been authenticated, then map them to a guest account */ if (lp_map_to_guest() == MAP_TO_GUEST_ON_BAD_UID){ map_domainuser_to_guest = True; fstrcpy(user,lp_guestaccount()); pw = smb_getpwnam( mem_ctx, user, real_username, True ); } /* extra sanity check that the guest account is valid */ if ( !pw ) { DEBUG(1,("Username %s is invalid on this system\n", user)); data_blob_free(&ap_rep); data_blob_free(&session_key); TALLOC_FREE(mem_ctx); reply_nterror(req, nt_status_squash( NT_STATUS_LOGON_FAILURE)); return; } } /* setup the string used by %U */ sub_set_smb_name( real_username ); reload_services(True); if ( map_domainuser_to_guest ) { make_server_info_guest(NULL, &server_info); } else if (logon_info) { /* pass the unmapped username here since map_username() will be called again from inside make_server_info_info3() */ ret = make_server_info_info3(mem_ctx, client, domain, &server_info, &logon_info->info3); if ( !NT_STATUS_IS_OK(ret) ) { DEBUG(1,("make_server_info_info3 failed: %s!\n", nt_errstr(ret))); data_blob_free(&ap_rep); data_blob_free(&session_key); TALLOC_FREE(mem_ctx); reply_nterror(req, nt_status_squash(ret)); return; } } else { /* * We didn't get a PAC, we have to make up the user * ourselves. Try to ask the pdb backend to provide * SID consistency with ntlmssp session setup */ struct samu *sampass; sampass = samu_new(talloc_tos()); if (sampass == NULL) { ret = NT_STATUS_NO_MEMORY; data_blob_free(&ap_rep); data_blob_free(&session_key); TALLOC_FREE(mem_ctx); reply_nterror(req, nt_status_squash(ret)); return; } if (pdb_getsampwnam(sampass, real_username)) { DEBUG(10, ("found user %s in passdb, calling " "make_server_info_sam\n", real_username)); ret = make_server_info_sam(&server_info, sampass); } else { /* * User not in passdb, make it up artificially */ TALLOC_FREE(sampass); DEBUG(10, ("didn't find user %s in passdb, calling " "make_server_info_pw\n", real_username)); ret = make_server_info_pw(&server_info, real_username, pw); } if ( !NT_STATUS_IS_OK(ret) ) { DEBUG(1,("make_server_info_[sam|pw] failed: %s!\n", nt_errstr(ret))); data_blob_free(&ap_rep); data_blob_free(&session_key); TALLOC_FREE(mem_ctx); reply_nterror(req, nt_status_squash(ret)); return; } /* make_server_info_pw does not set the domain. Without this * we end up with the local netbios name in substitutions for * %D. */ if (server_info->sam_account != NULL) { pdb_set_domain(server_info->sam_account, domain, PDB_SET); } } server_info->nss_token |= username_was_mapped; /* we need to build the token for the user. make_server_info_guest() already does this */ if ( !server_info->ptok ) { ret = create_local_token( server_info ); if ( !NT_STATUS_IS_OK(ret) ) { DEBUG(10,("failed to create local token: %s\n", nt_errstr(ret))); data_blob_free(&ap_rep); data_blob_free(&session_key); TALLOC_FREE( mem_ctx ); TALLOC_FREE( server_info ); reply_nterror(req, nt_status_squash(ret)); return; } } if (!is_partial_auth_vuid(sconn, sess_vuid)) { sess_vuid = register_initial_vuid(sconn); } data_blob_free(&server_info->user_session_key); server_info->user_session_key = session_key; session_key = data_blob_null; /* register_existing_vuid keeps the server info */ /* register_existing_vuid takes ownership of session_key on success, * no need to free after this on success. A better interface would copy * it.... */ sess_vuid = register_existing_vuid(sconn, sess_vuid, server_info, nullblob, client); reply_outbuf(req, 4, 0); SSVAL(req->outbuf,smb_uid,sess_vuid); if (sess_vuid == UID_FIELD_INVALID ) { ret = NT_STATUS_LOGON_FAILURE; } else { /* current_user_info is changed on new vuid */ reload_services( True ); SSVAL(req->outbuf, smb_vwv3, 0); if (server_info->guest) { SSVAL(req->outbuf,smb_vwv2,1); } SSVAL(req->outbuf, smb_uid, sess_vuid); /* Successful logon. Keep this vuid. */ *p_invalidate_vuid = False; } /* wrap that up in a nice GSS-API wrapping */ if (NT_STATUS_IS_OK(ret)) { ap_rep_wrapped = spnego_gen_krb5_wrap(ap_rep, TOK_ID_KRB_AP_REP); } else { ap_rep_wrapped = data_blob_null; } response = spnego_gen_auth_response(&ap_rep_wrapped, ret, mechOID); reply_sesssetup_blob(req, response, ret); data_blob_free(&ap_rep); data_blob_free(&ap_rep_wrapped); data_blob_free(&response); TALLOC_FREE(mem_ctx); }
@@ -1213,7 +1213,7 @@ static void reply_sesssetup_and_X_spnego(struct smb_request *req) file_save("negotiate.dat", blob1.data, blob1.length); #endif - p2 = (char *)req->buf + data_blob_len; + p2 = (char *)req->buf + blob1.length; p2 += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p2, STR_TERMINATE);
CWE-119
null
null
8,813
static void reply_spnego_negotiate(struct smb_request *req, uint16 vuid, DATA_BLOB blob1, AUTH_NTLMSSP_STATE **auth_ntlmssp_state) { DATA_BLOB secblob; DATA_BLOB chal; char *kerb_mech = NULL; NTSTATUS status; struct smbd_server_connection *sconn = smbd_server_conn; status = parse_spnego_mechanisms(blob1, &secblob, &kerb_mech); if (!NT_STATUS_IS_OK(status)) { /* Kill the intermediate vuid */ invalidate_vuid(sconn, vuid); reply_nterror(req, nt_status_squash(status)); return; } DEBUG(3,("reply_spnego_negotiate: Got secblob of size %lu\n", (unsigned long)secblob.length)); #ifdef HAVE_KRB5 if (kerb_mech && ((lp_security()==SEC_ADS) || USE_KERBEROS_KEYTAB) ) { bool destroy_vuid = True; reply_spnego_kerberos(req, &secblob, kerb_mech, vuid, &destroy_vuid); data_blob_free(&secblob); if (destroy_vuid) { /* Kill the intermediate vuid */ invalidate_vuid(sconn, vuid); } SAFE_FREE(kerb_mech); return; } #endif if (*auth_ntlmssp_state) { auth_ntlmssp_end(auth_ntlmssp_state); } if (kerb_mech) { data_blob_free(&secblob); /* The mechtoken is a krb5 ticket, but * we need to fall back to NTLM. */ reply_spnego_downgrade_to_ntlmssp(req, vuid); SAFE_FREE(kerb_mech); return; } status = auth_ntlmssp_start(auth_ntlmssp_state); if (!NT_STATUS_IS_OK(status)) { /* Kill the intermediate vuid */ invalidate_vuid(sconn, vuid); reply_nterror(req, nt_status_squash(status)); return; } status = auth_ntlmssp_update(*auth_ntlmssp_state, secblob, &chal); data_blob_free(&secblob); reply_spnego_ntlmssp(req, vuid, auth_ntlmssp_state, &chal, status, OID_NTLMSSP, true); data_blob_free(&chal); /* already replied */ return; }
DoS Overflow
0
static void reply_spnego_negotiate(struct smb_request *req, uint16 vuid, DATA_BLOB blob1, AUTH_NTLMSSP_STATE **auth_ntlmssp_state) { DATA_BLOB secblob; DATA_BLOB chal; char *kerb_mech = NULL; NTSTATUS status; struct smbd_server_connection *sconn = smbd_server_conn; status = parse_spnego_mechanisms(blob1, &secblob, &kerb_mech); if (!NT_STATUS_IS_OK(status)) { /* Kill the intermediate vuid */ invalidate_vuid(sconn, vuid); reply_nterror(req, nt_status_squash(status)); return; } DEBUG(3,("reply_spnego_negotiate: Got secblob of size %lu\n", (unsigned long)secblob.length)); #ifdef HAVE_KRB5 if (kerb_mech && ((lp_security()==SEC_ADS) || USE_KERBEROS_KEYTAB) ) { bool destroy_vuid = True; reply_spnego_kerberos(req, &secblob, kerb_mech, vuid, &destroy_vuid); data_blob_free(&secblob); if (destroy_vuid) { /* Kill the intermediate vuid */ invalidate_vuid(sconn, vuid); } SAFE_FREE(kerb_mech); return; } #endif if (*auth_ntlmssp_state) { auth_ntlmssp_end(auth_ntlmssp_state); } if (kerb_mech) { data_blob_free(&secblob); /* The mechtoken is a krb5 ticket, but * we need to fall back to NTLM. */ reply_spnego_downgrade_to_ntlmssp(req, vuid); SAFE_FREE(kerb_mech); return; } status = auth_ntlmssp_start(auth_ntlmssp_state); if (!NT_STATUS_IS_OK(status)) { /* Kill the intermediate vuid */ invalidate_vuid(sconn, vuid); reply_nterror(req, nt_status_squash(status)); return; } status = auth_ntlmssp_update(*auth_ntlmssp_state, secblob, &chal); data_blob_free(&secblob); reply_spnego_ntlmssp(req, vuid, auth_ntlmssp_state, &chal, status, OID_NTLMSSP, true); data_blob_free(&chal); /* already replied */ return; }
@@ -1213,7 +1213,7 @@ static void reply_sesssetup_and_X_spnego(struct smb_request *req) file_save("negotiate.dat", blob1.data, blob1.length); #endif - p2 = (char *)req->buf + data_blob_len; + p2 = (char *)req->buf + blob1.length; p2 += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p2, STR_TERMINATE);
CWE-119
null
null
8,814
static void reply_spnego_ntlmssp(struct smb_request *req, uint16 vuid, AUTH_NTLMSSP_STATE **auth_ntlmssp_state, DATA_BLOB *ntlmssp_blob, NTSTATUS nt_status, const char *OID, bool wrap) { DATA_BLOB response; struct auth_serversupplied_info *server_info = NULL; struct smbd_server_connection *sconn = smbd_server_conn; if (NT_STATUS_IS_OK(nt_status)) { server_info = (*auth_ntlmssp_state)->server_info; } else { nt_status = do_map_to_guest(nt_status, &server_info, (*auth_ntlmssp_state)->ntlmssp_state->user, (*auth_ntlmssp_state)->ntlmssp_state->domain); } reply_outbuf(req, 4, 0); SSVAL(req->outbuf, smb_uid, vuid); if (NT_STATUS_IS_OK(nt_status)) { DATA_BLOB nullblob = data_blob_null; if (!is_partial_auth_vuid(sconn, vuid)) { nt_status = NT_STATUS_LOGON_FAILURE; goto out; } data_blob_free(&server_info->user_session_key); server_info->user_session_key = data_blob_talloc( server_info, (*auth_ntlmssp_state)->ntlmssp_state->session_key.data, (*auth_ntlmssp_state)->ntlmssp_state->session_key.length); /* register_existing_vuid keeps the server info */ if (register_existing_vuid(sconn, vuid, server_info, nullblob, (*auth_ntlmssp_state)->ntlmssp_state->user) != vuid) { nt_status = NT_STATUS_LOGON_FAILURE; goto out; } (*auth_ntlmssp_state)->server_info = NULL; /* current_user_info is changed on new vuid */ reload_services( True ); SSVAL(req->outbuf, smb_vwv3, 0); if (server_info->guest) { SSVAL(req->outbuf,smb_vwv2,1); } } out: if (wrap) { response = spnego_gen_auth_response(ntlmssp_blob, nt_status, OID); } else { response = *ntlmssp_blob; } reply_sesssetup_blob(req, response, nt_status); if (wrap) { data_blob_free(&response); } /* NT_STATUS_MORE_PROCESSING_REQUIRED from our NTLMSSP code tells us, and the other end, that we are not finished yet. */ if (!NT_STATUS_EQUAL(nt_status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { /* NB. This is *NOT* an error case. JRA */ auth_ntlmssp_end(auth_ntlmssp_state); if (!NT_STATUS_IS_OK(nt_status)) { /* Kill the intermediate vuid */ invalidate_vuid(sconn, vuid); } } }
DoS Overflow
0
static void reply_spnego_ntlmssp(struct smb_request *req, uint16 vuid, AUTH_NTLMSSP_STATE **auth_ntlmssp_state, DATA_BLOB *ntlmssp_blob, NTSTATUS nt_status, const char *OID, bool wrap) { DATA_BLOB response; struct auth_serversupplied_info *server_info = NULL; struct smbd_server_connection *sconn = smbd_server_conn; if (NT_STATUS_IS_OK(nt_status)) { server_info = (*auth_ntlmssp_state)->server_info; } else { nt_status = do_map_to_guest(nt_status, &server_info, (*auth_ntlmssp_state)->ntlmssp_state->user, (*auth_ntlmssp_state)->ntlmssp_state->domain); } reply_outbuf(req, 4, 0); SSVAL(req->outbuf, smb_uid, vuid); if (NT_STATUS_IS_OK(nt_status)) { DATA_BLOB nullblob = data_blob_null; if (!is_partial_auth_vuid(sconn, vuid)) { nt_status = NT_STATUS_LOGON_FAILURE; goto out; } data_blob_free(&server_info->user_session_key); server_info->user_session_key = data_blob_talloc( server_info, (*auth_ntlmssp_state)->ntlmssp_state->session_key.data, (*auth_ntlmssp_state)->ntlmssp_state->session_key.length); /* register_existing_vuid keeps the server info */ if (register_existing_vuid(sconn, vuid, server_info, nullblob, (*auth_ntlmssp_state)->ntlmssp_state->user) != vuid) { nt_status = NT_STATUS_LOGON_FAILURE; goto out; } (*auth_ntlmssp_state)->server_info = NULL; /* current_user_info is changed on new vuid */ reload_services( True ); SSVAL(req->outbuf, smb_vwv3, 0); if (server_info->guest) { SSVAL(req->outbuf,smb_vwv2,1); } } out: if (wrap) { response = spnego_gen_auth_response(ntlmssp_blob, nt_status, OID); } else { response = *ntlmssp_blob; } reply_sesssetup_blob(req, response, nt_status); if (wrap) { data_blob_free(&response); } /* NT_STATUS_MORE_PROCESSING_REQUIRED from our NTLMSSP code tells us, and the other end, that we are not finished yet. */ if (!NT_STATUS_EQUAL(nt_status, NT_STATUS_MORE_PROCESSING_REQUIRED)) { /* NB. This is *NOT* an error case. JRA */ auth_ntlmssp_end(auth_ntlmssp_state); if (!NT_STATUS_IS_OK(nt_status)) { /* Kill the intermediate vuid */ invalidate_vuid(sconn, vuid); } } }
@@ -1213,7 +1213,7 @@ static void reply_sesssetup_and_X_spnego(struct smb_request *req) file_save("negotiate.dat", blob1.data, blob1.length); #endif - p2 = (char *)req->buf + data_blob_len; + p2 = (char *)req->buf + blob1.length; p2 += srvstr_pull_req_talloc(talloc_tos(), req, &tmp, p2, STR_TERMINATE);
CWE-119
null
null
8,815
void add_to_common_flags2(uint32 v) { common_flags2 |= v; }
DoS
0
void add_to_common_flags2(uint32 v) { common_flags2 |= v; }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,816
static void construct_reply(char *inbuf, int size, size_t unread_bytes, uint32_t seqnum, bool encrypted, struct smb_perfcount_data *deferred_pcd) { connection_struct *conn; struct smb_request *req; if (!(req = talloc(talloc_tos(), struct smb_request))) { smb_panic("could not allocate smb_request"); } init_smb_request(req, (uint8 *)inbuf, unread_bytes, encrypted, seqnum); req->inbuf = (uint8_t *)talloc_move(req, &inbuf); /* we popped this message off the queue - keep original perf data */ if (deferred_pcd) req->pcd = *deferred_pcd; else { SMB_PERFCOUNT_START(&req->pcd); SMB_PERFCOUNT_SET_OP(&req->pcd, req->cmd); SMB_PERFCOUNT_SET_MSGLEN_IN(&req->pcd, size); } conn = switch_message(req->cmd, req, size); if (req->unread_bytes) { /* writeX failed. drain socket. */ if (drain_socket(smbd_server_fd(), req->unread_bytes) != req->unread_bytes) { smb_panic("failed to drain pending bytes"); } req->unread_bytes = 0; } if (req->done) { TALLOC_FREE(req); return; } if (req->outbuf == NULL) { return; } if (CVAL(req->outbuf,0) == 0) { show_msg((char *)req->outbuf); } if (!srv_send_smb(smbd_server_fd(), (char *)req->outbuf, true, req->seqnum+1, IS_CONN_ENCRYPTED(conn)||req->encrypted, &req->pcd)) { exit_server_cleanly("construct_reply: srv_send_smb failed."); } TALLOC_FREE(req); return; }
DoS
0
static void construct_reply(char *inbuf, int size, size_t unread_bytes, uint32_t seqnum, bool encrypted, struct smb_perfcount_data *deferred_pcd) { connection_struct *conn; struct smb_request *req; if (!(req = talloc(talloc_tos(), struct smb_request))) { smb_panic("could not allocate smb_request"); } init_smb_request(req, (uint8 *)inbuf, unread_bytes, encrypted, seqnum); req->inbuf = (uint8_t *)talloc_move(req, &inbuf); /* we popped this message off the queue - keep original perf data */ if (deferred_pcd) req->pcd = *deferred_pcd; else { SMB_PERFCOUNT_START(&req->pcd); SMB_PERFCOUNT_SET_OP(&req->pcd, req->cmd); SMB_PERFCOUNT_SET_MSGLEN_IN(&req->pcd, size); } conn = switch_message(req->cmd, req, size); if (req->unread_bytes) { /* writeX failed. drain socket. */ if (drain_socket(smbd_server_fd(), req->unread_bytes) != req->unread_bytes) { smb_panic("failed to drain pending bytes"); } req->unread_bytes = 0; } if (req->done) { TALLOC_FREE(req); return; } if (req->outbuf == NULL) { return; } if (CVAL(req->outbuf,0) == 0) { show_msg((char *)req->outbuf); } if (!srv_send_smb(smbd_server_fd(), (char *)req->outbuf, true, req->seqnum+1, IS_CONN_ENCRYPTED(conn)||req->encrypted, &req->pcd)) { exit_server_cleanly("construct_reply: srv_send_smb failed."); } TALLOC_FREE(req); return; }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,817
void construct_reply_common_req(struct smb_request *req, char *outbuf) { construct_reply_common(req, (char *)req->inbuf, outbuf); }
DoS
0
void construct_reply_common_req(struct smb_request *req, char *outbuf) { construct_reply_common(req, (char *)req->inbuf, outbuf); }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,818
static bool create_outbuf(TALLOC_CTX *mem_ctx, struct smb_request *req, const char *inbuf, char **outbuf, uint8_t num_words, uint32_t num_bytes) { /* * Protect against integer wrap */ if ((num_bytes > 0xffffff) || ((num_bytes + smb_size + num_words*2) > 0xffffff)) { char *msg; if (asprintf(&msg, "num_bytes too large: %u", (unsigned)num_bytes) == -1) { msg = CONST_DISCARD(char *, "num_bytes too large"); } smb_panic(msg); } *outbuf = TALLOC_ARRAY(mem_ctx, char, smb_size + num_words*2 + num_bytes); if (*outbuf == NULL) { return false; } construct_reply_common(req, inbuf, *outbuf); srv_set_message(*outbuf, num_words, num_bytes, false); /* * Zero out the word area, the caller has to take care of the bcc area * himself */ if (num_words != 0) { memset(*outbuf + smb_vwv0, 0, num_words*2); } return true; }
DoS
0
static bool create_outbuf(TALLOC_CTX *mem_ctx, struct smb_request *req, const char *inbuf, char **outbuf, uint8_t num_words, uint32_t num_bytes) { /* * Protect against integer wrap */ if ((num_bytes > 0xffffff) || ((num_bytes + smb_size + num_words*2) > 0xffffff)) { char *msg; if (asprintf(&msg, "num_bytes too large: %u", (unsigned)num_bytes) == -1) { msg = CONST_DISCARD(char *, "num_bytes too large"); } smb_panic(msg); } *outbuf = TALLOC_ARRAY(mem_ctx, char, smb_size + num_words*2 + num_bytes); if (*outbuf == NULL) { return false; } construct_reply_common(req, inbuf, *outbuf); srv_set_message(*outbuf, num_words, num_bytes, false); /* * Zero out the word area, the caller has to take care of the bcc area * himself */ if (num_words != 0) { memset(*outbuf + smb_vwv0, 0, num_words*2); } return true; }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,819
static bool deadtime_fn(const struct timeval *now, void *private_data) { struct smbd_server_connection *sconn = smbd_server_conn; if ((conn_num_open(sconn) == 0) || (conn_idle_all(sconn, now->tv_sec))) { DEBUG( 2, ( "Closing idle connection\n" ) ); messaging_send(smbd_messaging_context(), procid_self(), MSG_SHUTDOWN, &data_blob_null); return False; } return True; }
DoS
0
static bool deadtime_fn(const struct timeval *now, void *private_data) { struct smbd_server_connection *sconn = smbd_server_conn; if ((conn_num_open(sconn) == 0) || (conn_idle_all(sconn, now->tv_sec))) { DEBUG( 2, ( "Closing idle connection\n" ) ); messaging_send(smbd_messaging_context(), procid_self(), MSG_SHUTDOWN, &data_blob_null); return False; } return True; }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,820
struct idle_event *event_add_idle(struct event_context *event_ctx, TALLOC_CTX *mem_ctx, struct timeval interval, const char *name, bool (*handler)(const struct timeval *now, void *private_data), void *private_data) { struct idle_event *result; struct timeval now = timeval_current(); result = TALLOC_P(mem_ctx, struct idle_event); if (result == NULL) { DEBUG(0, ("talloc failed\n")); return NULL; } result->interval = interval; result->handler = handler; result->private_data = private_data; if (!(result->name = talloc_asprintf(result, "idle_evt(%s)", name))) { DEBUG(0, ("talloc failed\n")); TALLOC_FREE(result); return NULL; } result->te = event_add_timed(event_ctx, result, timeval_sum(&now, &interval), smbd_idle_event_handler, result); if (result->te == NULL) { DEBUG(0, ("event_add_timed failed\n")); TALLOC_FREE(result); return NULL; } DEBUG(10,("event_add_idle: %s %p\n", result->name, result->te)); return result; }
DoS
0
struct idle_event *event_add_idle(struct event_context *event_ctx, TALLOC_CTX *mem_ctx, struct timeval interval, const char *name, bool (*handler)(const struct timeval *now, void *private_data), void *private_data) { struct idle_event *result; struct timeval now = timeval_current(); result = TALLOC_P(mem_ctx, struct idle_event); if (result == NULL) { DEBUG(0, ("talloc failed\n")); return NULL; } result->interval = interval; result->handler = handler; result->private_data = private_data; if (!(result->name = talloc_asprintf(result, "idle_evt(%s)", name))) { DEBUG(0, ("talloc failed\n")); TALLOC_FREE(result); return NULL; } result->te = event_add_timed(event_ctx, result, timeval_sum(&now, &interval), smbd_idle_event_handler, result); if (result->te == NULL) { DEBUG(0, ("event_add_timed failed\n")); TALLOC_FREE(result); return NULL; } DEBUG(10,("event_add_idle: %s %p\n", result->name, result->te)); return result; }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,821
static void fixup_chain_error_packet(struct smb_request *req) { uint8_t *outbuf = req->outbuf; req->outbuf = NULL; reply_outbuf(req, 2, 0); memcpy(req->outbuf, outbuf, smb_wct); TALLOC_FREE(outbuf); SCVAL(req->outbuf, smb_vwv0, 0xff); }
DoS
0
static void fixup_chain_error_packet(struct smb_request *req) { uint8_t *outbuf = req->outbuf; req->outbuf = NULL; reply_outbuf(req, 2, 0); memcpy(req->outbuf, outbuf, smb_wct); TALLOC_FREE(outbuf); SCVAL(req->outbuf, smb_vwv0, 0xff); }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,822
struct pending_message_list *get_open_deferred_message(uint16 mid) { struct pending_message_list *pml; for (pml = deferred_open_queue; pml; pml = pml->next) { if (SVAL(pml->buf.data,smb_mid) == mid) { return pml; } } return NULL; }
DoS
0
struct pending_message_list *get_open_deferred_message(uint16 mid) { struct pending_message_list *pml; for (pml = deferred_open_queue; pml; pml = pml->next) { if (SVAL(pml->buf.data,smb_mid) == mid) { return pml; } } return NULL; }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,823
static bool housekeeping_fn(const struct timeval *now, void *private_data) { change_to_root_user(); /* update printer queue caches if necessary */ update_monitored_printq_cache(); /* check if we need to reload services */ check_reload(time(NULL)); /* Change machine password if neccessary. */ attempt_machine_password_change(); /* * Force a log file check. */ force_check_log_size(); check_log_size(); return true; }
DoS
0
static bool housekeeping_fn(const struct timeval *now, void *private_data) { change_to_root_user(); /* update printer queue caches if necessary */ update_monitored_printq_cache(); /* check if we need to reload services */ check_reload(time(NULL)); /* Change machine password if neccessary. */ attempt_machine_password_change(); /* * Force a log file check. */ force_check_log_size(); check_log_size(); return true; }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,824
static void init_smb_request(struct smb_request *req, const uint8 *inbuf, size_t unread_bytes, bool encrypted, uint32_t seqnum) { struct smbd_server_connection *sconn = smbd_server_conn; size_t req_size = smb_len(inbuf) + 4; /* Ensure we have at least smb_size bytes. */ if (req_size < smb_size) { DEBUG(0,("init_smb_request: invalid request size %u\n", (unsigned int)req_size )); exit_server_cleanly("Invalid SMB request"); } req->cmd = CVAL(inbuf, smb_com); req->flags2 = SVAL(inbuf, smb_flg2); req->smbpid = SVAL(inbuf, smb_pid); req->mid = SVAL(inbuf, smb_mid); req->seqnum = seqnum; req->vuid = SVAL(inbuf, smb_uid); req->tid = SVAL(inbuf, smb_tid); req->wct = CVAL(inbuf, smb_wct); req->vwv = (uint16_t *)(inbuf+smb_vwv); req->buflen = smb_buflen(inbuf); req->buf = (const uint8_t *)smb_buf(inbuf); req->unread_bytes = unread_bytes; req->encrypted = encrypted; req->conn = conn_find(sconn,req->tid); req->chain_fsp = NULL; req->chain_outbuf = NULL; req->done = false; smb_init_perfcount_data(&req->pcd); /* Ensure we have at least wct words and 2 bytes of bcc. */ if (smb_size + req->wct*2 > req_size) { DEBUG(0,("init_smb_request: invalid wct number %u (size %u)\n", (unsigned int)req->wct, (unsigned int)req_size)); exit_server_cleanly("Invalid SMB request"); } /* Ensure bcc is correct. */ if (((uint8 *)smb_buf(inbuf)) + req->buflen > inbuf + req_size) { DEBUG(0,("init_smb_request: invalid bcc number %u " "(wct = %u, size %u)\n", (unsigned int)req->buflen, (unsigned int)req->wct, (unsigned int)req_size)); exit_server_cleanly("Invalid SMB request"); } req->outbuf = NULL; }
DoS
0
static void init_smb_request(struct smb_request *req, const uint8 *inbuf, size_t unread_bytes, bool encrypted, uint32_t seqnum) { struct smbd_server_connection *sconn = smbd_server_conn; size_t req_size = smb_len(inbuf) + 4; /* Ensure we have at least smb_size bytes. */ if (req_size < smb_size) { DEBUG(0,("init_smb_request: invalid request size %u\n", (unsigned int)req_size )); exit_server_cleanly("Invalid SMB request"); } req->cmd = CVAL(inbuf, smb_com); req->flags2 = SVAL(inbuf, smb_flg2); req->smbpid = SVAL(inbuf, smb_pid); req->mid = SVAL(inbuf, smb_mid); req->seqnum = seqnum; req->vuid = SVAL(inbuf, smb_uid); req->tid = SVAL(inbuf, smb_tid); req->wct = CVAL(inbuf, smb_wct); req->vwv = (uint16_t *)(inbuf+smb_vwv); req->buflen = smb_buflen(inbuf); req->buf = (const uint8_t *)smb_buf(inbuf); req->unread_bytes = unread_bytes; req->encrypted = encrypted; req->conn = conn_find(sconn,req->tid); req->chain_fsp = NULL; req->chain_outbuf = NULL; req->done = false; smb_init_perfcount_data(&req->pcd); /* Ensure we have at least wct words and 2 bytes of bcc. */ if (smb_size + req->wct*2 > req_size) { DEBUG(0,("init_smb_request: invalid wct number %u (size %u)\n", (unsigned int)req->wct, (unsigned int)req_size)); exit_server_cleanly("Invalid SMB request"); } /* Ensure bcc is correct. */ if (((uint8 *)smb_buf(inbuf)) + req->buflen > inbuf + req_size) { DEBUG(0,("init_smb_request: invalid bcc number %u " "(wct = %u, size %u)\n", (unsigned int)req->buflen, (unsigned int)req->wct, (unsigned int)req_size)); exit_server_cleanly("Invalid SMB request"); } req->outbuf = NULL; }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,825
static bool keepalive_fn(const struct timeval *now, void *private_data) { if (!send_keepalive(smbd_server_fd())) { DEBUG( 2, ( "Keepalive failed - exiting.\n" ) ); return False; } return True; }
DoS
0
static bool keepalive_fn(const struct timeval *now, void *private_data) { if (!send_keepalive(smbd_server_fd())) { DEBUG( 2, ( "Keepalive failed - exiting.\n" ) ); return False; } return True; }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,826
bool open_was_deferred(uint16 mid) { struct pending_message_list *pml; for (pml = deferred_open_queue; pml; pml = pml->next) { if (SVAL(pml->buf.data,smb_mid) == mid && !pml->processed) { return True; } } return False; }
DoS
0
bool open_was_deferred(uint16 mid) { struct pending_message_list *pml; for (pml = deferred_open_queue; pml; pml = pml->next) { if (SVAL(pml->buf.data,smb_mid) == mid && !pml->processed) { return True; } } return False; }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,827
static void process_smb(struct smbd_server_connection *conn, uint8_t *inbuf, size_t nread, size_t unread_bytes, uint32_t seqnum, bool encrypted, struct smb_perfcount_data *deferred_pcd) { int msg_type = CVAL(inbuf,0); DO_PROFILE_INC(smb_count); DEBUG( 6, ( "got message type 0x%x of len 0x%x\n", msg_type, smb_len(inbuf) ) ); DEBUG( 3, ( "Transaction %d of length %d (%u toread)\n", trans_num, (int)nread, (unsigned int)unread_bytes )); if (msg_type != 0) { /* * NetBIOS session request, keepalive, etc. */ reply_special((char *)inbuf); goto done; } if (smbd_server_conn->allow_smb2) { if (smbd_is_smb2_header(inbuf, nread)) { smbd_smb2_first_negprot(smbd_server_conn, inbuf, nread); return; } smbd_server_conn->allow_smb2 = false; } show_msg((char *)inbuf); construct_reply((char *)inbuf,nread,unread_bytes,seqnum,encrypted,deferred_pcd); trans_num++; done: conn->smb1.num_requests++; /* The timeout_processing function isn't run nearly often enough to implement 'max log size' without overrunning the size of the file by many megabytes. This is especially true if we are running at debug level 10. Checking every 50 SMBs is a nice tradeoff of performance vs log file size overrun. */ if ((conn->smb1.num_requests % 50) == 0 && need_to_check_log_size()) { change_to_root_user(); check_log_size(); } }
DoS
0
static void process_smb(struct smbd_server_connection *conn, uint8_t *inbuf, size_t nread, size_t unread_bytes, uint32_t seqnum, bool encrypted, struct smb_perfcount_data *deferred_pcd) { int msg_type = CVAL(inbuf,0); DO_PROFILE_INC(smb_count); DEBUG( 6, ( "got message type 0x%x of len 0x%x\n", msg_type, smb_len(inbuf) ) ); DEBUG( 3, ( "Transaction %d of length %d (%u toread)\n", trans_num, (int)nread, (unsigned int)unread_bytes )); if (msg_type != 0) { /* * NetBIOS session request, keepalive, etc. */ reply_special((char *)inbuf); goto done; } if (smbd_server_conn->allow_smb2) { if (smbd_is_smb2_header(inbuf, nread)) { smbd_smb2_first_negprot(smbd_server_conn, inbuf, nread); return; } smbd_server_conn->allow_smb2 = false; } show_msg((char *)inbuf); construct_reply((char *)inbuf,nread,unread_bytes,seqnum,encrypted,deferred_pcd); trans_num++; done: conn->smb1.num_requests++; /* The timeout_processing function isn't run nearly often enough to implement 'max log size' without overrunning the size of the file by many megabytes. This is especially true if we are running at debug level 10. Checking every 50 SMBs is a nice tradeoff of performance vs log file size overrun. */ if ((conn->smb1.num_requests % 50) == 0 && need_to_check_log_size()) { change_to_root_user(); check_log_size(); } }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,828
bool push_deferred_smb_message(struct smb_request *req, struct timeval request_time, struct timeval timeout, char *private_data, size_t priv_len) { struct timeval end_time; if (req->unread_bytes) { DEBUG(0,("push_deferred_smb_message: logic error ! " "unread_bytes = %u\n", (unsigned int)req->unread_bytes )); smb_panic("push_deferred_smb_message: " "logic error unread_bytes != 0" ); } end_time = timeval_sum(&request_time, &timeout); DEBUG(10,("push_deferred_open_smb_message: pushing message len %u mid %u " "timeout time [%u.%06u]\n", (unsigned int) smb_len(req->inbuf)+4, (unsigned int)req->mid, (unsigned int)end_time.tv_sec, (unsigned int)end_time.tv_usec)); return push_queued_message(req, request_time, end_time, private_data, priv_len); }
DoS
0
bool push_deferred_smb_message(struct smb_request *req, struct timeval request_time, struct timeval timeout, char *private_data, size_t priv_len) { struct timeval end_time; if (req->unread_bytes) { DEBUG(0,("push_deferred_smb_message: logic error ! " "unread_bytes = %u\n", (unsigned int)req->unread_bytes )); smb_panic("push_deferred_smb_message: " "logic error unread_bytes != 0" ); } end_time = timeval_sum(&request_time, &timeout); DEBUG(10,("push_deferred_open_smb_message: pushing message len %u mid %u " "timeout time [%u.%06u]\n", (unsigned int) smb_len(req->inbuf)+4, (unsigned int)req->mid, (unsigned int)end_time.tv_sec, (unsigned int)end_time.tv_usec)); return push_queued_message(req, request_time, end_time, private_data, priv_len); }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,829
static NTSTATUS read_packet_remainder(int fd, char *buffer, unsigned int timeout, ssize_t len) { if (len <= 0) { return NT_STATUS_OK; } return read_fd_with_timeout(fd, buffer, len, len, timeout, NULL); }
DoS
0
static NTSTATUS read_packet_remainder(int fd, char *buffer, unsigned int timeout, ssize_t len) { if (len <= 0) { return NT_STATUS_OK; } return read_fd_with_timeout(fd, buffer, len, len, timeout, NULL); }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,830
static NTSTATUS receive_smb_raw_talloc(TALLOC_CTX *mem_ctx, int fd, char **buffer, unsigned int timeout, size_t *p_unread, size_t *plen) { char lenbuf[4]; size_t len; int min_recv_size = lp_min_receive_file_size(); NTSTATUS status; *p_unread = 0; status = read_smb_length_return_keepalive(fd, lenbuf, timeout, &len); if (!NT_STATUS_IS_OK(status)) { DEBUG(10, ("receive_smb_raw: %s\n", nt_errstr(status))); return status; } if (CVAL(lenbuf,0) == 0 && min_recv_size && (smb_len_large(lenbuf) > /* Could be a UNIX large writeX. */ (min_recv_size + STANDARD_WRITE_AND_X_HEADER_SIZE)) && !srv_is_signing_active(smbd_server_conn)) { return receive_smb_raw_talloc_partial_read( mem_ctx, lenbuf, fd, buffer, timeout, p_unread, plen); } if (!valid_packet_size(len)) { return NT_STATUS_INVALID_PARAMETER; } /* * The +4 here can't wrap, we've checked the length above already. */ *buffer = TALLOC_ARRAY(mem_ctx, char, len+4); if (*buffer == NULL) { DEBUG(0, ("Could not allocate inbuf of length %d\n", (int)len+4)); return NT_STATUS_NO_MEMORY; } memcpy(*buffer, lenbuf, sizeof(lenbuf)); status = read_packet_remainder(fd, (*buffer)+4, timeout, len); if (!NT_STATUS_IS_OK(status)) { return status; } *plen = len + 4; return NT_STATUS_OK; }
DoS
0
static NTSTATUS receive_smb_raw_talloc(TALLOC_CTX *mem_ctx, int fd, char **buffer, unsigned int timeout, size_t *p_unread, size_t *plen) { char lenbuf[4]; size_t len; int min_recv_size = lp_min_receive_file_size(); NTSTATUS status; *p_unread = 0; status = read_smb_length_return_keepalive(fd, lenbuf, timeout, &len); if (!NT_STATUS_IS_OK(status)) { DEBUG(10, ("receive_smb_raw: %s\n", nt_errstr(status))); return status; } if (CVAL(lenbuf,0) == 0 && min_recv_size && (smb_len_large(lenbuf) > /* Could be a UNIX large writeX. */ (min_recv_size + STANDARD_WRITE_AND_X_HEADER_SIZE)) && !srv_is_signing_active(smbd_server_conn)) { return receive_smb_raw_talloc_partial_read( mem_ctx, lenbuf, fd, buffer, timeout, p_unread, plen); } if (!valid_packet_size(len)) { return NT_STATUS_INVALID_PARAMETER; } /* * The +4 here can't wrap, we've checked the length above already. */ *buffer = TALLOC_ARRAY(mem_ctx, char, len+4); if (*buffer == NULL) { DEBUG(0, ("Could not allocate inbuf of length %d\n", (int)len+4)); return NT_STATUS_NO_MEMORY; } memcpy(*buffer, lenbuf, sizeof(lenbuf)); status = read_packet_remainder(fd, (*buffer)+4, timeout, len); if (!NT_STATUS_IS_OK(status)) { return status; } *plen = len + 4; return NT_STATUS_OK; }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,831
static NTSTATUS receive_smb_raw_talloc_partial_read(TALLOC_CTX *mem_ctx, const char lenbuf[4], int fd, char **buffer, unsigned int timeout, size_t *p_unread, size_t *len_ret) { /* Size of a WRITEX call (+4 byte len). */ char writeX_header[4 + STANDARD_WRITE_AND_X_HEADER_SIZE]; ssize_t len = smb_len_large(lenbuf); /* Could be a UNIX large writeX. */ ssize_t toread; NTSTATUS status; memcpy(writeX_header, lenbuf, 4); status = read_fd_with_timeout( fd, writeX_header + 4, STANDARD_WRITE_AND_X_HEADER_SIZE, STANDARD_WRITE_AND_X_HEADER_SIZE, timeout, NULL); if (!NT_STATUS_IS_OK(status)) { return status; } /* * Ok - now try and see if this is a possible * valid writeX call. */ if (is_valid_writeX_buffer((uint8_t *)writeX_header)) { /* * If the data offset is beyond what * we've read, drain the extra bytes. */ uint16_t doff = SVAL(writeX_header,smb_vwv11); ssize_t newlen; if (doff > STANDARD_WRITE_AND_X_HEADER_SIZE) { size_t drain = doff - STANDARD_WRITE_AND_X_HEADER_SIZE; if (drain_socket(smbd_server_fd(), drain) != drain) { smb_panic("receive_smb_raw_talloc_partial_read:" " failed to drain pending bytes"); } } else { doff = STANDARD_WRITE_AND_X_HEADER_SIZE; } /* Spoof down the length and null out the bcc. */ set_message_bcc(writeX_header, 0); newlen = smb_len(writeX_header); /* Copy the header we've written. */ *buffer = (char *)TALLOC_MEMDUP(mem_ctx, writeX_header, sizeof(writeX_header)); if (*buffer == NULL) { DEBUG(0, ("Could not allocate inbuf of length %d\n", (int)sizeof(writeX_header))); return NT_STATUS_NO_MEMORY; } /* Work out the remaining bytes. */ *p_unread = len - STANDARD_WRITE_AND_X_HEADER_SIZE; *len_ret = newlen + 4; return NT_STATUS_OK; } if (!valid_packet_size(len)) { return NT_STATUS_INVALID_PARAMETER; } /* * Not a valid writeX call. Just do the standard * talloc and return. */ *buffer = TALLOC_ARRAY(mem_ctx, char, len+4); if (*buffer == NULL) { DEBUG(0, ("Could not allocate inbuf of length %d\n", (int)len+4)); return NT_STATUS_NO_MEMORY; } /* Copy in what we already read. */ memcpy(*buffer, writeX_header, 4 + STANDARD_WRITE_AND_X_HEADER_SIZE); toread = len - STANDARD_WRITE_AND_X_HEADER_SIZE; if(toread > 0) { status = read_packet_remainder( fd, (*buffer) + 4 + STANDARD_WRITE_AND_X_HEADER_SIZE, timeout, toread); if (!NT_STATUS_IS_OK(status)) { DEBUG(10, ("receive_smb_raw_talloc_partial_read: %s\n", nt_errstr(status))); return status; } } *len_ret = len + 4; return NT_STATUS_OK; }
DoS
0
static NTSTATUS receive_smb_raw_talloc_partial_read(TALLOC_CTX *mem_ctx, const char lenbuf[4], int fd, char **buffer, unsigned int timeout, size_t *p_unread, size_t *len_ret) { /* Size of a WRITEX call (+4 byte len). */ char writeX_header[4 + STANDARD_WRITE_AND_X_HEADER_SIZE]; ssize_t len = smb_len_large(lenbuf); /* Could be a UNIX large writeX. */ ssize_t toread; NTSTATUS status; memcpy(writeX_header, lenbuf, 4); status = read_fd_with_timeout( fd, writeX_header + 4, STANDARD_WRITE_AND_X_HEADER_SIZE, STANDARD_WRITE_AND_X_HEADER_SIZE, timeout, NULL); if (!NT_STATUS_IS_OK(status)) { return status; } /* * Ok - now try and see if this is a possible * valid writeX call. */ if (is_valid_writeX_buffer((uint8_t *)writeX_header)) { /* * If the data offset is beyond what * we've read, drain the extra bytes. */ uint16_t doff = SVAL(writeX_header,smb_vwv11); ssize_t newlen; if (doff > STANDARD_WRITE_AND_X_HEADER_SIZE) { size_t drain = doff - STANDARD_WRITE_AND_X_HEADER_SIZE; if (drain_socket(smbd_server_fd(), drain) != drain) { smb_panic("receive_smb_raw_talloc_partial_read:" " failed to drain pending bytes"); } } else { doff = STANDARD_WRITE_AND_X_HEADER_SIZE; } /* Spoof down the length and null out the bcc. */ set_message_bcc(writeX_header, 0); newlen = smb_len(writeX_header); /* Copy the header we've written. */ *buffer = (char *)TALLOC_MEMDUP(mem_ctx, writeX_header, sizeof(writeX_header)); if (*buffer == NULL) { DEBUG(0, ("Could not allocate inbuf of length %d\n", (int)sizeof(writeX_header))); return NT_STATUS_NO_MEMORY; } /* Work out the remaining bytes. */ *p_unread = len - STANDARD_WRITE_AND_X_HEADER_SIZE; *len_ret = newlen + 4; return NT_STATUS_OK; } if (!valid_packet_size(len)) { return NT_STATUS_INVALID_PARAMETER; } /* * Not a valid writeX call. Just do the standard * talloc and return. */ *buffer = TALLOC_ARRAY(mem_ctx, char, len+4); if (*buffer == NULL) { DEBUG(0, ("Could not allocate inbuf of length %d\n", (int)len+4)); return NT_STATUS_NO_MEMORY; } /* Copy in what we already read. */ memcpy(*buffer, writeX_header, 4 + STANDARD_WRITE_AND_X_HEADER_SIZE); toread = len - STANDARD_WRITE_AND_X_HEADER_SIZE; if(toread > 0) { status = read_packet_remainder( fd, (*buffer) + 4 + STANDARD_WRITE_AND_X_HEADER_SIZE, timeout, toread); if (!NT_STATUS_IS_OK(status)) { DEBUG(10, ("receive_smb_raw_talloc_partial_read: %s\n", nt_errstr(status))); return status; } } *len_ret = len + 4; return NT_STATUS_OK; }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,832
static NTSTATUS receive_smb_talloc(TALLOC_CTX *mem_ctx, int fd, char **buffer, unsigned int timeout, size_t *p_unread, bool *p_encrypted, size_t *p_len, uint32_t *seqnum) { size_t len = 0; NTSTATUS status; *p_encrypted = false; status = receive_smb_raw_talloc(mem_ctx, fd, buffer, timeout, p_unread, &len); if (!NT_STATUS_IS_OK(status)) { return status; } if (is_encrypted_packet((uint8_t *)*buffer)) { status = srv_decrypt_buffer(*buffer); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("receive_smb_talloc: SMB decryption failed on " "incoming packet! Error %s\n", nt_errstr(status) )); return status; } *p_encrypted = true; } /* Check the incoming SMB signature. */ if (!srv_check_sign_mac(smbd_server_conn, *buffer, seqnum)) { DEBUG(0, ("receive_smb: SMB Signature verification failed on " "incoming packet!\n")); return NT_STATUS_INVALID_NETWORK_RESPONSE; } *p_len = len; return NT_STATUS_OK; }
DoS
0
static NTSTATUS receive_smb_talloc(TALLOC_CTX *mem_ctx, int fd, char **buffer, unsigned int timeout, size_t *p_unread, bool *p_encrypted, size_t *p_len, uint32_t *seqnum) { size_t len = 0; NTSTATUS status; *p_encrypted = false; status = receive_smb_raw_talloc(mem_ctx, fd, buffer, timeout, p_unread, &len); if (!NT_STATUS_IS_OK(status)) { return status; } if (is_encrypted_packet((uint8_t *)*buffer)) { status = srv_decrypt_buffer(*buffer); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("receive_smb_talloc: SMB decryption failed on " "incoming packet! Error %s\n", nt_errstr(status) )); return status; } *p_encrypted = true; } /* Check the incoming SMB signature. */ if (!srv_check_sign_mac(smbd_server_conn, *buffer, seqnum)) { DEBUG(0, ("receive_smb: SMB Signature verification failed on " "incoming packet!\n")); return NT_STATUS_INVALID_NETWORK_RESPONSE; } *p_len = len; return NT_STATUS_OK; }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,833
void remove_deferred_open_smb_message(uint16 mid) { struct pending_message_list *pml; for (pml = deferred_open_queue; pml; pml = pml->next) { if (mid == SVAL(pml->buf.data,smb_mid)) { DEBUG(10,("remove_deferred_open_smb_message: " "deleting mid %u len %u\n", (unsigned int)mid, (unsigned int)pml->buf.length )); DLIST_REMOVE(deferred_open_queue, pml); TALLOC_FREE(pml); return; } } }
DoS
0
void remove_deferred_open_smb_message(uint16 mid) { struct pending_message_list *pml; for (pml = deferred_open_queue; pml; pml = pml->next) { if (mid == SVAL(pml->buf.data,smb_mid)) { DEBUG(10,("remove_deferred_open_smb_message: " "deleting mid %u len %u\n", (unsigned int)mid, (unsigned int)pml->buf.length )); DLIST_REMOVE(deferred_open_queue, pml); TALLOC_FREE(pml); return; } } }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,834
void remove_from_common_flags2(uint32 v) { common_flags2 &= ~v; }
DoS
0
void remove_from_common_flags2(uint32 v) { common_flags2 &= ~v; }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,835
void reply_outbuf(struct smb_request *req, uint8 num_words, uint32 num_bytes) { char *outbuf; if (!create_outbuf(req, req, (char *)req->inbuf, &outbuf, num_words, num_bytes)) { smb_panic("could not allocate output buffer\n"); } req->outbuf = (uint8_t *)outbuf; }
DoS
0
void reply_outbuf(struct smb_request *req, uint8 num_words, uint32 num_bytes) { char *outbuf; if (!create_outbuf(req, req, (char *)req->inbuf, &outbuf, num_words, num_bytes)) { smb_panic("could not allocate output buffer\n"); } req->outbuf = (uint8_t *)outbuf; }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,836
bool req_is_in_chain(struct smb_request *req) { if (req->vwv != (uint16_t *)(req->inbuf+smb_vwv)) { /* * We're right now handling a subsequent request, so we must * be in a chain */ return true; } if (!is_andx_req(req->cmd)) { return false; } if (req->wct < 2) { /* * Okay, an illegal request, but definitely not chained :-) */ return false; } return (CVAL(req->vwv+0, 0) != 0xFF); }
DoS
0
bool req_is_in_chain(struct smb_request *req) { if (req->vwv != (uint16_t *)(req->inbuf+smb_vwv)) { /* * We're right now handling a subsequent request, so we must * be in a chain */ return true; } if (!is_andx_req(req->cmd)) { return false; } if (req->wct < 2) { /* * Okay, an illegal request, but definitely not chained :-) */ return false; } return (CVAL(req->vwv+0, 0) != 0xFF); }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,837
size_t req_wct_ofs(struct smb_request *req) { size_t buf_size; if (req->chain_outbuf == NULL) { return smb_wct - 4; } buf_size = talloc_get_size(req->chain_outbuf); if ((buf_size % 4) != 0) { buf_size += (4 - (buf_size % 4)); } return buf_size - 4; }
DoS
0
size_t req_wct_ofs(struct smb_request *req) { size_t buf_size; if (req->chain_outbuf == NULL) { return smb_wct - 4; } buf_size = talloc_get_size(req->chain_outbuf); if ((buf_size % 4) != 0) { buf_size += (4 - (buf_size % 4)); } return buf_size - 4; }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,838
void schedule_deferred_open_smb_message(uint16 mid) { struct pending_message_list *pml; int i = 0; for (pml = deferred_open_queue; pml; pml = pml->next) { uint16 msg_mid = SVAL(pml->buf.data,smb_mid); DEBUG(10,("schedule_deferred_open_smb_message: [%d] msg_mid = %u\n", i++, (unsigned int)msg_mid )); if (mid == msg_mid) { struct timed_event *te; if (pml->processed) { /* A processed message should not be * rescheduled. */ DEBUG(0,("schedule_deferred_open_smb_message: LOGIC ERROR " "message mid %u was already processed\n", msg_mid )); continue; } DEBUG(10,("schedule_deferred_open_smb_message: scheduling mid %u\n", mid )); te = event_add_timed(smbd_event_context(), pml, timeval_zero(), smbd_deferred_open_timer, pml); if (!te) { DEBUG(10,("schedule_deferred_open_smb_message: " "event_add_timed() failed, skipping mid %u\n", mid )); } TALLOC_FREE(pml->te); pml->te = te; DLIST_PROMOTE(deferred_open_queue, pml); return; } } DEBUG(10,("schedule_deferred_open_smb_message: failed to find message mid %u\n", mid )); }
DoS
0
void schedule_deferred_open_smb_message(uint16 mid) { struct pending_message_list *pml; int i = 0; for (pml = deferred_open_queue; pml; pml = pml->next) { uint16 msg_mid = SVAL(pml->buf.data,smb_mid); DEBUG(10,("schedule_deferred_open_smb_message: [%d] msg_mid = %u\n", i++, (unsigned int)msg_mid )); if (mid == msg_mid) { struct timed_event *te; if (pml->processed) { /* A processed message should not be * rescheduled. */ DEBUG(0,("schedule_deferred_open_smb_message: LOGIC ERROR " "message mid %u was already processed\n", msg_mid )); continue; } DEBUG(10,("schedule_deferred_open_smb_message: scheduling mid %u\n", mid )); te = event_add_timed(smbd_event_context(), pml, timeval_zero(), smbd_deferred_open_timer, pml); if (!te) { DEBUG(10,("schedule_deferred_open_smb_message: " "event_add_timed() failed, skipping mid %u\n", mid )); } TALLOC_FREE(pml->te); pml->te = te; DLIST_PROMOTE(deferred_open_queue, pml); return; } } DEBUG(10,("schedule_deferred_open_smb_message: failed to find message mid %u\n", mid )); }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,839
const char *smb_fn_name(int type) { const char *unknown_name = "SMBunknown"; if (smb_messages[type].name == NULL) return(unknown_name); return(smb_messages[type].name); }
DoS
0
const char *smb_fn_name(int type) { const char *unknown_name = "SMBunknown"; if (smb_messages[type].name == NULL) return(unknown_name); return(smb_messages[type].name); }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,840
static bool smb_splice_chain(uint8_t **poutbuf, uint8_t smb_command, uint8_t wct, const uint16_t *vwv, size_t bytes_alignment, uint32_t num_bytes, const uint8_t *bytes) { uint8_t *outbuf; size_t old_size, new_size; size_t ofs; size_t chain_padding = 0; size_t bytes_padding = 0; bool first_request; old_size = talloc_get_size(*poutbuf); /* * old_size == smb_wct means we're pushing the first request in for * libsmb/ */ first_request = (old_size == smb_wct); if (!first_request && ((old_size % 4) != 0)) { /* * Align the wct field of subsequent requests to a 4-byte * boundary */ chain_padding = 4 - (old_size % 4); } /* * After the old request comes the new wct field (1 byte), the vwv's * and the num_bytes field. After at we might need to align the bytes * given to us to "bytes_alignment", increasing the num_bytes value. */ new_size = old_size + chain_padding + 1 + wct * sizeof(uint16_t) + 2; if ((bytes_alignment != 0) && ((new_size % bytes_alignment) != 0)) { bytes_padding = bytes_alignment - (new_size % bytes_alignment); } new_size += bytes_padding + num_bytes; if ((smb_command != SMBwriteX) && (new_size > 0xffff)) { DEBUG(1, ("splice_chain: %u bytes won't fit\n", (unsigned)new_size)); return false; } outbuf = TALLOC_REALLOC_ARRAY(NULL, *poutbuf, uint8_t, new_size); if (outbuf == NULL) { DEBUG(0, ("talloc failed\n")); return false; } *poutbuf = outbuf; if (first_request) { SCVAL(outbuf, smb_com, smb_command); } else { size_t andx_cmd_ofs; if (!find_andx_cmd_ofs(outbuf, &andx_cmd_ofs)) { DEBUG(1, ("invalid command chain\n")); *poutbuf = TALLOC_REALLOC_ARRAY( NULL, *poutbuf, uint8_t, old_size); return false; } if (chain_padding != 0) { memset(outbuf + old_size, 0, chain_padding); old_size += chain_padding; } SCVAL(outbuf, andx_cmd_ofs, smb_command); SSVAL(outbuf, andx_cmd_ofs + 2, old_size - 4); } ofs = old_size; /* * Push the chained request: * * wct field */ SCVAL(outbuf, ofs, wct); ofs += 1; /* * vwv array */ memcpy(outbuf + ofs, vwv, sizeof(uint16_t) * wct); ofs += sizeof(uint16_t) * wct; /* * bcc (byte count) */ SSVAL(outbuf, ofs, num_bytes + bytes_padding); ofs += sizeof(uint16_t); /* * padding */ if (bytes_padding != 0) { memset(outbuf + ofs, 0, bytes_padding); ofs += bytes_padding; } /* * The bytes field */ memcpy(outbuf + ofs, bytes, num_bytes); return true; }
DoS
0
static bool smb_splice_chain(uint8_t **poutbuf, uint8_t smb_command, uint8_t wct, const uint16_t *vwv, size_t bytes_alignment, uint32_t num_bytes, const uint8_t *bytes) { uint8_t *outbuf; size_t old_size, new_size; size_t ofs; size_t chain_padding = 0; size_t bytes_padding = 0; bool first_request; old_size = talloc_get_size(*poutbuf); /* * old_size == smb_wct means we're pushing the first request in for * libsmb/ */ first_request = (old_size == smb_wct); if (!first_request && ((old_size % 4) != 0)) { /* * Align the wct field of subsequent requests to a 4-byte * boundary */ chain_padding = 4 - (old_size % 4); } /* * After the old request comes the new wct field (1 byte), the vwv's * and the num_bytes field. After at we might need to align the bytes * given to us to "bytes_alignment", increasing the num_bytes value. */ new_size = old_size + chain_padding + 1 + wct * sizeof(uint16_t) + 2; if ((bytes_alignment != 0) && ((new_size % bytes_alignment) != 0)) { bytes_padding = bytes_alignment - (new_size % bytes_alignment); } new_size += bytes_padding + num_bytes; if ((smb_command != SMBwriteX) && (new_size > 0xffff)) { DEBUG(1, ("splice_chain: %u bytes won't fit\n", (unsigned)new_size)); return false; } outbuf = TALLOC_REALLOC_ARRAY(NULL, *poutbuf, uint8_t, new_size); if (outbuf == NULL) { DEBUG(0, ("talloc failed\n")); return false; } *poutbuf = outbuf; if (first_request) { SCVAL(outbuf, smb_com, smb_command); } else { size_t andx_cmd_ofs; if (!find_andx_cmd_ofs(outbuf, &andx_cmd_ofs)) { DEBUG(1, ("invalid command chain\n")); *poutbuf = TALLOC_REALLOC_ARRAY( NULL, *poutbuf, uint8_t, old_size); return false; } if (chain_padding != 0) { memset(outbuf + old_size, 0, chain_padding); old_size += chain_padding; } SCVAL(outbuf, andx_cmd_ofs, smb_command); SSVAL(outbuf, andx_cmd_ofs + 2, old_size - 4); } ofs = old_size; /* * Push the chained request: * * wct field */ SCVAL(outbuf, ofs, wct); ofs += 1; /* * vwv array */ memcpy(outbuf + ofs, vwv, sizeof(uint16_t) * wct); ofs += sizeof(uint16_t) * wct; /* * bcc (byte count) */ SSVAL(outbuf, ofs, num_bytes + bytes_padding); ofs += sizeof(uint16_t); /* * padding */ if (bytes_padding != 0) { memset(outbuf + ofs, 0, bytes_padding); ofs += bytes_padding; } /* * The bytes field */ memcpy(outbuf + ofs, bytes, num_bytes); return true; }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,841
static void smbd_deferred_open_timer(struct event_context *ev, struct timed_event *te, struct timeval _tval, void *private_data) { struct pending_message_list *msg = talloc_get_type(private_data, struct pending_message_list); TALLOC_CTX *mem_ctx = talloc_tos(); uint16_t mid = SVAL(msg->buf.data,smb_mid); uint8_t *inbuf; inbuf = (uint8_t *)talloc_memdup(mem_ctx, msg->buf.data, msg->buf.length); if (inbuf == NULL) { exit_server("smbd_deferred_open_timer: talloc failed\n"); return; } /* We leave this message on the queue so the open code can know this is a retry. */ DEBUG(5,("smbd_deferred_open_timer: trigger mid %u.\n", (unsigned int)mid )); /* Mark the message as processed so this is not * re-processed in error. */ msg->processed = true; process_smb(smbd_server_conn, inbuf, msg->buf.length, 0, msg->seqnum, msg->encrypted, &msg->pcd); /* If it's still there and was processed, remove it. */ msg = get_open_deferred_message(mid); if (msg && msg->processed) { remove_deferred_open_smb_message(mid); } }
DoS
0
static void smbd_deferred_open_timer(struct event_context *ev, struct timed_event *te, struct timeval _tval, void *private_data) { struct pending_message_list *msg = talloc_get_type(private_data, struct pending_message_list); TALLOC_CTX *mem_ctx = talloc_tos(); uint16_t mid = SVAL(msg->buf.data,smb_mid); uint8_t *inbuf; inbuf = (uint8_t *)talloc_memdup(mem_ctx, msg->buf.data, msg->buf.length); if (inbuf == NULL) { exit_server("smbd_deferred_open_timer: talloc failed\n"); return; } /* We leave this message on the queue so the open code can know this is a retry. */ DEBUG(5,("smbd_deferred_open_timer: trigger mid %u.\n", (unsigned int)mid )); /* Mark the message as processed so this is not * re-processed in error. */ msg->processed = true; process_smb(smbd_server_conn, inbuf, msg->buf.length, 0, msg->seqnum, msg->encrypted, &msg->pcd); /* If it's still there and was processed, remove it. */ msg = get_open_deferred_message(mid); if (msg && msg->processed) { remove_deferred_open_smb_message(mid); } }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,842
static void smbd_idle_event_handler(struct event_context *ctx, struct timed_event *te, struct timeval now, void *private_data) { struct idle_event *event = talloc_get_type_abort(private_data, struct idle_event); TALLOC_FREE(event->te); DEBUG(10,("smbd_idle_event_handler: %s %p called\n", event->name, event->te)); if (!event->handler(&now, event->private_data)) { DEBUG(10,("smbd_idle_event_handler: %s %p stopped\n", event->name, event->te)); /* Don't repeat, delete ourselves */ TALLOC_FREE(event); return; } DEBUG(10,("smbd_idle_event_handler: %s %p rescheduled\n", event->name, event->te)); event->te = event_add_timed(ctx, event, timeval_sum(&now, &event->interval), smbd_idle_event_handler, event); /* We can't do much but fail here. */ SMB_ASSERT(event->te != NULL); }
DoS
0
static void smbd_idle_event_handler(struct event_context *ctx, struct timed_event *te, struct timeval now, void *private_data) { struct idle_event *event = talloc_get_type_abort(private_data, struct idle_event); TALLOC_FREE(event->te); DEBUG(10,("smbd_idle_event_handler: %s %p called\n", event->name, event->te)); if (!event->handler(&now, event->private_data)) { DEBUG(10,("smbd_idle_event_handler: %s %p stopped\n", event->name, event->te)); /* Don't repeat, delete ourselves */ TALLOC_FREE(event); return; } DEBUG(10,("smbd_idle_event_handler: %s %p rescheduled\n", event->name, event->te)); event->te = event_add_timed(ctx, event, timeval_sum(&now, &event->interval), smbd_idle_event_handler, event); /* We can't do much but fail here. */ SMB_ASSERT(event->te != NULL); }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,843
void smbd_process(void) { TALLOC_CTX *frame = talloc_stackframe(); char remaddr[INET6_ADDRSTRLEN]; if (lp_maxprotocol() == PROTOCOL_SMB2 && lp_security() != SEC_SHARE) { smbd_server_conn->allow_smb2 = true; } /* Ensure child is set to blocking mode */ set_blocking(smbd_server_fd(),True); set_socket_options(smbd_server_fd(),"SO_KEEPALIVE"); set_socket_options(smbd_server_fd(), lp_socket_options()); /* this is needed so that we get decent entries in smbstatus for port 445 connects */ set_remote_machine_name(get_peer_addr(smbd_server_fd(), remaddr, sizeof(remaddr)), false); reload_services(true); /* * Before the first packet, check the global hosts allow/ hosts deny * parameters before doing any parsing of packets passed to us by the * client. This prevents attacks on our parsing code from hosts not in * the hosts allow list. */ if (!check_access(smbd_server_fd(), lp_hostsallow(-1), lp_hostsdeny(-1))) { char addr[INET6_ADDRSTRLEN]; /* * send a negative session response "not listening on calling * name" */ unsigned char buf[5] = {0x83, 0, 0, 1, 0x81}; DEBUG( 1, ("Connection denied from %s\n", client_addr(get_client_fd(),addr,sizeof(addr)) ) ); (void)srv_send_smb(smbd_server_fd(),(char *)buf, false, 0, false, NULL); exit_server_cleanly("connection denied"); } static_init_rpc; init_modules(); smb_perfcount_init(); if (!init_account_policy()) { exit_server("Could not open account policy tdb.\n"); } if (*lp_rootdir()) { if (chroot(lp_rootdir()) != 0) { DEBUG(0,("Failed to change root to %s\n", lp_rootdir())); exit_server("Failed to chroot()"); } if (chdir("/") == -1) { DEBUG(0,("Failed to chdir to / on chroot to %s\n", lp_rootdir())); exit_server("Failed to chroot()"); } DEBUG(0,("Changed root to %s\n", lp_rootdir())); } if (!srv_init_signing(smbd_server_conn)) { exit_server("Failed to init smb_signing"); } /* Setup oplocks */ if (!init_oplocks(smbd_messaging_context())) exit_server("Failed to init oplocks"); /* Setup aio signal handler. */ initialize_async_io_handler(); /* register our message handlers */ messaging_register(smbd_messaging_context(), NULL, MSG_SMB_FORCE_TDIS, msg_force_tdis); messaging_register(smbd_messaging_context(), NULL, MSG_SMB_RELEASE_IP, msg_release_ip); messaging_register(smbd_messaging_context(), NULL, MSG_SMB_CLOSE_FILE, msg_close_file); /* * Use the default MSG_DEBUG handler to avoid rebroadcasting * MSGs to all child processes */ messaging_deregister(smbd_messaging_context(), MSG_DEBUG, NULL); messaging_register(smbd_messaging_context(), NULL, MSG_DEBUG, debug_message); if ((lp_keepalive() != 0) && !(event_add_idle(smbd_event_context(), NULL, timeval_set(lp_keepalive(), 0), "keepalive", keepalive_fn, NULL))) { DEBUG(0, ("Could not add keepalive event\n")); exit(1); } if (!(event_add_idle(smbd_event_context(), NULL, timeval_set(IDLE_CLOSED_TIMEOUT, 0), "deadtime", deadtime_fn, NULL))) { DEBUG(0, ("Could not add deadtime event\n")); exit(1); } if (!(event_add_idle(smbd_event_context(), NULL, timeval_set(SMBD_SELECT_TIMEOUT, 0), "housekeeping", housekeeping_fn, NULL))) { DEBUG(0, ("Could not add housekeeping event\n")); exit(1); } #ifdef CLUSTER_SUPPORT if (lp_clustering()) { /* * We need to tell ctdb about our client's TCP * connection, so that for failover ctdbd can send * tickle acks, triggering a reconnection by the * client. */ struct sockaddr_storage srv, clnt; if (client_get_tcp_info(&srv, &clnt) == 0) { NTSTATUS status; status = ctdbd_register_ips( messaging_ctdbd_connection(), &srv, &clnt, release_ip, NULL); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("ctdbd_register_ips failed: %s\n", nt_errstr(status))); } } else { DEBUG(0,("Unable to get tcp info for " "CTDB_CONTROL_TCP_CLIENT: %s\n", strerror(errno))); } } #endif smbd_server_conn->nbt.got_session = false; smbd_server_conn->smb1.negprot.max_recv = MIN(lp_maxxmit(),BUFFER_SIZE); smbd_server_conn->smb1.sessions.done_sesssetup = false; smbd_server_conn->smb1.sessions.max_send = BUFFER_SIZE; smbd_server_conn->smb1.sessions.last_session_tag = UID_FIELD_INVALID; /* users from session setup */ smbd_server_conn->smb1.sessions.session_userlist = NULL; /* workgroup from session setup. */ smbd_server_conn->smb1.sessions.session_workgroup = NULL; /* this holds info on user ids that are already validated for this VC */ smbd_server_conn->smb1.sessions.validated_users = NULL; smbd_server_conn->smb1.sessions.next_vuid = VUID_OFFSET; smbd_server_conn->smb1.sessions.num_validated_vuids = 0; #ifdef HAVE_NETGROUP smbd_server_conn->smb1.sessions.my_yp_domain = NULL; #endif conn_init(smbd_server_conn); if (!init_dptrs(smbd_server_conn)) { exit_server("init_dptrs() failed"); } smbd_server_conn->smb1.fde = event_add_fd(smbd_event_context(), smbd_server_conn, smbd_server_fd(), EVENT_FD_READ, smbd_server_connection_handler, smbd_server_conn); if (!smbd_server_conn->smb1.fde) { exit_server("failed to create smbd_server_connection fde"); } TALLOC_FREE(frame); while (True) { NTSTATUS status; frame = talloc_stackframe_pool(8192); errno = 0; status = smbd_server_connection_loop_once(smbd_server_conn); if (!NT_STATUS_EQUAL(status, NT_STATUS_RETRY) && !NT_STATUS_IS_OK(status)) { DEBUG(3, ("smbd_server_connection_loop_once failed: %s," " exiting\n", nt_errstr(status))); break; } TALLOC_FREE(frame); } exit_server_cleanly(NULL); }
DoS
0
void smbd_process(void) { TALLOC_CTX *frame = talloc_stackframe(); char remaddr[INET6_ADDRSTRLEN]; if (lp_maxprotocol() == PROTOCOL_SMB2 && lp_security() != SEC_SHARE) { smbd_server_conn->allow_smb2 = true; } /* Ensure child is set to blocking mode */ set_blocking(smbd_server_fd(),True); set_socket_options(smbd_server_fd(),"SO_KEEPALIVE"); set_socket_options(smbd_server_fd(), lp_socket_options()); /* this is needed so that we get decent entries in smbstatus for port 445 connects */ set_remote_machine_name(get_peer_addr(smbd_server_fd(), remaddr, sizeof(remaddr)), false); reload_services(true); /* * Before the first packet, check the global hosts allow/ hosts deny * parameters before doing any parsing of packets passed to us by the * client. This prevents attacks on our parsing code from hosts not in * the hosts allow list. */ if (!check_access(smbd_server_fd(), lp_hostsallow(-1), lp_hostsdeny(-1))) { char addr[INET6_ADDRSTRLEN]; /* * send a negative session response "not listening on calling * name" */ unsigned char buf[5] = {0x83, 0, 0, 1, 0x81}; DEBUG( 1, ("Connection denied from %s\n", client_addr(get_client_fd(),addr,sizeof(addr)) ) ); (void)srv_send_smb(smbd_server_fd(),(char *)buf, false, 0, false, NULL); exit_server_cleanly("connection denied"); } static_init_rpc; init_modules(); smb_perfcount_init(); if (!init_account_policy()) { exit_server("Could not open account policy tdb.\n"); } if (*lp_rootdir()) { if (chroot(lp_rootdir()) != 0) { DEBUG(0,("Failed to change root to %s\n", lp_rootdir())); exit_server("Failed to chroot()"); } if (chdir("/") == -1) { DEBUG(0,("Failed to chdir to / on chroot to %s\n", lp_rootdir())); exit_server("Failed to chroot()"); } DEBUG(0,("Changed root to %s\n", lp_rootdir())); } if (!srv_init_signing(smbd_server_conn)) { exit_server("Failed to init smb_signing"); } /* Setup oplocks */ if (!init_oplocks(smbd_messaging_context())) exit_server("Failed to init oplocks"); /* Setup aio signal handler. */ initialize_async_io_handler(); /* register our message handlers */ messaging_register(smbd_messaging_context(), NULL, MSG_SMB_FORCE_TDIS, msg_force_tdis); messaging_register(smbd_messaging_context(), NULL, MSG_SMB_RELEASE_IP, msg_release_ip); messaging_register(smbd_messaging_context(), NULL, MSG_SMB_CLOSE_FILE, msg_close_file); /* * Use the default MSG_DEBUG handler to avoid rebroadcasting * MSGs to all child processes */ messaging_deregister(smbd_messaging_context(), MSG_DEBUG, NULL); messaging_register(smbd_messaging_context(), NULL, MSG_DEBUG, debug_message); if ((lp_keepalive() != 0) && !(event_add_idle(smbd_event_context(), NULL, timeval_set(lp_keepalive(), 0), "keepalive", keepalive_fn, NULL))) { DEBUG(0, ("Could not add keepalive event\n")); exit(1); } if (!(event_add_idle(smbd_event_context(), NULL, timeval_set(IDLE_CLOSED_TIMEOUT, 0), "deadtime", deadtime_fn, NULL))) { DEBUG(0, ("Could not add deadtime event\n")); exit(1); } if (!(event_add_idle(smbd_event_context(), NULL, timeval_set(SMBD_SELECT_TIMEOUT, 0), "housekeeping", housekeeping_fn, NULL))) { DEBUG(0, ("Could not add housekeeping event\n")); exit(1); } #ifdef CLUSTER_SUPPORT if (lp_clustering()) { /* * We need to tell ctdb about our client's TCP * connection, so that for failover ctdbd can send * tickle acks, triggering a reconnection by the * client. */ struct sockaddr_storage srv, clnt; if (client_get_tcp_info(&srv, &clnt) == 0) { NTSTATUS status; status = ctdbd_register_ips( messaging_ctdbd_connection(), &srv, &clnt, release_ip, NULL); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("ctdbd_register_ips failed: %s\n", nt_errstr(status))); } } else { DEBUG(0,("Unable to get tcp info for " "CTDB_CONTROL_TCP_CLIENT: %s\n", strerror(errno))); } } #endif smbd_server_conn->nbt.got_session = false; smbd_server_conn->smb1.negprot.max_recv = MIN(lp_maxxmit(),BUFFER_SIZE); smbd_server_conn->smb1.sessions.done_sesssetup = false; smbd_server_conn->smb1.sessions.max_send = BUFFER_SIZE; smbd_server_conn->smb1.sessions.last_session_tag = UID_FIELD_INVALID; /* users from session setup */ smbd_server_conn->smb1.sessions.session_userlist = NULL; /* workgroup from session setup. */ smbd_server_conn->smb1.sessions.session_workgroup = NULL; /* this holds info on user ids that are already validated for this VC */ smbd_server_conn->smb1.sessions.validated_users = NULL; smbd_server_conn->smb1.sessions.next_vuid = VUID_OFFSET; smbd_server_conn->smb1.sessions.num_validated_vuids = 0; #ifdef HAVE_NETGROUP smbd_server_conn->smb1.sessions.my_yp_domain = NULL; #endif conn_init(smbd_server_conn); if (!init_dptrs(smbd_server_conn)) { exit_server("init_dptrs() failed"); } smbd_server_conn->smb1.fde = event_add_fd(smbd_event_context(), smbd_server_conn, smbd_server_fd(), EVENT_FD_READ, smbd_server_connection_handler, smbd_server_conn); if (!smbd_server_conn->smb1.fde) { exit_server("failed to create smbd_server_connection fde"); } TALLOC_FREE(frame); while (True) { NTSTATUS status; frame = talloc_stackframe_pool(8192); errno = 0; status = smbd_server_connection_loop_once(smbd_server_conn); if (!NT_STATUS_EQUAL(status, NT_STATUS_RETRY) && !NT_STATUS_IS_OK(status)) { DEBUG(3, ("smbd_server_connection_loop_once failed: %s," " exiting\n", nt_errstr(status))); break; } TALLOC_FREE(frame); } exit_server_cleanly(NULL); }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,844
static NTSTATUS smbd_server_connection_loop_once(struct smbd_server_connection *conn) { fd_set r_fds, w_fds; int selrtn; struct timeval to; int maxfd = 0; to.tv_sec = SMBD_SELECT_TIMEOUT; to.tv_usec = 0; /* * Setup the select fd sets. */ FD_ZERO(&r_fds); FD_ZERO(&w_fds); /* * Are there any timed events waiting ? If so, ensure we don't * select for longer than it would take to wait for them. */ { struct timeval now; GetTimeOfDay(&now); event_add_to_select_args(smbd_event_context(), &now, &r_fds, &w_fds, &to, &maxfd); } /* Process a signal and timed events now... */ if (run_events(smbd_event_context(), 0, NULL, NULL)) { return NT_STATUS_RETRY; } { int sav; START_PROFILE(smbd_idle); selrtn = sys_select(maxfd+1,&r_fds,&w_fds,NULL,&to); sav = errno; END_PROFILE(smbd_idle); errno = sav; } if (run_events(smbd_event_context(), selrtn, &r_fds, &w_fds)) { return NT_STATUS_RETRY; } /* Check if error */ if (selrtn == -1) { /* something is wrong. Maybe the socket is dead? */ return map_nt_error_from_unix(errno); } /* Did we timeout ? */ if (selrtn == 0) { return NT_STATUS_RETRY; } /* should not be reached */ return NT_STATUS_INTERNAL_ERROR; }
DoS
0
static NTSTATUS smbd_server_connection_loop_once(struct smbd_server_connection *conn) { fd_set r_fds, w_fds; int selrtn; struct timeval to; int maxfd = 0; to.tv_sec = SMBD_SELECT_TIMEOUT; to.tv_usec = 0; /* * Setup the select fd sets. */ FD_ZERO(&r_fds); FD_ZERO(&w_fds); /* * Are there any timed events waiting ? If so, ensure we don't * select for longer than it would take to wait for them. */ { struct timeval now; GetTimeOfDay(&now); event_add_to_select_args(smbd_event_context(), &now, &r_fds, &w_fds, &to, &maxfd); } /* Process a signal and timed events now... */ if (run_events(smbd_event_context(), 0, NULL, NULL)) { return NT_STATUS_RETRY; } { int sav; START_PROFILE(smbd_idle); selrtn = sys_select(maxfd+1,&r_fds,&w_fds,NULL,&to); sav = errno; END_PROFILE(smbd_idle); errno = sav; } if (run_events(smbd_event_context(), selrtn, &r_fds, &w_fds)) { return NT_STATUS_RETRY; } /* Check if error */ if (selrtn == -1) { /* something is wrong. Maybe the socket is dead? */ return map_nt_error_from_unix(errno); } /* Did we timeout ? */ if (selrtn == 0) { return NT_STATUS_RETRY; } /* should not be reached */ return NT_STATUS_INTERNAL_ERROR; }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,845
void smbd_setup_sig_hup_handler(void) { struct tevent_signal *se; se = tevent_add_signal(smbd_event_context(), smbd_event_context(), SIGHUP, 0, smbd_sig_hup_handler, NULL); if (!se) { exit_server("failed to setup SIGHUP handler"); } }
DoS
0
void smbd_setup_sig_hup_handler(void) { struct tevent_signal *se; se = tevent_add_signal(smbd_event_context(), smbd_event_context(), SIGHUP, 0, smbd_sig_hup_handler, NULL); if (!se) { exit_server("failed to setup SIGHUP handler"); } }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,846
void smbd_setup_sig_term_handler(void) { struct tevent_signal *se; se = tevent_add_signal(smbd_event_context(), smbd_event_context(), SIGTERM, 0, smbd_sig_term_handler, NULL); if (!se) { exit_server("failed to setup SIGTERM handler"); } }
DoS
0
void smbd_setup_sig_term_handler(void) { struct tevent_signal *se; se = tevent_add_signal(smbd_event_context(), smbd_event_context(), SIGTERM, 0, smbd_sig_term_handler, NULL); if (!se) { exit_server("failed to setup SIGTERM handler"); } }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,847
static void smbd_sig_hup_handler(struct tevent_context *ev, struct tevent_signal *se, int signum, int count, void *siginfo, void *private_data) { change_to_root_user(); DEBUG(1,("Reloading services after SIGHUP\n")); reload_services(False); }
DoS
0
static void smbd_sig_hup_handler(struct tevent_context *ev, struct tevent_signal *se, int signum, int count, void *siginfo, void *private_data) { change_to_root_user(); DEBUG(1,("Reloading services after SIGHUP\n")); reload_services(False); }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,848
static void smbd_sig_term_handler(struct tevent_context *ev, struct tevent_signal *se, int signum, int count, void *siginfo, void *private_data) { exit_server_cleanly("termination signal"); }
DoS
0
static void smbd_sig_term_handler(struct tevent_context *ev, struct tevent_signal *se, int signum, int count, void *siginfo, void *private_data) { exit_server_cleanly("termination signal"); }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,849
bool srv_send_smb(int fd, char *buffer, bool do_signing, uint32_t seqnum, bool do_encrypt, struct smb_perfcount_data *pcd) { size_t len = 0; size_t nwritten=0; ssize_t ret; char *buf_out = buffer; if (do_signing) { /* Sign the outgoing packet if required. */ srv_calculate_sign_mac(smbd_server_conn, buf_out, seqnum); } if (do_encrypt) { NTSTATUS status = srv_encrypt_buffer(buffer, &buf_out); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("send_smb: SMB encryption failed " "on outgoing packet! Error %s\n", nt_errstr(status) )); goto out; } } len = smb_len(buf_out) + 4; ret = write_data(fd,buf_out+nwritten,len - nwritten); if (ret <= 0) { DEBUG(0,("Error writing %d bytes to client. %d. (%s)\n", (int)len,(int)ret, strerror(errno) )); srv_free_enc_buffer(buf_out); goto out; } SMB_PERFCOUNT_SET_MSGLEN_OUT(pcd, len); srv_free_enc_buffer(buf_out); out: SMB_PERFCOUNT_END(pcd); return true; }
DoS
0
bool srv_send_smb(int fd, char *buffer, bool do_signing, uint32_t seqnum, bool do_encrypt, struct smb_perfcount_data *pcd) { size_t len = 0; size_t nwritten=0; ssize_t ret; char *buf_out = buffer; if (do_signing) { /* Sign the outgoing packet if required. */ srv_calculate_sign_mac(smbd_server_conn, buf_out, seqnum); } if (do_encrypt) { NTSTATUS status = srv_encrypt_buffer(buffer, &buf_out); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("send_smb: SMB encryption failed " "on outgoing packet! Error %s\n", nt_errstr(status) )); goto out; } } len = smb_len(buf_out) + 4; ret = write_data(fd,buf_out+nwritten,len - nwritten); if (ret <= 0) { DEBUG(0,("Error writing %d bytes to client. %d. (%s)\n", (int)len,(int)ret, strerror(errno) )); srv_free_enc_buffer(buf_out); goto out; } SMB_PERFCOUNT_SET_MSGLEN_OUT(pcd, len); srv_free_enc_buffer(buf_out); out: SMB_PERFCOUNT_END(pcd); return true; }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,850
int srv_set_message(char *buf, int num_words, int num_bytes, bool zero) { if (zero && (num_words || num_bytes)) { memset(buf + smb_size,'\0',num_words*2 + num_bytes); } SCVAL(buf,smb_wct,num_words); SSVAL(buf,smb_vwv + num_words*SIZEOFWORD,num_bytes); smb_setlen(buf,(smb_size + num_words*2 + num_bytes - 4)); return (smb_size + num_words*2 + num_bytes); }
DoS
0
int srv_set_message(char *buf, int num_words, int num_bytes, bool zero) { if (zero && (num_words || num_bytes)) { memset(buf + smb_size,'\0',num_words*2 + num_bytes); } SCVAL(buf,smb_wct,num_words); SSVAL(buf,smb_vwv + num_words*SIZEOFWORD,num_bytes); smb_setlen(buf,(smb_size + num_words*2 + num_bytes - 4)); return (smb_size + num_words*2 + num_bytes); }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,851
static connection_struct *switch_message(uint8 type, struct smb_request *req, int size) { int flags; uint16 session_tag; connection_struct *conn = NULL; struct smbd_server_connection *sconn = smbd_server_conn; errno = 0; /* Make sure this is an SMB packet. smb_size contains NetBIOS header * so subtract 4 from it. */ if (!valid_smb_header(req->inbuf) || (size < (smb_size - 4))) { DEBUG(2,("Non-SMB packet of length %d. Terminating server\n", smb_len(req->inbuf))); exit_server_cleanly("Non-SMB packet"); } if (smb_messages[type].fn == NULL) { DEBUG(0,("Unknown message type %d!\n",type)); smb_dump("Unknown", 1, (char *)req->inbuf, size); reply_unknown_new(req, type); return NULL; } flags = smb_messages[type].flags; /* In share mode security we must ignore the vuid. */ session_tag = (lp_security() == SEC_SHARE) ? UID_FIELD_INVALID : req->vuid; conn = req->conn; DEBUG(3,("switch message %s (pid %d) conn 0x%lx\n", smb_fn_name(type), (int)sys_getpid(), (unsigned long)conn)); smb_dump(smb_fn_name(type), 1, (char *)req->inbuf, size); /* Ensure this value is replaced in the incoming packet. */ SSVAL(req->inbuf,smb_uid,session_tag); /* * Ensure the correct username is in current_user_info. This is a * really ugly bugfix for problems with multiple session_setup_and_X's * being done and allowing %U and %G substitutions to work correctly. * There is a reason this code is done here, don't move it unless you * know what you're doing... :-). * JRA. */ if (session_tag != sconn->smb1.sessions.last_session_tag) { user_struct *vuser = NULL; sconn->smb1.sessions.last_session_tag = session_tag; if(session_tag != UID_FIELD_INVALID) { vuser = get_valid_user_struct(sconn, session_tag); if (vuser) { set_current_user_info( vuser->server_info->sanitized_username, vuser->server_info->unix_name, pdb_get_domain(vuser->server_info ->sam_account)); } } } /* Does this call need to be run as the connected user? */ if (flags & AS_USER) { /* Does this call need a valid tree connection? */ if (!conn) { /* * Amazingly, the error code depends on the command * (from Samba4). */ if (type == SMBntcreateX) { reply_nterror(req, NT_STATUS_INVALID_HANDLE); } else { reply_nterror(req, NT_STATUS_NETWORK_NAME_DELETED); } return NULL; } if (!change_to_user(conn,session_tag)) { DEBUG(0, ("Error: Could not change to user. Removing " "deferred open, mid=%d.\n", req->mid)); reply_force_doserror(req, ERRSRV, ERRbaduid); return conn; } /* All NEED_WRITE and CAN_IPC flags must also have AS_USER. */ /* Does it need write permission? */ if ((flags & NEED_WRITE) && !CAN_WRITE(conn)) { reply_nterror(req, NT_STATUS_MEDIA_WRITE_PROTECTED); return conn; } /* IPC services are limited */ if (IS_IPC(conn) && !(flags & CAN_IPC)) { reply_nterror(req, NT_STATUS_ACCESS_DENIED); return conn; } } else { /* This call needs to be run as root */ change_to_root_user(); } /* load service specific parameters */ if (conn) { if (req->encrypted) { conn->encrypted_tid = true; /* encrypted required from now on. */ conn->encrypt_level = Required; } else if (ENCRYPTION_REQUIRED(conn)) { if (req->cmd != SMBtrans2 && req->cmd != SMBtranss2) { exit_server_cleanly("encryption required " "on connection"); return conn; } } if (!set_current_service(conn,SVAL(req->inbuf,smb_flg), (flags & (AS_USER|DO_CHDIR) ?True:False))) { reply_nterror(req, NT_STATUS_ACCESS_DENIED); return conn; } conn->num_smb_operations++; } /* does this protocol need to be run as guest? */ if ((flags & AS_GUEST) && (!change_to_guest() || !check_access(smbd_server_fd(), lp_hostsallow(-1), lp_hostsdeny(-1)))) { reply_nterror(req, NT_STATUS_ACCESS_DENIED); return conn; } smb_messages[type].fn(req); return req->conn; }
DoS
0
static connection_struct *switch_message(uint8 type, struct smb_request *req, int size) { int flags; uint16 session_tag; connection_struct *conn = NULL; struct smbd_server_connection *sconn = smbd_server_conn; errno = 0; /* Make sure this is an SMB packet. smb_size contains NetBIOS header * so subtract 4 from it. */ if (!valid_smb_header(req->inbuf) || (size < (smb_size - 4))) { DEBUG(2,("Non-SMB packet of length %d. Terminating server\n", smb_len(req->inbuf))); exit_server_cleanly("Non-SMB packet"); } if (smb_messages[type].fn == NULL) { DEBUG(0,("Unknown message type %d!\n",type)); smb_dump("Unknown", 1, (char *)req->inbuf, size); reply_unknown_new(req, type); return NULL; } flags = smb_messages[type].flags; /* In share mode security we must ignore the vuid. */ session_tag = (lp_security() == SEC_SHARE) ? UID_FIELD_INVALID : req->vuid; conn = req->conn; DEBUG(3,("switch message %s (pid %d) conn 0x%lx\n", smb_fn_name(type), (int)sys_getpid(), (unsigned long)conn)); smb_dump(smb_fn_name(type), 1, (char *)req->inbuf, size); /* Ensure this value is replaced in the incoming packet. */ SSVAL(req->inbuf,smb_uid,session_tag); /* * Ensure the correct username is in current_user_info. This is a * really ugly bugfix for problems with multiple session_setup_and_X's * being done and allowing %U and %G substitutions to work correctly. * There is a reason this code is done here, don't move it unless you * know what you're doing... :-). * JRA. */ if (session_tag != sconn->smb1.sessions.last_session_tag) { user_struct *vuser = NULL; sconn->smb1.sessions.last_session_tag = session_tag; if(session_tag != UID_FIELD_INVALID) { vuser = get_valid_user_struct(sconn, session_tag); if (vuser) { set_current_user_info( vuser->server_info->sanitized_username, vuser->server_info->unix_name, pdb_get_domain(vuser->server_info ->sam_account)); } } } /* Does this call need to be run as the connected user? */ if (flags & AS_USER) { /* Does this call need a valid tree connection? */ if (!conn) { /* * Amazingly, the error code depends on the command * (from Samba4). */ if (type == SMBntcreateX) { reply_nterror(req, NT_STATUS_INVALID_HANDLE); } else { reply_nterror(req, NT_STATUS_NETWORK_NAME_DELETED); } return NULL; } if (!change_to_user(conn,session_tag)) { DEBUG(0, ("Error: Could not change to user. Removing " "deferred open, mid=%d.\n", req->mid)); reply_force_doserror(req, ERRSRV, ERRbaduid); return conn; } /* All NEED_WRITE and CAN_IPC flags must also have AS_USER. */ /* Does it need write permission? */ if ((flags & NEED_WRITE) && !CAN_WRITE(conn)) { reply_nterror(req, NT_STATUS_MEDIA_WRITE_PROTECTED); return conn; } /* IPC services are limited */ if (IS_IPC(conn) && !(flags & CAN_IPC)) { reply_nterror(req, NT_STATUS_ACCESS_DENIED); return conn; } } else { /* This call needs to be run as root */ change_to_root_user(); } /* load service specific parameters */ if (conn) { if (req->encrypted) { conn->encrypted_tid = true; /* encrypted required from now on. */ conn->encrypt_level = Required; } else if (ENCRYPTION_REQUIRED(conn)) { if (req->cmd != SMBtrans2 && req->cmd != SMBtranss2) { exit_server_cleanly("encryption required " "on connection"); return conn; } } if (!set_current_service(conn,SVAL(req->inbuf,smb_flg), (flags & (AS_USER|DO_CHDIR) ?True:False))) { reply_nterror(req, NT_STATUS_ACCESS_DENIED); return conn; } conn->num_smb_operations++; } /* does this protocol need to be run as guest? */ if ((flags & AS_GUEST) && (!change_to_guest() || !check_access(smbd_server_fd(), lp_hostsallow(-1), lp_hostsdeny(-1)))) { reply_nterror(req, NT_STATUS_ACCESS_DENIED); return conn; } smb_messages[type].fn(req); return req->conn; }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,852
static bool valid_packet_size(size_t len) { /* * A WRITEX with CAP_LARGE_WRITEX can be 64k worth of data plus 65 bytes * of header. Don't print the error if this fits.... JRA. */ if (len > (BUFFER_SIZE + LARGE_WRITEX_HDR_SIZE)) { DEBUG(0,("Invalid packet length! (%lu bytes).\n", (unsigned long)len)); return false; } return true; }
DoS
0
static bool valid_packet_size(size_t len) { /* * A WRITEX with CAP_LARGE_WRITEX can be 64k worth of data plus 65 bytes * of header. Don't print the error if this fits.... JRA. */ if (len > (BUFFER_SIZE + LARGE_WRITEX_HDR_SIZE)) { DEBUG(0,("Invalid packet length! (%lu bytes).\n", (unsigned long)len)); return false; } return true; }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,853
static bool valid_smb_header(const uint8_t *inbuf) { if (is_encrypted_packet(inbuf)) { return true; } /* * This used to be (strncmp(smb_base(inbuf),"\377SMB",4) == 0) * but it just looks weird to call strncmp for this one. */ return (IVAL(smb_base(inbuf), 0) == 0x424D53FF); }
DoS
0
static bool valid_smb_header(const uint8_t *inbuf) { if (is_encrypted_packet(inbuf)) { return true; } /* * This used to be (strncmp(smb_base(inbuf),"\377SMB",4) == 0) * but it just looks weird to call strncmp for this one. */ return (IVAL(smb_base(inbuf), 0) == 0x424D53FF); }
@@ -1810,6 +1810,15 @@ void chain_reply(struct smb_request *req) */ if ((req->wct < 2) || (CVAL(req->outbuf, smb_wct) < 2)) { + if (req->chain_outbuf == NULL) { + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, + smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + smb_panic("talloc failed"); + } + } + req->outbuf = NULL; goto error; } @@ -1837,7 +1846,7 @@ void chain_reply(struct smb_request *req) req->chain_outbuf = TALLOC_REALLOC_ARRAY( req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); if (req->chain_outbuf == NULL) { - goto error; + smb_panic("talloc failed"); } req->outbuf = NULL; } else {
null
null
null
8,854
static diy_fp_t cached_power(int k) { diy_fp_t res; int index = 343 + k; res.f = powers_ten[index]; res.e = powers_ten_e[index]; return res; }
Overflow
0
static diy_fp_t cached_power(int k) { diy_fp_t res; int index = 343 + k; res.f = powers_ten[index]; res.e = powers_ten_e[index]; return res; }
@@ -709,16 +709,20 @@ js_strtod(const char *string, char **endPtr) * fraction. */ - if (exp < 0) { + if (exp < -maxExponent) { + exp = maxExponent; + expSign = TRUE; + errno = ERANGE; + } else if (exp > maxExponent) { + exp = maxExponent; + expSign = FALSE; + errno = ERANGE; + } else if (exp < 0) { expSign = TRUE; exp = -exp; } else { expSign = FALSE; } - if (exp > maxExponent) { - exp = maxExponent; - errno = ERANGE; - } dblExp = 1.0; for (d = powersOf10; exp != 0; exp >>= 1, d += 1) { if (exp & 01) {
CWE-190
null
null
8,855
static void digit_gen(diy_fp_t Mp, diy_fp_t delta, char* buffer, int* len, int* K) { uint32_t div, p1; uint64_t p2; int d,kappa; diy_fp_t one; one.f = ((uint64_t) 1) << -Mp.e; one.e = Mp.e; p1 = Mp.f >> -one.e; p2 = Mp.f & (one.f - 1); *len = 0; kappa = 3; div = TEN2; while (kappa > 0) { d = p1 / div; if (d || *len) buffer[(*len)++] = '0' + d; p1 %= div; kappa--; div /= 10; if ((((uint64_t)p1)<<-one.e)+p2 <= delta.f) { *K += kappa; return; } } do { p2 *= 10; d = p2 >> -one.e; if (d || *len) buffer[(*len)++] = '0' + d; p2 &= one.f - 1; kappa--; delta.f *= 10; } while (p2 > delta.f); *K += kappa; }
Overflow
0
static void digit_gen(diy_fp_t Mp, diy_fp_t delta, char* buffer, int* len, int* K) { uint32_t div, p1; uint64_t p2; int d,kappa; diy_fp_t one; one.f = ((uint64_t) 1) << -Mp.e; one.e = Mp.e; p1 = Mp.f >> -one.e; p2 = Mp.f & (one.f - 1); *len = 0; kappa = 3; div = TEN2; while (kappa > 0) { d = p1 / div; if (d || *len) buffer[(*len)++] = '0' + d; p1 %= div; kappa--; div /= 10; if ((((uint64_t)p1)<<-one.e)+p2 <= delta.f) { *K += kappa; return; } } do { p2 *= 10; d = p2 >> -one.e; if (d || *len) buffer[(*len)++] = '0' + d; p2 &= one.f - 1; kappa--; delta.f *= 10; } while (p2 > delta.f); *K += kappa; }
@@ -709,16 +709,20 @@ js_strtod(const char *string, char **endPtr) * fraction. */ - if (exp < 0) { + if (exp < -maxExponent) { + exp = maxExponent; + expSign = TRUE; + errno = ERANGE; + } else if (exp > maxExponent) { + exp = maxExponent; + expSign = FALSE; + errno = ERANGE; + } else if (exp < 0) { expSign = TRUE; exp = -exp; } else { expSign = FALSE; } - if (exp > maxExponent) { - exp = maxExponent; - errno = ERANGE; - } dblExp = 1.0; for (d = powersOf10; exp != 0; exp >>= 1, d += 1) { if (exp & 01) {
CWE-190
null
null
8,856
js_fmtexp(char *p, int e) { char se[9]; int i; *p++ = 'e'; if(e < 0) { *p++ = '-'; e = -e; } else *p++ = '+'; i = 0; while(e) { se[i++] = e % 10 + '0'; e /= 10; } while(i < 1) se[i++] = '0'; while(i > 0) *p++ = se[--i]; *p++ = '\0'; }
Overflow
0
js_fmtexp(char *p, int e) { char se[9]; int i; *p++ = 'e'; if(e < 0) { *p++ = '-'; e = -e; } else *p++ = '+'; i = 0; while(e) { se[i++] = e % 10 + '0'; e /= 10; } while(i < 1) se[i++] = '0'; while(i > 0) *p++ = se[--i]; *p++ = '\0'; }
@@ -709,16 +709,20 @@ js_strtod(const char *string, char **endPtr) * fraction. */ - if (exp < 0) { + if (exp < -maxExponent) { + exp = maxExponent; + expSign = TRUE; + errno = ERANGE; + } else if (exp > maxExponent) { + exp = maxExponent; + expSign = FALSE; + errno = ERANGE; + } else if (exp < 0) { expSign = TRUE; exp = -exp; } else { expSign = FALSE; } - if (exp > maxExponent) { - exp = maxExponent; - errno = ERANGE; - } dblExp = 1.0; for (d = powersOf10; exp != 0; exp >>= 1, d += 1) { if (exp & 01) {
CWE-190
null
null
8,857
js_grisu2(double v, char *buffer, int *K) { int length, mk; diy_fp_t w_m, w_p, c_mk, Wp, Wm, delta; int q = 64, alpha = -59, gamma = -56; normalized_boundaries(v, &w_m, &w_p); mk = k_comp(w_p.e + q, alpha, gamma); c_mk = cached_power(mk); Wp = multiply(w_p, c_mk); Wm = multiply(w_m, c_mk); Wm.f++; Wp.f--; delta = minus(Wp, Wm); *K = -mk; digit_gen(Wp, delta, buffer, &length, K); return length; }
Overflow
0
js_grisu2(double v, char *buffer, int *K) { int length, mk; diy_fp_t w_m, w_p, c_mk, Wp, Wm, delta; int q = 64, alpha = -59, gamma = -56; normalized_boundaries(v, &w_m, &w_p); mk = k_comp(w_p.e + q, alpha, gamma); c_mk = cached_power(mk); Wp = multiply(w_p, c_mk); Wm = multiply(w_m, c_mk); Wm.f++; Wp.f--; delta = minus(Wp, Wm); *K = -mk; digit_gen(Wp, delta, buffer, &length, K); return length; }
@@ -709,16 +709,20 @@ js_strtod(const char *string, char **endPtr) * fraction. */ - if (exp < 0) { + if (exp < -maxExponent) { + exp = maxExponent; + expSign = TRUE; + errno = ERANGE; + } else if (exp > maxExponent) { + exp = maxExponent; + expSign = FALSE; + errno = ERANGE; + } else if (exp < 0) { expSign = TRUE; exp = -exp; } else { expSign = FALSE; } - if (exp > maxExponent) { - exp = maxExponent; - errno = ERANGE; - } dblExp = 1.0; for (d = powersOf10; exp != 0; exp >>= 1, d += 1) { if (exp & 01) {
CWE-190
null
null
8,858
PHP_GINIT_FUNCTION(phar) /* {{{ */ { #if defined(COMPILE_DL_PHAR) && defined(ZTS) ZEND_TSRMLS_CACHE_UPDATE(); #endif phar_mime_type mime; memset(phar_globals, 0, sizeof(zend_phar_globals)); phar_globals->readonly = 1; zend_hash_init(&phar_globals->mime_types, 0, NULL, mime_type_dtor, 1); #define PHAR_SET_MIME(mimetype, ret, fileext) \ mime.mime = mimetype; \ mime.len = sizeof((mimetype))+1; \ mime.type = ret; \ zend_hash_str_add_mem(&phar_globals->mime_types, fileext, sizeof(fileext)-1, (void *)&mime, sizeof(phar_mime_type)); \ PHAR_SET_MIME("text/html", PHAR_MIME_PHPS, "phps") PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "c") PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "cc") PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "cpp") PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "c++") PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "dtd") PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "h") PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "log") PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "rng") PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "txt") PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "xsd") PHAR_SET_MIME("", PHAR_MIME_PHP, "php") PHAR_SET_MIME("", PHAR_MIME_PHP, "inc") PHAR_SET_MIME("video/avi", PHAR_MIME_OTHER, "avi") PHAR_SET_MIME("image/bmp", PHAR_MIME_OTHER, "bmp") PHAR_SET_MIME("text/css", PHAR_MIME_OTHER, "css") PHAR_SET_MIME("image/gif", PHAR_MIME_OTHER, "gif") PHAR_SET_MIME("text/html", PHAR_MIME_OTHER, "htm") PHAR_SET_MIME("text/html", PHAR_MIME_OTHER, "html") PHAR_SET_MIME("text/html", PHAR_MIME_OTHER, "htmls") PHAR_SET_MIME("image/x-ico", PHAR_MIME_OTHER, "ico") PHAR_SET_MIME("image/jpeg", PHAR_MIME_OTHER, "jpe") PHAR_SET_MIME("image/jpeg", PHAR_MIME_OTHER, "jpg") PHAR_SET_MIME("image/jpeg", PHAR_MIME_OTHER, "jpeg") PHAR_SET_MIME("application/x-javascript", PHAR_MIME_OTHER, "js") PHAR_SET_MIME("audio/midi", PHAR_MIME_OTHER, "midi") PHAR_SET_MIME("audio/midi", PHAR_MIME_OTHER, "mid") PHAR_SET_MIME("audio/mod", PHAR_MIME_OTHER, "mod") PHAR_SET_MIME("movie/quicktime", PHAR_MIME_OTHER, "mov") PHAR_SET_MIME("audio/mp3", PHAR_MIME_OTHER, "mp3") PHAR_SET_MIME("video/mpeg", PHAR_MIME_OTHER, "mpg") PHAR_SET_MIME("video/mpeg", PHAR_MIME_OTHER, "mpeg") PHAR_SET_MIME("application/pdf", PHAR_MIME_OTHER, "pdf") PHAR_SET_MIME("image/png", PHAR_MIME_OTHER, "png") PHAR_SET_MIME("application/shockwave-flash", PHAR_MIME_OTHER, "swf") PHAR_SET_MIME("image/tiff", PHAR_MIME_OTHER, "tif") PHAR_SET_MIME("image/tiff", PHAR_MIME_OTHER, "tiff") PHAR_SET_MIME("audio/wav", PHAR_MIME_OTHER, "wav") PHAR_SET_MIME("image/xbm", PHAR_MIME_OTHER, "xbm") PHAR_SET_MIME("text/xml", PHAR_MIME_OTHER, "xml") phar_restore_orig_functions(); } /* }}} */
Exec Code
0
PHP_GINIT_FUNCTION(phar) /* {{{ */ { #if defined(COMPILE_DL_PHAR) && defined(ZTS) ZEND_TSRMLS_CACHE_UPDATE(); #endif phar_mime_type mime; memset(phar_globals, 0, sizeof(zend_phar_globals)); phar_globals->readonly = 1; zend_hash_init(&phar_globals->mime_types, 0, NULL, mime_type_dtor, 1); #define PHAR_SET_MIME(mimetype, ret, fileext) \ mime.mime = mimetype; \ mime.len = sizeof((mimetype))+1; \ mime.type = ret; \ zend_hash_str_add_mem(&phar_globals->mime_types, fileext, sizeof(fileext)-1, (void *)&mime, sizeof(phar_mime_type)); \ PHAR_SET_MIME("text/html", PHAR_MIME_PHPS, "phps") PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "c") PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "cc") PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "cpp") PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "c++") PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "dtd") PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "h") PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "log") PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "rng") PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "txt") PHAR_SET_MIME("text/plain", PHAR_MIME_OTHER, "xsd") PHAR_SET_MIME("", PHAR_MIME_PHP, "php") PHAR_SET_MIME("", PHAR_MIME_PHP, "inc") PHAR_SET_MIME("video/avi", PHAR_MIME_OTHER, "avi") PHAR_SET_MIME("image/bmp", PHAR_MIME_OTHER, "bmp") PHAR_SET_MIME("text/css", PHAR_MIME_OTHER, "css") PHAR_SET_MIME("image/gif", PHAR_MIME_OTHER, "gif") PHAR_SET_MIME("text/html", PHAR_MIME_OTHER, "htm") PHAR_SET_MIME("text/html", PHAR_MIME_OTHER, "html") PHAR_SET_MIME("text/html", PHAR_MIME_OTHER, "htmls") PHAR_SET_MIME("image/x-ico", PHAR_MIME_OTHER, "ico") PHAR_SET_MIME("image/jpeg", PHAR_MIME_OTHER, "jpe") PHAR_SET_MIME("image/jpeg", PHAR_MIME_OTHER, "jpg") PHAR_SET_MIME("image/jpeg", PHAR_MIME_OTHER, "jpeg") PHAR_SET_MIME("application/x-javascript", PHAR_MIME_OTHER, "js") PHAR_SET_MIME("audio/midi", PHAR_MIME_OTHER, "midi") PHAR_SET_MIME("audio/midi", PHAR_MIME_OTHER, "mid") PHAR_SET_MIME("audio/mod", PHAR_MIME_OTHER, "mod") PHAR_SET_MIME("movie/quicktime", PHAR_MIME_OTHER, "mov") PHAR_SET_MIME("audio/mp3", PHAR_MIME_OTHER, "mp3") PHAR_SET_MIME("video/mpeg", PHAR_MIME_OTHER, "mpg") PHAR_SET_MIME("video/mpeg", PHAR_MIME_OTHER, "mpeg") PHAR_SET_MIME("application/pdf", PHAR_MIME_OTHER, "pdf") PHAR_SET_MIME("image/png", PHAR_MIME_OTHER, "png") PHAR_SET_MIME("application/shockwave-flash", PHAR_MIME_OTHER, "swf") PHAR_SET_MIME("image/tiff", PHAR_MIME_OTHER, "tif") PHAR_SET_MIME("image/tiff", PHAR_MIME_OTHER, "tiff") PHAR_SET_MIME("audio/wav", PHAR_MIME_OTHER, "wav") PHAR_SET_MIME("image/xbm", PHAR_MIME_OTHER, "xbm") PHAR_SET_MIME("text/xml", PHAR_MIME_OTHER, "xml") phar_restore_orig_functions(); } /* }}} */
@@ -2196,6 +2196,10 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a #endif int ext_len; + if (CHECK_NULL_PATH(filename, filename_len)) { + return FAILURE; + } + if (!strncasecmp(filename, "phar://", 7)) { filename += 7; filename_len -= 7;
CWE-20
null
null
8,859
PHP_MINFO_FUNCTION(phar) /* {{{ */ { phar_request_initialize(); php_info_print_table_start(); php_info_print_table_header(2, "Phar: PHP Archive support", "enabled"); php_info_print_table_row(2, "Phar EXT version", PHP_PHAR_VERSION); php_info_print_table_row(2, "Phar API version", PHP_PHAR_API_VERSION); php_info_print_table_row(2, "SVN revision", "$Id$"); php_info_print_table_row(2, "Phar-based phar archives", "enabled"); php_info_print_table_row(2, "Tar-based phar archives", "enabled"); php_info_print_table_row(2, "ZIP-based phar archives", "enabled"); if (PHAR_G(has_zlib)) { php_info_print_table_row(2, "gzip compression", "enabled"); } else { php_info_print_table_row(2, "gzip compression", "disabled (install ext/zlib)"); } if (PHAR_G(has_bz2)) { php_info_print_table_row(2, "bzip2 compression", "enabled"); } else { php_info_print_table_row(2, "bzip2 compression", "disabled (install pecl/bz2)"); } #ifdef PHAR_HAVE_OPENSSL php_info_print_table_row(2, "Native OpenSSL support", "enabled"); #else if (zend_hash_str_exists(&module_registry, "openssl", sizeof("openssl")-1)) { php_info_print_table_row(2, "OpenSSL support", "enabled"); } else { php_info_print_table_row(2, "OpenSSL support", "disabled (install ext/openssl)"); } #endif php_info_print_table_end(); php_info_print_box_start(0); PUTS("Phar based on pear/PHP_Archive, original concept by Davey Shafik."); PUTS(!sapi_module.phpinfo_as_text?"<br />":"\n"); PUTS("Phar fully realized by Gregory Beaver and Marcus Boerger."); PUTS(!sapi_module.phpinfo_as_text?"<br />":"\n"); PUTS("Portions of tar implementation Copyright (c) 2003-2009 Tim Kientzle."); php_info_print_box_end(); DISPLAY_INI_ENTRIES(); } /* }}} */
Exec Code
0
PHP_MINFO_FUNCTION(phar) /* {{{ */ { phar_request_initialize(); php_info_print_table_start(); php_info_print_table_header(2, "Phar: PHP Archive support", "enabled"); php_info_print_table_row(2, "Phar EXT version", PHP_PHAR_VERSION); php_info_print_table_row(2, "Phar API version", PHP_PHAR_API_VERSION); php_info_print_table_row(2, "SVN revision", "$Id$"); php_info_print_table_row(2, "Phar-based phar archives", "enabled"); php_info_print_table_row(2, "Tar-based phar archives", "enabled"); php_info_print_table_row(2, "ZIP-based phar archives", "enabled"); if (PHAR_G(has_zlib)) { php_info_print_table_row(2, "gzip compression", "enabled"); } else { php_info_print_table_row(2, "gzip compression", "disabled (install ext/zlib)"); } if (PHAR_G(has_bz2)) { php_info_print_table_row(2, "bzip2 compression", "enabled"); } else { php_info_print_table_row(2, "bzip2 compression", "disabled (install pecl/bz2)"); } #ifdef PHAR_HAVE_OPENSSL php_info_print_table_row(2, "Native OpenSSL support", "enabled"); #else if (zend_hash_str_exists(&module_registry, "openssl", sizeof("openssl")-1)) { php_info_print_table_row(2, "OpenSSL support", "enabled"); } else { php_info_print_table_row(2, "OpenSSL support", "disabled (install ext/openssl)"); } #endif php_info_print_table_end(); php_info_print_box_start(0); PUTS("Phar based on pear/PHP_Archive, original concept by Davey Shafik."); PUTS(!sapi_module.phpinfo_as_text?"<br />":"\n"); PUTS("Phar fully realized by Gregory Beaver and Marcus Boerger."); PUTS(!sapi_module.phpinfo_as_text?"<br />":"\n"); PUTS("Portions of tar implementation Copyright (c) 2003-2009 Tim Kientzle."); php_info_print_box_end(); DISPLAY_INI_ENTRIES(); } /* }}} */
@@ -2196,6 +2196,10 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a #endif int ext_len; + if (CHECK_NULL_PATH(filename, filename_len)) { + return FAILURE; + } + if (!strncasecmp(filename, "phar://", 7)) { filename += 7; filename_len -= 7;
CWE-20
null
null
8,860
PHP_MINIT_FUNCTION(phar) /* {{{ */ { REGISTER_INI_ENTRIES(); phar_orig_compile_file = zend_compile_file; zend_compile_file = phar_compile_file; phar_save_resolve_path = zend_resolve_path; zend_resolve_path = phar_resolve_path; phar_object_init(); phar_intercept_functions_init(); phar_save_orig_functions(); return php_register_url_stream_wrapper("phar", &php_stream_phar_wrapper); } /* }}} */
Exec Code
0
PHP_MINIT_FUNCTION(phar) /* {{{ */ { REGISTER_INI_ENTRIES(); phar_orig_compile_file = zend_compile_file; zend_compile_file = phar_compile_file; phar_save_resolve_path = zend_resolve_path; zend_resolve_path = phar_resolve_path; phar_object_init(); phar_intercept_functions_init(); phar_save_orig_functions(); return php_register_url_stream_wrapper("phar", &php_stream_phar_wrapper); } /* }}} */
@@ -2196,6 +2196,10 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a #endif int ext_len; + if (CHECK_NULL_PATH(filename, filename_len)) { + return FAILURE; + } + if (!strncasecmp(filename, "phar://", 7)) { filename += 7; filename_len -= 7;
CWE-20
null
null
8,861
PHP_MSHUTDOWN_FUNCTION(phar) /* {{{ */ { php_unregister_url_stream_wrapper("phar"); phar_intercept_functions_shutdown(); if (zend_compile_file == phar_compile_file) { zend_compile_file = phar_orig_compile_file; } if (PHAR_G(manifest_cached)) { zend_hash_destroy(&(cached_phars)); zend_hash_destroy(&(cached_alias)); } return SUCCESS; } /* }}} */
Exec Code
0
PHP_MSHUTDOWN_FUNCTION(phar) /* {{{ */ { php_unregister_url_stream_wrapper("phar"); phar_intercept_functions_shutdown(); if (zend_compile_file == phar_compile_file) { zend_compile_file = phar_orig_compile_file; } if (PHAR_G(manifest_cached)) { zend_hash_destroy(&(cached_phars)); zend_hash_destroy(&(cached_alias)); } return SUCCESS; } /* }}} */
@@ -2196,6 +2196,10 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a #endif int ext_len; + if (CHECK_NULL_PATH(filename, filename_len)) { + return FAILURE; + } + if (!strncasecmp(filename, "phar://", 7)) { filename += 7; filename_len -= 7;
CWE-20
null
null
8,862
PHP_RSHUTDOWN_FUNCTION(phar) /* {{{ */ { int i; PHAR_G(request_ends) = 1; if (PHAR_G(request_init)) { phar_release_functions(); zend_hash_destroy(&(PHAR_G(phar_alias_map))); PHAR_G(phar_alias_map.u.flags) = 0; zend_hash_destroy(&(PHAR_G(phar_fname_map))); PHAR_G(phar_fname_map.u.flags) = 0; zend_hash_destroy(&(PHAR_G(phar_persist_map))); PHAR_G(phar_persist_map.u.flags) = 0; PHAR_G(phar_SERVER_mung_list) = 0; if (PHAR_G(cached_fp)) { for (i = 0; i < zend_hash_num_elements(&cached_phars); ++i) { if (PHAR_G(cached_fp)[i].fp) { php_stream_close(PHAR_G(cached_fp)[i].fp); } if (PHAR_G(cached_fp)[i].ufp) { php_stream_close(PHAR_G(cached_fp)[i].ufp); } efree(PHAR_G(cached_fp)[i].manifest); } efree(PHAR_G(cached_fp)); PHAR_G(cached_fp) = 0; } PHAR_G(request_init) = 0; if (PHAR_G(cwd)) { efree(PHAR_G(cwd)); } PHAR_G(cwd) = NULL; PHAR_G(cwd_len) = 0; PHAR_G(cwd_init) = 0; } PHAR_G(request_done) = 1; return SUCCESS; } /* }}} */
Exec Code
0
PHP_RSHUTDOWN_FUNCTION(phar) /* {{{ */ { int i; PHAR_G(request_ends) = 1; if (PHAR_G(request_init)) { phar_release_functions(); zend_hash_destroy(&(PHAR_G(phar_alias_map))); PHAR_G(phar_alias_map.u.flags) = 0; zend_hash_destroy(&(PHAR_G(phar_fname_map))); PHAR_G(phar_fname_map.u.flags) = 0; zend_hash_destroy(&(PHAR_G(phar_persist_map))); PHAR_G(phar_persist_map.u.flags) = 0; PHAR_G(phar_SERVER_mung_list) = 0; if (PHAR_G(cached_fp)) { for (i = 0; i < zend_hash_num_elements(&cached_phars); ++i) { if (PHAR_G(cached_fp)[i].fp) { php_stream_close(PHAR_G(cached_fp)[i].fp); } if (PHAR_G(cached_fp)[i].ufp) { php_stream_close(PHAR_G(cached_fp)[i].ufp); } efree(PHAR_G(cached_fp)[i].manifest); } efree(PHAR_G(cached_fp)); PHAR_G(cached_fp) = 0; } PHAR_G(request_init) = 0; if (PHAR_G(cwd)) { efree(PHAR_G(cwd)); } PHAR_G(cwd) = NULL; PHAR_G(cwd_len) = 0; PHAR_G(cwd_init) = 0; } PHAR_G(request_done) = 1; return SUCCESS; } /* }}} */
@@ -2196,6 +2196,10 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a #endif int ext_len; + if (CHECK_NULL_PATH(filename, filename_len)) { + return FAILURE; + } + if (!strncasecmp(filename, "phar://", 7)) { filename += 7; filename_len -= 7;
CWE-20
null
null
8,863
ZEND_INI_MH(phar_ini_modify_handler) /* {{{ */ { zend_bool old, ini; if (ZSTR_LEN(entry->name) == sizeof("phar.readonly")-1) { old = PHAR_G(readonly_orig); } else { old = PHAR_G(require_hash_orig); } if (ZSTR_LEN(new_value) == 2 && !strcasecmp("on", ZSTR_VAL(new_value))) { ini = (zend_bool) 1; } else if (ZSTR_LEN(new_value) == 3 && !strcasecmp("yes", ZSTR_VAL(new_value))) { ini = (zend_bool) 1; } else if (ZSTR_LEN(new_value) == 4 && !strcasecmp("true", ZSTR_VAL(new_value))) { ini = (zend_bool) 1; } else { ini = (zend_bool) atoi(ZSTR_VAL(new_value)); } /* do not allow unsetting in runtime */ if (stage == ZEND_INI_STAGE_STARTUP) { if (ZSTR_LEN(entry->name) == sizeof("phar.readonly")-1) { PHAR_G(readonly_orig) = ini; } else { PHAR_G(require_hash_orig) = ini; } } else if (old && !ini) { return FAILURE; } if (ZSTR_LEN(entry->name) == sizeof("phar.readonly")-1) { PHAR_G(readonly) = ini; if (PHAR_G(request_init) && PHAR_G(phar_fname_map.u.flags)) { zend_hash_apply_with_argument(&(PHAR_G(phar_fname_map)), phar_set_writeable_bit, (void *)&ini); } } else { PHAR_G(require_hash) = ini; } return SUCCESS; } /* }}}*/
Exec Code
0
ZEND_INI_MH(phar_ini_modify_handler) /* {{{ */ { zend_bool old, ini; if (ZSTR_LEN(entry->name) == sizeof("phar.readonly")-1) { old = PHAR_G(readonly_orig); } else { old = PHAR_G(require_hash_orig); } if (ZSTR_LEN(new_value) == 2 && !strcasecmp("on", ZSTR_VAL(new_value))) { ini = (zend_bool) 1; } else if (ZSTR_LEN(new_value) == 3 && !strcasecmp("yes", ZSTR_VAL(new_value))) { ini = (zend_bool) 1; } else if (ZSTR_LEN(new_value) == 4 && !strcasecmp("true", ZSTR_VAL(new_value))) { ini = (zend_bool) 1; } else { ini = (zend_bool) atoi(ZSTR_VAL(new_value)); } /* do not allow unsetting in runtime */ if (stage == ZEND_INI_STAGE_STARTUP) { if (ZSTR_LEN(entry->name) == sizeof("phar.readonly")-1) { PHAR_G(readonly_orig) = ini; } else { PHAR_G(require_hash_orig) = ini; } } else if (old && !ini) { return FAILURE; } if (ZSTR_LEN(entry->name) == sizeof("phar.readonly")-1) { PHAR_G(readonly) = ini; if (PHAR_G(request_init) && PHAR_G(phar_fname_map.u.flags)) { zend_hash_apply_with_argument(&(PHAR_G(phar_fname_map)), phar_set_writeable_bit, (void *)&ini); } } else { PHAR_G(require_hash) = ini; } return SUCCESS; } /* }}}*/
@@ -2196,6 +2196,10 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a #endif int ext_len; + if (CHECK_NULL_PATH(filename, filename_len)) { + return FAILURE; + } + if (!strncasecmp(filename, "phar://", 7)) { filename += 7; filename_len -= 7;
CWE-20
null
null
8,864
ZEND_INI_MH(phar_ini_cache_list) /* {{{ */ { PHAR_G(cache_list) = ZSTR_VAL(new_value); if (stage == ZEND_INI_STAGE_STARTUP) { phar_split_cache_list(); } return SUCCESS; } /* }}} */
Exec Code
0
ZEND_INI_MH(phar_ini_cache_list) /* {{{ */ { PHAR_G(cache_list) = ZSTR_VAL(new_value); if (stage == ZEND_INI_STAGE_STARTUP) { phar_split_cache_list(); } return SUCCESS; } /* }}} */
@@ -2196,6 +2196,10 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a #endif int ext_len; + if (CHECK_NULL_PATH(filename, filename_len)) { + return FAILURE; + } + if (!strncasecmp(filename, "phar://", 7)) { filename += 7; filename_len -= 7;
CWE-20
null
null
8,865
static void destroy_phar_data(zval *zv) /* {{{ */ { phar_archive_data *phar_data = (phar_archive_data *)Z_PTR_P(zv); if (PHAR_G(request_ends)) { /* first, iterate over the manifest and close all PHAR_TMP entry fp handles, this prevents unnecessary unfreed stream resources */ zend_hash_apply(&(phar_data->manifest), phar_tmpclose_apply); destroy_phar_data_only(zv); return; } zend_hash_apply_with_argument(&(PHAR_G(phar_alias_map)), phar_unalias_apply, phar_data); if (--phar_data->refcount < 0) { phar_destroy_phar_data(phar_data); } } /* }}}*/
Exec Code
0
static void destroy_phar_data(zval *zv) /* {{{ */ { phar_archive_data *phar_data = (phar_archive_data *)Z_PTR_P(zv); if (PHAR_G(request_ends)) { /* first, iterate over the manifest and close all PHAR_TMP entry fp handles, this prevents unnecessary unfreed stream resources */ zend_hash_apply(&(phar_data->manifest), phar_tmpclose_apply); destroy_phar_data_only(zv); return; } zend_hash_apply_with_argument(&(PHAR_G(phar_alias_map)), phar_unalias_apply, phar_data); if (--phar_data->refcount < 0) { phar_destroy_phar_data(phar_data); } } /* }}}*/
@@ -2196,6 +2196,10 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a #endif int ext_len; + if (CHECK_NULL_PATH(filename, filename_len)) { + return FAILURE; + } + if (!strncasecmp(filename, "phar://", 7)) { filename += 7; filename_len -= 7;
CWE-20
null
null
8,866
static void destroy_phar_data_only(zval *zv) /* {{{ */ { phar_archive_data *phar_data = (phar_archive_data *) Z_PTR_P(zv); if (EG(exception) || --phar_data->refcount < 0) { phar_destroy_phar_data(phar_data); } } /* }}}*/
Exec Code
0
static void destroy_phar_data_only(zval *zv) /* {{{ */ { phar_archive_data *phar_data = (phar_archive_data *) Z_PTR_P(zv); if (EG(exception) || --phar_data->refcount < 0) { phar_destroy_phar_data(phar_data); } } /* }}}*/
@@ -2196,6 +2196,10 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a #endif int ext_len; + if (CHECK_NULL_PATH(filename, filename_len)) { + return FAILURE; + } + if (!strncasecmp(filename, "phar://", 7)) { filename += 7; filename_len -= 7;
CWE-20
null
null
8,867
void destroy_phar_manifest_entry_int(phar_entry_info *entry) /* {{{ */ { if (entry->cfp) { php_stream_close(entry->cfp); entry->cfp = 0; } if (entry->fp) { php_stream_close(entry->fp); entry->fp = 0; } if (Z_TYPE(entry->metadata) != IS_UNDEF) { if (entry->is_persistent) { if (entry->metadata_len) { /* for zip comments that are strings */ free(Z_PTR(entry->metadata)); } else { zval_internal_ptr_dtor(&entry->metadata); } } else { zval_ptr_dtor(&entry->metadata); } entry->metadata_len = 0; ZVAL_UNDEF(&entry->metadata); } if (entry->metadata_str.s) { smart_str_free(&entry->metadata_str); entry->metadata_str.s = NULL; } pefree(entry->filename, entry->is_persistent); if (entry->link) { pefree(entry->link, entry->is_persistent); entry->link = 0; } if (entry->tmp) { pefree(entry->tmp, entry->is_persistent); entry->tmp = 0; } } /* }}} */
Exec Code
0
void destroy_phar_manifest_entry_int(phar_entry_info *entry) /* {{{ */ { if (entry->cfp) { php_stream_close(entry->cfp); entry->cfp = 0; } if (entry->fp) { php_stream_close(entry->fp); entry->fp = 0; } if (Z_TYPE(entry->metadata) != IS_UNDEF) { if (entry->is_persistent) { if (entry->metadata_len) { /* for zip comments that are strings */ free(Z_PTR(entry->metadata)); } else { zval_internal_ptr_dtor(&entry->metadata); } } else { zval_ptr_dtor(&entry->metadata); } entry->metadata_len = 0; ZVAL_UNDEF(&entry->metadata); } if (entry->metadata_str.s) { smart_str_free(&entry->metadata_str); entry->metadata_str.s = NULL; } pefree(entry->filename, entry->is_persistent); if (entry->link) { pefree(entry->link, entry->is_persistent); entry->link = 0; } if (entry->tmp) { pefree(entry->tmp, entry->is_persistent); entry->tmp = 0; } } /* }}} */
@@ -2196,6 +2196,10 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a #endif int ext_len; + if (CHECK_NULL_PATH(filename, filename_len)) { + return FAILURE; + } + if (!strncasecmp(filename, "phar://", 7)) { filename += 7; filename_len -= 7;
CWE-20
null
null
8,868
static void mime_type_dtor(zval *zv) { free(Z_PTR_P(zv)); }
Exec Code
0
static void mime_type_dtor(zval *zv) { free(Z_PTR_P(zv)); }
@@ -2196,6 +2196,10 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a #endif int ext_len; + if (CHECK_NULL_PATH(filename, filename_len)) { + return FAILURE; + } + if (!strncasecmp(filename, "phar://", 7)) { filename += 7; filename_len -= 7;
CWE-20
null
null
8,869
static int phar_analyze_path(const char *fname, const char *ext, int ext_len, int for_create) /* {{{ */ { php_stream_statbuf ssb; char *realpath; char *filename = estrndup(fname, (ext - fname) + ext_len); if ((realpath = expand_filepath(filename, NULL))) { #ifdef PHP_WIN32 phar_unixify_path_separators(realpath, strlen(realpath)); #endif if (zend_hash_str_exists(&(PHAR_G(phar_fname_map)), realpath, strlen(realpath))) { efree(realpath); efree(filename); return SUCCESS; } if (PHAR_G(manifest_cached) && zend_hash_str_exists(&cached_phars, realpath, strlen(realpath))) { efree(realpath); efree(filename); return SUCCESS; } efree(realpath); } if (SUCCESS == php_stream_stat_path((char *) filename, &ssb)) { efree(filename); if (ssb.sb.st_mode & S_IFDIR) { return FAILURE; } if (for_create == 1) { return FAILURE; } return SUCCESS; } else { char *slash; if (!for_create) { efree(filename); return FAILURE; } slash = (char *) strrchr(filename, '/'); if (slash) { *slash = '\0'; } if (SUCCESS != php_stream_stat_path((char *) filename, &ssb)) { if (!slash) { if (!(realpath = expand_filepath(filename, NULL))) { efree(filename); return FAILURE; } #ifdef PHP_WIN32 phar_unixify_path_separators(realpath, strlen(realpath)); #endif slash = strstr(realpath, filename); if (slash) { slash += ((ext - fname) + ext_len); *slash = '\0'; } slash = strrchr(realpath, '/'); if (slash) { *slash = '\0'; } else { efree(realpath); efree(filename); return FAILURE; } if (SUCCESS != php_stream_stat_path(realpath, &ssb)) { efree(realpath); efree(filename); return FAILURE; } efree(realpath); if (ssb.sb.st_mode & S_IFDIR) { efree(filename); return SUCCESS; } } efree(filename); return FAILURE; } efree(filename); if (ssb.sb.st_mode & S_IFDIR) { return SUCCESS; } return FAILURE; } } /* }}} */
Exec Code
0
static int phar_analyze_path(const char *fname, const char *ext, int ext_len, int for_create) /* {{{ */ { php_stream_statbuf ssb; char *realpath; char *filename = estrndup(fname, (ext - fname) + ext_len); if ((realpath = expand_filepath(filename, NULL))) { #ifdef PHP_WIN32 phar_unixify_path_separators(realpath, strlen(realpath)); #endif if (zend_hash_str_exists(&(PHAR_G(phar_fname_map)), realpath, strlen(realpath))) { efree(realpath); efree(filename); return SUCCESS; } if (PHAR_G(manifest_cached) && zend_hash_str_exists(&cached_phars, realpath, strlen(realpath))) { efree(realpath); efree(filename); return SUCCESS; } efree(realpath); } if (SUCCESS == php_stream_stat_path((char *) filename, &ssb)) { efree(filename); if (ssb.sb.st_mode & S_IFDIR) { return FAILURE; } if (for_create == 1) { return FAILURE; } return SUCCESS; } else { char *slash; if (!for_create) { efree(filename); return FAILURE; } slash = (char *) strrchr(filename, '/'); if (slash) { *slash = '\0'; } if (SUCCESS != php_stream_stat_path((char *) filename, &ssb)) { if (!slash) { if (!(realpath = expand_filepath(filename, NULL))) { efree(filename); return FAILURE; } #ifdef PHP_WIN32 phar_unixify_path_separators(realpath, strlen(realpath)); #endif slash = strstr(realpath, filename); if (slash) { slash += ((ext - fname) + ext_len); *slash = '\0'; } slash = strrchr(realpath, '/'); if (slash) { *slash = '\0'; } else { efree(realpath); efree(filename); return FAILURE; } if (SUCCESS != php_stream_stat_path(realpath, &ssb)) { efree(realpath); efree(filename); return FAILURE; } efree(realpath); if (ssb.sb.st_mode & S_IFDIR) { efree(filename); return SUCCESS; } } efree(filename); return FAILURE; } efree(filename); if (ssb.sb.st_mode & S_IFDIR) { return SUCCESS; } return FAILURE; } } /* }}} */
@@ -2196,6 +2196,10 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a #endif int ext_len; + if (CHECK_NULL_PATH(filename, filename_len)) { + return FAILURE; + } + if (!strncasecmp(filename, "phar://", 7)) { filename += 7; filename_len -= 7;
CWE-20
null
null
8,870
int phar_archive_delref(phar_archive_data *phar) /* {{{ */ { if (phar->is_persistent) { return 0; } if (--phar->refcount < 0) { if (PHAR_G(request_done) || zend_hash_str_del(&(PHAR_G(phar_fname_map)), phar->fname, phar->fname_len) != SUCCESS) { phar_destroy_phar_data(phar); } return 1; } else if (!phar->refcount) { /* invalidate phar cache */ PHAR_G(last_phar) = NULL; PHAR_G(last_phar_name) = PHAR_G(last_alias) = NULL; if (phar->fp && !(phar->flags & PHAR_FILE_COMPRESSION_MASK)) { /* close open file handle - allows removal or rename of the file on windows, which has greedy locking only close if the archive was not already compressed. If it was compressed, then the fp does not refer to the original file */ php_stream_close(phar->fp); phar->fp = NULL; } if (!zend_hash_num_elements(&phar->manifest)) { /* this is a new phar that has perhaps had an alias/metadata set, but has never been flushed */ if (zend_hash_str_del(&(PHAR_G(phar_fname_map)), phar->fname, phar->fname_len) != SUCCESS) { phar_destroy_phar_data(phar); } return 1; } } return 0; } /* }}}*/
Exec Code
0
int phar_archive_delref(phar_archive_data *phar) /* {{{ */ { if (phar->is_persistent) { return 0; } if (--phar->refcount < 0) { if (PHAR_G(request_done) || zend_hash_str_del(&(PHAR_G(phar_fname_map)), phar->fname, phar->fname_len) != SUCCESS) { phar_destroy_phar_data(phar); } return 1; } else if (!phar->refcount) { /* invalidate phar cache */ PHAR_G(last_phar) = NULL; PHAR_G(last_phar_name) = PHAR_G(last_alias) = NULL; if (phar->fp && !(phar->flags & PHAR_FILE_COMPRESSION_MASK)) { /* close open file handle - allows removal or rename of the file on windows, which has greedy locking only close if the archive was not already compressed. If it was compressed, then the fp does not refer to the original file */ php_stream_close(phar->fp); phar->fp = NULL; } if (!zend_hash_num_elements(&phar->manifest)) { /* this is a new phar that has perhaps had an alias/metadata set, but has never been flushed */ if (zend_hash_str_del(&(PHAR_G(phar_fname_map)), phar->fname, phar->fname_len) != SUCCESS) { phar_destroy_phar_data(phar); } return 1; } } return 0; } /* }}}*/
@@ -2196,6 +2196,10 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a #endif int ext_len; + if (CHECK_NULL_PATH(filename, filename_len)) { + return FAILURE; + } + if (!strncasecmp(filename, "phar://", 7)) { filename += 7; filename_len -= 7;
CWE-20
null
null
8,871
static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type) /* {{{ */ { zend_op_array *res; char *name = NULL; int failed; phar_archive_data *phar; if (!file_handle || !file_handle->filename) { return phar_orig_compile_file(file_handle, type); } if (strstr(file_handle->filename, ".phar") && !strstr(file_handle->filename, "://")) { if (SUCCESS == phar_open_from_filename((char*)file_handle->filename, strlen(file_handle->filename), NULL, 0, 0, &phar, NULL)) { if (phar->is_zip || phar->is_tar) { zend_file_handle f = *file_handle; /* zip or tar-based phar */ spprintf(&name, 4096, "phar://%s/%s", file_handle->filename, ".phar/stub.php"); if (SUCCESS == phar_orig_zend_open((const char *)name, file_handle)) { efree(name); name = NULL; file_handle->filename = f.filename; if (file_handle->opened_path) { efree(file_handle->opened_path); } file_handle->opened_path = f.opened_path; file_handle->free_filename = f.free_filename; } else { *file_handle = f; } } else if (phar->flags & PHAR_FILE_COMPRESSION_MASK) { /* compressed phar */ file_handle->type = ZEND_HANDLE_STREAM; /* we do our own reading directly from the phar, don't change the next line */ file_handle->handle.stream.handle = phar; file_handle->handle.stream.reader = phar_zend_stream_reader; file_handle->handle.stream.closer = NULL; file_handle->handle.stream.fsizer = phar_zend_stream_fsizer; file_handle->handle.stream.isatty = 0; phar->is_persistent ? php_stream_rewind(PHAR_G(cached_fp)[phar->phar_pos].fp) : php_stream_rewind(phar->fp); memset(&file_handle->handle.stream.mmap, 0, sizeof(file_handle->handle.stream.mmap)); } } } zend_try { failed = 0; CG(zend_lineno) = 0; res = phar_orig_compile_file(file_handle, type); } zend_catch { failed = 1; res = NULL; } zend_end_try(); if (name) { efree(name); } if (failed) { zend_bailout(); } return res; } /* }}} */
Exec Code
0
static zend_op_array *phar_compile_file(zend_file_handle *file_handle, int type) /* {{{ */ { zend_op_array *res; char *name = NULL; int failed; phar_archive_data *phar; if (!file_handle || !file_handle->filename) { return phar_orig_compile_file(file_handle, type); } if (strstr(file_handle->filename, ".phar") && !strstr(file_handle->filename, "://")) { if (SUCCESS == phar_open_from_filename((char*)file_handle->filename, strlen(file_handle->filename), NULL, 0, 0, &phar, NULL)) { if (phar->is_zip || phar->is_tar) { zend_file_handle f = *file_handle; /* zip or tar-based phar */ spprintf(&name, 4096, "phar://%s/%s", file_handle->filename, ".phar/stub.php"); if (SUCCESS == phar_orig_zend_open((const char *)name, file_handle)) { efree(name); name = NULL; file_handle->filename = f.filename; if (file_handle->opened_path) { efree(file_handle->opened_path); } file_handle->opened_path = f.opened_path; file_handle->free_filename = f.free_filename; } else { *file_handle = f; } } else if (phar->flags & PHAR_FILE_COMPRESSION_MASK) { /* compressed phar */ file_handle->type = ZEND_HANDLE_STREAM; /* we do our own reading directly from the phar, don't change the next line */ file_handle->handle.stream.handle = phar; file_handle->handle.stream.reader = phar_zend_stream_reader; file_handle->handle.stream.closer = NULL; file_handle->handle.stream.fsizer = phar_zend_stream_fsizer; file_handle->handle.stream.isatty = 0; phar->is_persistent ? php_stream_rewind(PHAR_G(cached_fp)[phar->phar_pos].fp) : php_stream_rewind(phar->fp); memset(&file_handle->handle.stream.mmap, 0, sizeof(file_handle->handle.stream.mmap)); } } } zend_try { failed = 0; CG(zend_lineno) = 0; res = phar_orig_compile_file(file_handle, type); } zend_catch { failed = 1; res = NULL; } zend_end_try(); if (name) { efree(name); } if (failed) { zend_bailout(); } return res; } /* }}} */
@@ -2196,6 +2196,10 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a #endif int ext_len; + if (CHECK_NULL_PATH(filename, filename_len)) { + return FAILURE; + } + if (!strncasecmp(filename, "phar://", 7)) { filename += 7; filename_len -= 7;
CWE-20
null
null
8,872
int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error) /* {{{ */ { phar_archive_data *mydata; php_stream *fp; zend_string *actual = NULL; char *p; if (!pphar) { pphar = &mydata; } #if PHP_API_VERSION < 20100412 if (PG(safe_mode) && (!php_checkuid(fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) { return FAILURE; } #endif if (php_check_open_basedir(fname)) { return FAILURE; } /* first open readonly so it won't be created if not present */ fp = php_stream_open_wrapper(fname, "rb", IGNORE_URL|STREAM_MUST_SEEK|0, &actual); if (actual) { fname = ZSTR_VAL(actual); fname_len = ZSTR_LEN(actual); } if (fp) { if (phar_open_from_fp(fp, fname, fname_len, alias, alias_len, options, pphar, is_data, error) == SUCCESS) { if ((*pphar)->is_data || !PHAR_G(readonly)) { (*pphar)->is_writeable = 1; } if (actual) { zend_string_release(actual); } return SUCCESS; } else { /* file exists, but is either corrupt or not a phar archive */ if (actual) { zend_string_release(actual); } return FAILURE; } } if (actual) { zend_string_release(actual); } if (PHAR_G(readonly) && !is_data) { if (options & REPORT_ERRORS) { if (error) { spprintf(error, 0, "creating archive \"%s\" disabled by the php.ini setting phar.readonly", fname); } } return FAILURE; } /* set up our manifest */ mydata = ecalloc(1, sizeof(phar_archive_data)); mydata->fname = expand_filepath(fname, NULL); fname_len = strlen(mydata->fname); #ifdef PHP_WIN32 phar_unixify_path_separators(mydata->fname, fname_len); #endif p = strrchr(mydata->fname, '/'); if (p) { mydata->ext = memchr(p, '.', (mydata->fname + fname_len) - p); if (mydata->ext == p) { mydata->ext = memchr(p + 1, '.', (mydata->fname + fname_len) - p - 1); } if (mydata->ext) { mydata->ext_len = (mydata->fname + fname_len) - mydata->ext; } } if (pphar) { *pphar = mydata; } zend_hash_init(&mydata->manifest, sizeof(phar_entry_info), zend_get_hash_value, destroy_phar_manifest_entry, 0); zend_hash_init(&mydata->mounted_dirs, sizeof(char *), zend_get_hash_value, NULL, 0); zend_hash_init(&mydata->virtual_dirs, sizeof(char *), zend_get_hash_value, NULL, (zend_bool)mydata->is_persistent); mydata->fname_len = fname_len; snprintf(mydata->version, sizeof(mydata->version), "%s", PHP_PHAR_API_VERSION); mydata->is_temporary_alias = alias ? 0 : 1; mydata->internal_file_start = -1; mydata->fp = NULL; mydata->is_writeable = 1; mydata->is_brandnew = 1; phar_request_initialize(); zend_hash_str_add_ptr(&(PHAR_G(phar_fname_map)), mydata->fname, fname_len, mydata); if (is_data) { alias = NULL; alias_len = 0; mydata->is_data = 1; /* assume tar format, PharData can specify other */ mydata->is_tar = 1; } else { phar_archive_data *fd_ptr; if (alias && NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len))) { if (SUCCESS != phar_free_alias(fd_ptr, alias, alias_len)) { if (error) { spprintf(error, 4096, "phar error: phar \"%s\" cannot set alias \"%s\", already in use by another phar archive", mydata->fname, alias); } zend_hash_str_del(&(PHAR_G(phar_fname_map)), mydata->fname, fname_len); if (pphar) { *pphar = NULL; } return FAILURE; } } mydata->alias = alias ? estrndup(alias, alias_len) : estrndup(mydata->fname, fname_len); mydata->alias_len = alias ? alias_len : fname_len; } if (alias_len && alias) { if (NULL == zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len, mydata)) { if (options & REPORT_ERRORS) { if (error) { spprintf(error, 0, "archive \"%s\" cannot be associated with alias \"%s\", already in use", fname, alias); } } zend_hash_str_del(&(PHAR_G(phar_fname_map)), mydata->fname, fname_len); if (pphar) { *pphar = NULL; } return FAILURE; } } return SUCCESS; } /* }}}*/
Exec Code
0
int phar_create_or_parse_filename(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error) /* {{{ */ { phar_archive_data *mydata; php_stream *fp; zend_string *actual = NULL; char *p; if (!pphar) { pphar = &mydata; } #if PHP_API_VERSION < 20100412 if (PG(safe_mode) && (!php_checkuid(fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) { return FAILURE; } #endif if (php_check_open_basedir(fname)) { return FAILURE; } /* first open readonly so it won't be created if not present */ fp = php_stream_open_wrapper(fname, "rb", IGNORE_URL|STREAM_MUST_SEEK|0, &actual); if (actual) { fname = ZSTR_VAL(actual); fname_len = ZSTR_LEN(actual); } if (fp) { if (phar_open_from_fp(fp, fname, fname_len, alias, alias_len, options, pphar, is_data, error) == SUCCESS) { if ((*pphar)->is_data || !PHAR_G(readonly)) { (*pphar)->is_writeable = 1; } if (actual) { zend_string_release(actual); } return SUCCESS; } else { /* file exists, but is either corrupt or not a phar archive */ if (actual) { zend_string_release(actual); } return FAILURE; } } if (actual) { zend_string_release(actual); } if (PHAR_G(readonly) && !is_data) { if (options & REPORT_ERRORS) { if (error) { spprintf(error, 0, "creating archive \"%s\" disabled by the php.ini setting phar.readonly", fname); } } return FAILURE; } /* set up our manifest */ mydata = ecalloc(1, sizeof(phar_archive_data)); mydata->fname = expand_filepath(fname, NULL); fname_len = strlen(mydata->fname); #ifdef PHP_WIN32 phar_unixify_path_separators(mydata->fname, fname_len); #endif p = strrchr(mydata->fname, '/'); if (p) { mydata->ext = memchr(p, '.', (mydata->fname + fname_len) - p); if (mydata->ext == p) { mydata->ext = memchr(p + 1, '.', (mydata->fname + fname_len) - p - 1); } if (mydata->ext) { mydata->ext_len = (mydata->fname + fname_len) - mydata->ext; } } if (pphar) { *pphar = mydata; } zend_hash_init(&mydata->manifest, sizeof(phar_entry_info), zend_get_hash_value, destroy_phar_manifest_entry, 0); zend_hash_init(&mydata->mounted_dirs, sizeof(char *), zend_get_hash_value, NULL, 0); zend_hash_init(&mydata->virtual_dirs, sizeof(char *), zend_get_hash_value, NULL, (zend_bool)mydata->is_persistent); mydata->fname_len = fname_len; snprintf(mydata->version, sizeof(mydata->version), "%s", PHP_PHAR_API_VERSION); mydata->is_temporary_alias = alias ? 0 : 1; mydata->internal_file_start = -1; mydata->fp = NULL; mydata->is_writeable = 1; mydata->is_brandnew = 1; phar_request_initialize(); zend_hash_str_add_ptr(&(PHAR_G(phar_fname_map)), mydata->fname, fname_len, mydata); if (is_data) { alias = NULL; alias_len = 0; mydata->is_data = 1; /* assume tar format, PharData can specify other */ mydata->is_tar = 1; } else { phar_archive_data *fd_ptr; if (alias && NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len))) { if (SUCCESS != phar_free_alias(fd_ptr, alias, alias_len)) { if (error) { spprintf(error, 4096, "phar error: phar \"%s\" cannot set alias \"%s\", already in use by another phar archive", mydata->fname, alias); } zend_hash_str_del(&(PHAR_G(phar_fname_map)), mydata->fname, fname_len); if (pphar) { *pphar = NULL; } return FAILURE; } } mydata->alias = alias ? estrndup(alias, alias_len) : estrndup(mydata->fname, fname_len); mydata->alias_len = alias ? alias_len : fname_len; } if (alias_len && alias) { if (NULL == zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len, mydata)) { if (options & REPORT_ERRORS) { if (error) { spprintf(error, 0, "archive \"%s\" cannot be associated with alias \"%s\", already in use", fname, alias); } } zend_hash_str_del(&(PHAR_G(phar_fname_map)), mydata->fname, fname_len); if (pphar) { *pphar = NULL; } return FAILURE; } } return SUCCESS; } /* }}}*/
@@ -2196,6 +2196,10 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a #endif int ext_len; + if (CHECK_NULL_PATH(filename, filename_len)) { + return FAILURE; + } + if (!strncasecmp(filename, "phar://", 7)) { filename += 7; filename_len -= 7;
CWE-20
null
null
8,873
void phar_destroy_phar_data(phar_archive_data *phar) /* {{{ */ { if (phar->alias && phar->alias != phar->fname) { pefree(phar->alias, phar->is_persistent); phar->alias = NULL; } if (phar->fname) { pefree(phar->fname, phar->is_persistent); phar->fname = NULL; } if (phar->signature) { pefree(phar->signature, phar->is_persistent); phar->signature = NULL; } if (phar->manifest.u.flags) { zend_hash_destroy(&phar->manifest); phar->manifest.u.flags = 0; } if (phar->mounted_dirs.u.flags) { zend_hash_destroy(&phar->mounted_dirs); phar->mounted_dirs.u.flags = 0; } if (phar->virtual_dirs.u.flags) { zend_hash_destroy(&phar->virtual_dirs); phar->virtual_dirs.u.flags = 0; } if (Z_TYPE(phar->metadata) != IS_UNDEF) { if (phar->is_persistent) { if (phar->metadata_len) { /* for zip comments that are strings */ free(Z_PTR(phar->metadata)); } else { zval_internal_ptr_dtor(&phar->metadata); } } else { zval_ptr_dtor(&phar->metadata); } phar->metadata_len = 0; ZVAL_UNDEF(&phar->metadata); } if (phar->fp) { php_stream_close(phar->fp); phar->fp = 0; } if (phar->ufp) { php_stream_close(phar->ufp); phar->ufp = 0; } pefree(phar, phar->is_persistent); } /* }}}*/
Exec Code
0
void phar_destroy_phar_data(phar_archive_data *phar) /* {{{ */ { if (phar->alias && phar->alias != phar->fname) { pefree(phar->alias, phar->is_persistent); phar->alias = NULL; } if (phar->fname) { pefree(phar->fname, phar->is_persistent); phar->fname = NULL; } if (phar->signature) { pefree(phar->signature, phar->is_persistent); phar->signature = NULL; } if (phar->manifest.u.flags) { zend_hash_destroy(&phar->manifest); phar->manifest.u.flags = 0; } if (phar->mounted_dirs.u.flags) { zend_hash_destroy(&phar->mounted_dirs); phar->mounted_dirs.u.flags = 0; } if (phar->virtual_dirs.u.flags) { zend_hash_destroy(&phar->virtual_dirs); phar->virtual_dirs.u.flags = 0; } if (Z_TYPE(phar->metadata) != IS_UNDEF) { if (phar->is_persistent) { if (phar->metadata_len) { /* for zip comments that are strings */ free(Z_PTR(phar->metadata)); } else { zval_internal_ptr_dtor(&phar->metadata); } } else { zval_ptr_dtor(&phar->metadata); } phar->metadata_len = 0; ZVAL_UNDEF(&phar->metadata); } if (phar->fp) { php_stream_close(phar->fp); phar->fp = 0; } if (phar->ufp) { php_stream_close(phar->ufp); phar->ufp = 0; } pefree(phar, phar->is_persistent); } /* }}}*/
@@ -2196,6 +2196,10 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a #endif int ext_len; + if (CHECK_NULL_PATH(filename, filename_len)) { + return FAILURE; + } + if (!strncasecmp(filename, "phar://", 7)) { filename += 7; filename_len -= 7;
CWE-20
null
null
8,874
int phar_entry_delref(phar_entry_data *idata) /* {{{ */ { int ret = 0; if (idata->internal_file && !idata->internal_file->is_persistent) { if (--idata->internal_file->fp_refcount < 0) { idata->internal_file->fp_refcount = 0; } if (idata->fp && idata->fp != idata->phar->fp && idata->fp != idata->phar->ufp && idata->fp != idata->internal_file->fp) { php_stream_close(idata->fp); } /* if phar_get_or_create_entry_data returns a sub-directory, we have to free it */ if (idata->internal_file->is_temp_dir) { destroy_phar_manifest_entry_int(idata->internal_file); efree(idata->internal_file); } } phar_archive_delref(idata->phar); efree(idata); return ret; } /* }}} */
Exec Code
0
int phar_entry_delref(phar_entry_data *idata) /* {{{ */ { int ret = 0; if (idata->internal_file && !idata->internal_file->is_persistent) { if (--idata->internal_file->fp_refcount < 0) { idata->internal_file->fp_refcount = 0; } if (idata->fp && idata->fp != idata->phar->fp && idata->fp != idata->phar->ufp && idata->fp != idata->internal_file->fp) { php_stream_close(idata->fp); } /* if phar_get_or_create_entry_data returns a sub-directory, we have to free it */ if (idata->internal_file->is_temp_dir) { destroy_phar_manifest_entry_int(idata->internal_file); efree(idata->internal_file); } } phar_archive_delref(idata->phar); efree(idata); return ret; } /* }}} */
@@ -2196,6 +2196,10 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a #endif int ext_len; + if (CHECK_NULL_PATH(filename, filename_len)) { + return FAILURE; + } + if (!strncasecmp(filename, "phar://", 7)) { filename += 7; filename_len -= 7;
CWE-20
null
null
8,875
void phar_entry_remove(phar_entry_data *idata, char **error) /* {{{ */ { phar_archive_data *phar; phar = idata->phar; if (idata->internal_file->fp_refcount < 2) { if (idata->fp && idata->fp != idata->phar->fp && idata->fp != idata->phar->ufp && idata->fp != idata->internal_file->fp) { php_stream_close(idata->fp); } zend_hash_str_del(&idata->phar->manifest, idata->internal_file->filename, idata->internal_file->filename_len); idata->phar->refcount--; efree(idata); } else { idata->internal_file->is_deleted = 1; phar_entry_delref(idata); } if (!phar->donotflush) { phar_flush(phar, 0, 0, 0, error); } } /* }}} */
Exec Code
0
void phar_entry_remove(phar_entry_data *idata, char **error) /* {{{ */ { phar_archive_data *phar; phar = idata->phar; if (idata->internal_file->fp_refcount < 2) { if (idata->fp && idata->fp != idata->phar->fp && idata->fp != idata->phar->ufp && idata->fp != idata->internal_file->fp) { php_stream_close(idata->fp); } zend_hash_str_del(&idata->phar->manifest, idata->internal_file->filename, idata->internal_file->filename_len); idata->phar->refcount--; efree(idata); } else { idata->internal_file->is_deleted = 1; phar_entry_delref(idata); } if (!phar->donotflush) { phar_flush(phar, 0, 0, 0, error); } } /* }}} */
@@ -2196,6 +2196,10 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a #endif int ext_len; + if (CHECK_NULL_PATH(filename, filename_len)) { + return FAILURE; + } + if (!strncasecmp(filename, "phar://", 7)) { filename += 7; filename_len -= 7;
CWE-20
null
null
8,876
char *phar_fix_filepath(char *path, int *new_len, int use_cwd) /* {{{ */ { char *newpath; int newpath_len; char *ptr; char *tok; int ptr_length, path_length = *new_len; if (PHAR_G(cwd_len) && use_cwd && path_length > 2 && path[0] == '.' && path[1] == '/') { newpath_len = PHAR_G(cwd_len); newpath = emalloc(strlen(path) + newpath_len + 1); memcpy(newpath, PHAR_G(cwd), newpath_len); } else { newpath = emalloc(strlen(path) + 2); newpath[0] = '/'; newpath_len = 1; } ptr = path; if (*ptr == '/') { ++ptr; } tok = ptr; do { ptr = memchr(ptr, '/', path_length - (ptr - path)); } while (ptr && ptr - tok == 0 && *ptr == '/' && ++ptr && ++tok); if (!ptr && (path_length - (tok - path))) { switch (path_length - (tok - path)) { case 1: if (*tok == '.') { efree(path); *new_len = 1; efree(newpath); return estrndup("/", 1); } break; case 2: if (tok[0] == '.' && tok[1] == '.') { efree(path); *new_len = 1; efree(newpath); return estrndup("/", 1); } } efree(newpath); return path; } while (ptr) { ptr_length = ptr - tok; last_time: if (IS_DIRECTORY_UP(tok, ptr_length)) { #define PREVIOUS newpath[newpath_len - 1] while (newpath_len > 1 && !IS_BACKSLASH(PREVIOUS)) { newpath_len--; } if (newpath[0] != '/') { newpath[newpath_len] = '\0'; } else if (newpath_len > 1) { --newpath_len; } } else if (!IS_DIRECTORY_CURRENT(tok, ptr_length)) { if (newpath_len > 1) { newpath[newpath_len++] = '/'; memcpy(newpath + newpath_len, tok, ptr_length+1); } else { memcpy(newpath + newpath_len, tok, ptr_length+1); } newpath_len += ptr_length; } if (ptr == path + path_length) { break; } tok = ++ptr; do { ptr = memchr(ptr, '/', path_length - (ptr - path)); } while (ptr && ptr - tok == 0 && *ptr == '/' && ++ptr && ++tok); if (!ptr && (path_length - (tok - path))) { ptr_length = path_length - (tok - path); ptr = path + path_length; goto last_time; } } efree(path); *new_len = newpath_len; newpath[newpath_len] = '\0'; return erealloc(newpath, newpath_len + 1); } /* }}} */
Exec Code
0
char *phar_fix_filepath(char *path, int *new_len, int use_cwd) /* {{{ */ { char *newpath; int newpath_len; char *ptr; char *tok; int ptr_length, path_length = *new_len; if (PHAR_G(cwd_len) && use_cwd && path_length > 2 && path[0] == '.' && path[1] == '/') { newpath_len = PHAR_G(cwd_len); newpath = emalloc(strlen(path) + newpath_len + 1); memcpy(newpath, PHAR_G(cwd), newpath_len); } else { newpath = emalloc(strlen(path) + 2); newpath[0] = '/'; newpath_len = 1; } ptr = path; if (*ptr == '/') { ++ptr; } tok = ptr; do { ptr = memchr(ptr, '/', path_length - (ptr - path)); } while (ptr && ptr - tok == 0 && *ptr == '/' && ++ptr && ++tok); if (!ptr && (path_length - (tok - path))) { switch (path_length - (tok - path)) { case 1: if (*tok == '.') { efree(path); *new_len = 1; efree(newpath); return estrndup("/", 1); } break; case 2: if (tok[0] == '.' && tok[1] == '.') { efree(path); *new_len = 1; efree(newpath); return estrndup("/", 1); } } efree(newpath); return path; } while (ptr) { ptr_length = ptr - tok; last_time: if (IS_DIRECTORY_UP(tok, ptr_length)) { #define PREVIOUS newpath[newpath_len - 1] while (newpath_len > 1 && !IS_BACKSLASH(PREVIOUS)) { newpath_len--; } if (newpath[0] != '/') { newpath[newpath_len] = '\0'; } else if (newpath_len > 1) { --newpath_len; } } else if (!IS_DIRECTORY_CURRENT(tok, ptr_length)) { if (newpath_len > 1) { newpath[newpath_len++] = '/'; memcpy(newpath + newpath_len, tok, ptr_length+1); } else { memcpy(newpath + newpath_len, tok, ptr_length+1); } newpath_len += ptr_length; } if (ptr == path + path_length) { break; } tok = ++ptr; do { ptr = memchr(ptr, '/', path_length - (ptr - path)); } while (ptr && ptr - tok == 0 && *ptr == '/' && ++ptr && ++tok); if (!ptr && (path_length - (tok - path))) { ptr_length = path_length - (tok - path); ptr = path + path_length; goto last_time; } } efree(path); *new_len = newpath_len; newpath[newpath_len] = '\0'; return erealloc(newpath, newpath_len + 1); } /* }}} */
@@ -2196,6 +2196,10 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a #endif int ext_len; + if (CHECK_NULL_PATH(filename, filename_len)) { + return FAILURE; + } + if (!strncasecmp(filename, "phar://", 7)) { filename += 7; filename_len -= 7;
CWE-20
null
null
8,877
static int phar_flush_clean_deleted_apply(zval *zv) /* {{{ */ { phar_entry_info *entry = (phar_entry_info *)Z_PTR_P(zv); if (entry->fp_refcount <= 0 && entry->is_deleted) { return ZEND_HASH_APPLY_REMOVE; } else { return ZEND_HASH_APPLY_KEEP; } } /* }}} */
Exec Code
0
static int phar_flush_clean_deleted_apply(zval *zv) /* {{{ */ { phar_entry_info *entry = (phar_entry_info *)Z_PTR_P(zv); if (entry->fp_refcount <= 0 && entry->is_deleted) { return ZEND_HASH_APPLY_REMOVE; } else { return ZEND_HASH_APPLY_KEEP; } } /* }}} */
@@ -2196,6 +2196,10 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a #endif int ext_len; + if (CHECK_NULL_PATH(filename, filename_len)) { + return FAILURE; + } + if (!strncasecmp(filename, "phar://", 7)) { filename += 7; filename_len -= 7;
CWE-20
null
null
8,878
int phar_open_from_filename(char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, char **error) /* {{{ */ { php_stream *fp; zend_string *actual; int ret, is_data = 0; if (error) { *error = NULL; } if (!strstr(fname, ".phar")) { is_data = 1; } if (phar_open_parsed_phar(fname, fname_len, alias, alias_len, is_data, options, pphar, error) == SUCCESS) { return SUCCESS; } else if (error && *error) { return FAILURE; } #if PHP_API_VERSION < 20100412 if (PG(safe_mode) && (!php_checkuid(fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) { return FAILURE; } #endif if (php_check_open_basedir(fname)) { return FAILURE; } fp = php_stream_open_wrapper(fname, "rb", IGNORE_URL|STREAM_MUST_SEEK, &actual); if (!fp) { if (options & REPORT_ERRORS) { if (error) { spprintf(error, 0, "unable to open phar for reading \"%s\"", fname); } } if (actual) { zend_string_release(actual); } return FAILURE; } if (actual) { fname = ZSTR_VAL(actual); fname_len = ZSTR_LEN(actual); } ret = phar_open_from_fp(fp, fname, fname_len, alias, alias_len, options, pphar, is_data, error); if (actual) { zend_string_release(actual); } return ret; } /* }}}*/
Exec Code
0
int phar_open_from_filename(char *fname, int fname_len, char *alias, int alias_len, int options, phar_archive_data** pphar, char **error) /* {{{ */ { php_stream *fp; zend_string *actual; int ret, is_data = 0; if (error) { *error = NULL; } if (!strstr(fname, ".phar")) { is_data = 1; } if (phar_open_parsed_phar(fname, fname_len, alias, alias_len, is_data, options, pphar, error) == SUCCESS) { return SUCCESS; } else if (error && *error) { return FAILURE; } #if PHP_API_VERSION < 20100412 if (PG(safe_mode) && (!php_checkuid(fname, NULL, CHECKUID_ALLOW_ONLY_FILE))) { return FAILURE; } #endif if (php_check_open_basedir(fname)) { return FAILURE; } fp = php_stream_open_wrapper(fname, "rb", IGNORE_URL|STREAM_MUST_SEEK, &actual); if (!fp) { if (options & REPORT_ERRORS) { if (error) { spprintf(error, 0, "unable to open phar for reading \"%s\"", fname); } } if (actual) { zend_string_release(actual); } return FAILURE; } if (actual) { fname = ZSTR_VAL(actual); fname_len = ZSTR_LEN(actual); } ret = phar_open_from_fp(fp, fname, fname_len, alias, alias_len, options, pphar, is_data, error); if (actual) { zend_string_release(actual); } return ret; } /* }}}*/
@@ -2196,6 +2196,10 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a #endif int ext_len; + if (CHECK_NULL_PATH(filename, filename_len)) { + return FAILURE; + } + if (!strncasecmp(filename, "phar://", 7)) { filename += 7; filename_len -= 7;
CWE-20
null
null
8,879
int phar_open_or_create_filename(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error) /* {{{ */ { const char *ext_str, *z; char *my_error; int ext_len; phar_archive_data **test, *unused = NULL; test = &unused; if (error) { *error = NULL; } /* first try to open an existing file */ if (phar_detect_phar_fname_ext(fname, fname_len, &ext_str, &ext_len, !is_data, 0, 1) == SUCCESS) { goto check_file; } /* next try to create a new file */ if (FAILURE == phar_detect_phar_fname_ext(fname, fname_len, &ext_str, &ext_len, !is_data, 1, 1)) { if (error) { if (ext_len == -2) { spprintf(error, 0, "Cannot create a phar archive from a URL like \"%s\". Phar objects can only be created from local files", fname); } else { spprintf(error, 0, "Cannot create phar '%s', file extension (or combination) not recognised or the directory does not exist", fname); } } return FAILURE; } check_file: if (phar_open_parsed_phar(fname, fname_len, alias, alias_len, is_data, options, test, &my_error) == SUCCESS) { if (pphar) { *pphar = *test; } if ((*test)->is_data && !(*test)->is_tar && !(*test)->is_zip) { if (error) { spprintf(error, 0, "Cannot open '%s' as a PharData object. Use Phar::__construct() for executable archives", fname); } return FAILURE; } if (PHAR_G(readonly) && !(*test)->is_data && ((*test)->is_tar || (*test)->is_zip)) { phar_entry_info *stub; if (NULL == (stub = zend_hash_str_find_ptr(&((*test)->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1))) { spprintf(error, 0, "'%s' is not a phar archive. Use PharData::__construct() for a standard zip or tar archive", fname); return FAILURE; } } if (!PHAR_G(readonly) || (*test)->is_data) { (*test)->is_writeable = 1; } return SUCCESS; } else if (my_error) { if (error) { *error = my_error; } else { efree(my_error); } return FAILURE; } if (ext_len > 3 && (z = memchr(ext_str, 'z', ext_len)) && ((ext_str + ext_len) - z >= 2) && !memcmp(z + 1, "ip", 2)) { /* assume zip-based phar */ return phar_open_or_create_zip(fname, fname_len, alias, alias_len, is_data, options, pphar, error); } if (ext_len > 3 && (z = memchr(ext_str, 't', ext_len)) && ((ext_str + ext_len) - z >= 2) && !memcmp(z + 1, "ar", 2)) { /* assume tar-based phar */ return phar_open_or_create_tar(fname, fname_len, alias, alias_len, is_data, options, pphar, error); } return phar_create_or_parse_filename(fname, fname_len, alias, alias_len, is_data, options, pphar, error); } /* }}} */
Exec Code
0
int phar_open_or_create_filename(char *fname, int fname_len, char *alias, int alias_len, int is_data, int options, phar_archive_data** pphar, char **error) /* {{{ */ { const char *ext_str, *z; char *my_error; int ext_len; phar_archive_data **test, *unused = NULL; test = &unused; if (error) { *error = NULL; } /* first try to open an existing file */ if (phar_detect_phar_fname_ext(fname, fname_len, &ext_str, &ext_len, !is_data, 0, 1) == SUCCESS) { goto check_file; } /* next try to create a new file */ if (FAILURE == phar_detect_phar_fname_ext(fname, fname_len, &ext_str, &ext_len, !is_data, 1, 1)) { if (error) { if (ext_len == -2) { spprintf(error, 0, "Cannot create a phar archive from a URL like \"%s\". Phar objects can only be created from local files", fname); } else { spprintf(error, 0, "Cannot create phar '%s', file extension (or combination) not recognised or the directory does not exist", fname); } } return FAILURE; } check_file: if (phar_open_parsed_phar(fname, fname_len, alias, alias_len, is_data, options, test, &my_error) == SUCCESS) { if (pphar) { *pphar = *test; } if ((*test)->is_data && !(*test)->is_tar && !(*test)->is_zip) { if (error) { spprintf(error, 0, "Cannot open '%s' as a PharData object. Use Phar::__construct() for executable archives", fname); } return FAILURE; } if (PHAR_G(readonly) && !(*test)->is_data && ((*test)->is_tar || (*test)->is_zip)) { phar_entry_info *stub; if (NULL == (stub = zend_hash_str_find_ptr(&((*test)->manifest), ".phar/stub.php", sizeof(".phar/stub.php")-1))) { spprintf(error, 0, "'%s' is not a phar archive. Use PharData::__construct() for a standard zip or tar archive", fname); return FAILURE; } } if (!PHAR_G(readonly) || (*test)->is_data) { (*test)->is_writeable = 1; } return SUCCESS; } else if (my_error) { if (error) { *error = my_error; } else { efree(my_error); } return FAILURE; } if (ext_len > 3 && (z = memchr(ext_str, 'z', ext_len)) && ((ext_str + ext_len) - z >= 2) && !memcmp(z + 1, "ip", 2)) { /* assume zip-based phar */ return phar_open_or_create_zip(fname, fname_len, alias, alias_len, is_data, options, pphar, error); } if (ext_len > 3 && (z = memchr(ext_str, 't', ext_len)) && ((ext_str + ext_len) - z >= 2) && !memcmp(z + 1, "ar", 2)) { /* assume tar-based phar */ return phar_open_or_create_tar(fname, fname_len, alias, alias_len, is_data, options, pphar, error); } return phar_create_or_parse_filename(fname, fname_len, alias, alias_len, is_data, options, pphar, error); } /* }}} */
@@ -2196,6 +2196,10 @@ int phar_split_fname(const char *filename, int filename_len, char **arch, int *a #endif int ext_len; + if (CHECK_NULL_PATH(filename, filename_len)) { + return FAILURE; + } + if (!strncasecmp(filename, "phar://", 7)) { filename += 7; filename_len -= 7;
CWE-20
null
null
8,880
PHP_METHOD(Phar, running) { char *fname, *arch, *entry; int fname_len, arch_len, entry_len; zend_bool retphar = 1; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &retphar) == FAILURE) { return; } fname = (char*)zend_get_executed_filename(); fname_len = strlen(fname); if (fname_len > 7 && !memcmp(fname, "phar://", 7) && SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0)) { efree(entry); if (retphar) { RETVAL_STRINGL(fname, arch_len + 7); efree(arch); return; } else { RETVAL_STRINGL(arch, arch_len); efree(arch); return; } } RETURN_EMPTY_STRING(); }
Exec Code
0
PHP_METHOD(Phar, running) { char *fname, *arch, *entry; int fname_len, arch_len, entry_len; zend_bool retphar = 1; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &retphar) == FAILURE) { return; } fname = (char*)zend_get_executed_filename(); fname_len = strlen(fname); if (fname_len > 7 && !memcmp(fname, "phar://", 7) && SUCCESS == phar_split_fname(fname, fname_len, &arch, &arch_len, &entry, &entry_len, 2, 0)) { efree(entry); if (retphar) { RETVAL_STRINGL(fname, arch_len + 7); efree(arch); return; } else { RETVAL_STRINGL(arch, arch_len); efree(arch); return; } } RETURN_EMPTY_STRING(); }
@@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount) size_t path_len, actual_len; phar_archive_data *pphar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) { return; } @@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub) zend_string *stub; size_t index_len = 0, webindex_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) { return; } @@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar) char *fname, *alias = NULL, *error; size_t fname_len, alias_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { return; } @@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename) int ext_len, is_executable; zend_bool executable = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) { return; } @@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct) is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data); if (is_data) { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { return; } } else { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { return; } } @@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive) int zname_len, arch_len, entry_len; phar_archive_data *phar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { RETURN_FALSE; } @@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { return; } @@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet) zend_string *sfname; PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet) return; } - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE - && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE + && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) { return; } @@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { return; } @@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { return; } @@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct) phar_archive_data *phar_data; zval *zobj = getThis(), arg1; - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; }
CWE-20
null
null
8,881
PHP_METHOD(Phar, webPhar) { zval *mimeoverride = NULL, *rewrite = NULL; char *alias = NULL, *error, *index_php = NULL, *f404 = NULL, *ru = NULL; size_t alias_len = 0, f404_len = 0, free_pathinfo = 0; int ru_len = 0; char *fname, *path_info, *mime_type = NULL, *entry, *pt; const char *basename; size_t fname_len, index_php_len = 0; int entry_len, code, not_cgi; phar_archive_data *phar = NULL; phar_entry_info *info = NULL; size_t sapi_mod_name_len = strlen(sapi_module.name); if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!saz", &alias, &alias_len, &index_php, &index_php_len, &f404, &f404_len, &mimeoverride, &rewrite) == FAILURE) { return; } phar_request_initialize(); fname = (char*)zend_get_executed_filename(); fname_len = strlen(fname); if (phar_open_executed_filename(alias, alias_len, &error) != SUCCESS) { if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); efree(error); } return; } /* retrieve requested file within phar */ if (!(SG(request_info).request_method && SG(request_info).request_uri && (!strcmp(SG(request_info).request_method, "GET") || !strcmp(SG(request_info).request_method, "POST")))) { return; } #ifdef PHP_WIN32 fname = estrndup(fname, fname_len); phar_unixify_path_separators(fname, fname_len); #endif basename = zend_memrchr(fname, '/', fname_len); if (!basename) { basename = fname; } else { ++basename; } if ((sapi_mod_name_len == sizeof("cgi-fcgi") - 1 && !strncmp(sapi_module.name, "cgi-fcgi", sizeof("cgi-fcgi") - 1)) || (sapi_mod_name_len == sizeof("fpm-fcgi") - 1 && !strncmp(sapi_module.name, "fpm-fcgi", sizeof("fpm-fcgi") - 1)) || (sapi_mod_name_len == sizeof("cgi") - 1 && !strncmp(sapi_module.name, "cgi", sizeof("cgi") - 1))) { if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) != IS_UNDEF) { HashTable *_server = Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]); zval *z_script_name, *z_path_info; if (NULL == (z_script_name = zend_hash_str_find(_server, "SCRIPT_NAME", sizeof("SCRIPT_NAME")-1)) || IS_STRING != Z_TYPE_P(z_script_name) || !strstr(Z_STRVAL_P(z_script_name), basename)) { return; } if (NULL != (z_path_info = zend_hash_str_find(_server, "PATH_INFO", sizeof("PATH_INFO")-1)) && IS_STRING == Z_TYPE_P(z_path_info)) { entry_len = Z_STRLEN_P(z_path_info); entry = estrndup(Z_STRVAL_P(z_path_info), entry_len); path_info = emalloc(Z_STRLEN_P(z_script_name) + entry_len + 1); memcpy(path_info, Z_STRVAL_P(z_script_name), Z_STRLEN_P(z_script_name)); memcpy(path_info + Z_STRLEN_P(z_script_name), entry, entry_len + 1); free_pathinfo = 1; } else { entry_len = 0; entry = estrndup("", 0); path_info = Z_STRVAL_P(z_script_name); } pt = estrndup(Z_STRVAL_P(z_script_name), Z_STRLEN_P(z_script_name)); } else { char *testit; testit = sapi_getenv("SCRIPT_NAME", sizeof("SCRIPT_NAME")-1); if (!(pt = strstr(testit, basename))) { efree(testit); return; } path_info = sapi_getenv("PATH_INFO", sizeof("PATH_INFO")-1); if (path_info) { entry = path_info; entry_len = strlen(entry); spprintf(&path_info, 0, "%s%s", testit, path_info); free_pathinfo = 1; } else { path_info = testit; free_pathinfo = 1; entry = estrndup("", 0); entry_len = 0; } pt = estrndup(testit, (pt - testit) + (fname_len - (basename - fname))); } not_cgi = 0; } else { path_info = SG(request_info).request_uri; if (!(pt = strstr(path_info, basename))) { /* this can happen with rewrite rules - and we have no idea what to do then, so return */ return; } entry_len = strlen(path_info); entry_len -= (pt - path_info) + (fname_len - (basename - fname)); entry = estrndup(pt + (fname_len - (basename - fname)), entry_len); pt = estrndup(path_info, (pt - path_info) + (fname_len - (basename - fname))); not_cgi = 1; } if (rewrite) { zend_fcall_info fci; zend_fcall_info_cache fcc; zval params, retval; ZVAL_STRINGL(&params, entry, entry_len); if (FAILURE == zend_fcall_info_init(rewrite, 0, &fci, &fcc, NULL, NULL)) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: invalid rewrite callback"); if (free_pathinfo) { efree(path_info); } return; } fci.param_count = 1; fci.params = &params; Z_ADDREF(params); fci.retval = &retval; if (FAILURE == zend_call_function(&fci, &fcc)) { if (!EG(exception)) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: failed to call rewrite callback"); } if (free_pathinfo) { efree(path_info); } return; } if (Z_TYPE_P(fci.retval) == IS_UNDEF || Z_TYPE(retval) == IS_UNDEF) { if (free_pathinfo) { efree(path_info); } zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: rewrite callback must return a string or false"); return; } switch (Z_TYPE(retval)) { case IS_STRING: efree(entry); entry = estrndup(Z_STRVAL_P(fci.retval), Z_STRLEN_P(fci.retval)); entry_len = Z_STRLEN_P(fci.retval); break; case IS_TRUE: case IS_FALSE: phar_do_403(entry, entry_len); if (free_pathinfo) { efree(path_info); } zend_bailout(); return; default: if (free_pathinfo) { efree(path_info); } zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: rewrite callback must return a string or false"); return; } } if (entry_len) { phar_postprocess_ru_web(fname, fname_len, &entry, &entry_len, &ru, &ru_len); } if (!entry_len || (entry_len == 1 && entry[0] == '/')) { efree(entry); /* direct request */ if (index_php_len) { entry = index_php; entry_len = index_php_len; if (entry[0] != '/') { spprintf(&entry, 0, "/%s", index_php); ++entry_len; } } else { /* assume "index.php" is starting point */ entry = estrndup("/index.php", sizeof("/index.php")); entry_len = sizeof("/index.php")-1; } if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, NULL) || (info = phar_get_entry_info(phar, entry, entry_len, NULL, 0)) == NULL) { phar_do_404(phar, fname, fname_len, f404, f404_len, entry, entry_len); if (free_pathinfo) { efree(path_info); } zend_bailout(); } else { char *tmp = NULL, sa = '\0'; sapi_header_line ctr = {0}; ctr.response_code = 301; ctr.line_len = sizeof("HTTP/1.1 301 Moved Permanently")-1; ctr.line = "HTTP/1.1 301 Moved Permanently"; sapi_header_op(SAPI_HEADER_REPLACE, &ctr); if (not_cgi) { tmp = strstr(path_info, basename) + fname_len; sa = *tmp; *tmp = '\0'; } ctr.response_code = 0; if (path_info[strlen(path_info)-1] == '/') { ctr.line_len = spprintf(&(ctr.line), 4096, "Location: %s%s", path_info, entry + 1); } else { ctr.line_len = spprintf(&(ctr.line), 4096, "Location: %s%s", path_info, entry); } if (not_cgi) { *tmp = sa; } if (free_pathinfo) { efree(path_info); } sapi_header_op(SAPI_HEADER_REPLACE, &ctr); sapi_send_headers(); efree(ctr.line); zend_bailout(); } } if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, NULL) || (info = phar_get_entry_info(phar, entry, entry_len, NULL, 0)) == NULL) { phar_do_404(phar, fname, fname_len, f404, f404_len, entry, entry_len); #ifdef PHP_WIN32 efree(fname); #endif zend_bailout(); } if (mimeoverride && zend_hash_num_elements(Z_ARRVAL_P(mimeoverride))) { const char *ext = zend_memrchr(entry, '.', entry_len); zval *val; if (ext) { ++ext; if (NULL != (val = zend_hash_str_find(Z_ARRVAL_P(mimeoverride), ext, strlen(ext)))) { switch (Z_TYPE_P(val)) { case IS_LONG: if (Z_LVAL_P(val) == PHAR_MIME_PHP || Z_LVAL_P(val) == PHAR_MIME_PHPS) { mime_type = ""; code = Z_LVAL_P(val); } else { zend_throw_exception_ex(phar_ce_PharException, 0, "Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed"); if (free_pathinfo) { efree(path_info); } efree(pt); efree(entry); #ifdef PHP_WIN32 efree(fname); #endif RETURN_FALSE; } break; case IS_STRING: mime_type = Z_STRVAL_P(val); code = PHAR_MIME_OTHER; break; default: zend_throw_exception_ex(phar_ce_PharException, 0, "Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed"); if (free_pathinfo) { efree(path_info); } efree(pt); efree(entry); #ifdef PHP_WIN32 efree(fname); #endif RETURN_FALSE; } } } } if (!mime_type) { code = phar_file_type(&PHAR_G(mime_types), entry, &mime_type); } phar_file_action(phar, info, mime_type, code, entry, entry_len, fname, pt, ru, ru_len); }
Exec Code
0
PHP_METHOD(Phar, webPhar) { zval *mimeoverride = NULL, *rewrite = NULL; char *alias = NULL, *error, *index_php = NULL, *f404 = NULL, *ru = NULL; size_t alias_len = 0, f404_len = 0, free_pathinfo = 0; int ru_len = 0; char *fname, *path_info, *mime_type = NULL, *entry, *pt; const char *basename; size_t fname_len, index_php_len = 0; int entry_len, code, not_cgi; phar_archive_data *phar = NULL; phar_entry_info *info = NULL; size_t sapi_mod_name_len = strlen(sapi_module.name); if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!saz", &alias, &alias_len, &index_php, &index_php_len, &f404, &f404_len, &mimeoverride, &rewrite) == FAILURE) { return; } phar_request_initialize(); fname = (char*)zend_get_executed_filename(); fname_len = strlen(fname); if (phar_open_executed_filename(alias, alias_len, &error) != SUCCESS) { if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); efree(error); } return; } /* retrieve requested file within phar */ if (!(SG(request_info).request_method && SG(request_info).request_uri && (!strcmp(SG(request_info).request_method, "GET") || !strcmp(SG(request_info).request_method, "POST")))) { return; } #ifdef PHP_WIN32 fname = estrndup(fname, fname_len); phar_unixify_path_separators(fname, fname_len); #endif basename = zend_memrchr(fname, '/', fname_len); if (!basename) { basename = fname; } else { ++basename; } if ((sapi_mod_name_len == sizeof("cgi-fcgi") - 1 && !strncmp(sapi_module.name, "cgi-fcgi", sizeof("cgi-fcgi") - 1)) || (sapi_mod_name_len == sizeof("fpm-fcgi") - 1 && !strncmp(sapi_module.name, "fpm-fcgi", sizeof("fpm-fcgi") - 1)) || (sapi_mod_name_len == sizeof("cgi") - 1 && !strncmp(sapi_module.name, "cgi", sizeof("cgi") - 1))) { if (Z_TYPE(PG(http_globals)[TRACK_VARS_SERVER]) != IS_UNDEF) { HashTable *_server = Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]); zval *z_script_name, *z_path_info; if (NULL == (z_script_name = zend_hash_str_find(_server, "SCRIPT_NAME", sizeof("SCRIPT_NAME")-1)) || IS_STRING != Z_TYPE_P(z_script_name) || !strstr(Z_STRVAL_P(z_script_name), basename)) { return; } if (NULL != (z_path_info = zend_hash_str_find(_server, "PATH_INFO", sizeof("PATH_INFO")-1)) && IS_STRING == Z_TYPE_P(z_path_info)) { entry_len = Z_STRLEN_P(z_path_info); entry = estrndup(Z_STRVAL_P(z_path_info), entry_len); path_info = emalloc(Z_STRLEN_P(z_script_name) + entry_len + 1); memcpy(path_info, Z_STRVAL_P(z_script_name), Z_STRLEN_P(z_script_name)); memcpy(path_info + Z_STRLEN_P(z_script_name), entry, entry_len + 1); free_pathinfo = 1; } else { entry_len = 0; entry = estrndup("", 0); path_info = Z_STRVAL_P(z_script_name); } pt = estrndup(Z_STRVAL_P(z_script_name), Z_STRLEN_P(z_script_name)); } else { char *testit; testit = sapi_getenv("SCRIPT_NAME", sizeof("SCRIPT_NAME")-1); if (!(pt = strstr(testit, basename))) { efree(testit); return; } path_info = sapi_getenv("PATH_INFO", sizeof("PATH_INFO")-1); if (path_info) { entry = path_info; entry_len = strlen(entry); spprintf(&path_info, 0, "%s%s", testit, path_info); free_pathinfo = 1; } else { path_info = testit; free_pathinfo = 1; entry = estrndup("", 0); entry_len = 0; } pt = estrndup(testit, (pt - testit) + (fname_len - (basename - fname))); } not_cgi = 0; } else { path_info = SG(request_info).request_uri; if (!(pt = strstr(path_info, basename))) { /* this can happen with rewrite rules - and we have no idea what to do then, so return */ return; } entry_len = strlen(path_info); entry_len -= (pt - path_info) + (fname_len - (basename - fname)); entry = estrndup(pt + (fname_len - (basename - fname)), entry_len); pt = estrndup(path_info, (pt - path_info) + (fname_len - (basename - fname))); not_cgi = 1; } if (rewrite) { zend_fcall_info fci; zend_fcall_info_cache fcc; zval params, retval; ZVAL_STRINGL(&params, entry, entry_len); if (FAILURE == zend_fcall_info_init(rewrite, 0, &fci, &fcc, NULL, NULL)) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: invalid rewrite callback"); if (free_pathinfo) { efree(path_info); } return; } fci.param_count = 1; fci.params = &params; Z_ADDREF(params); fci.retval = &retval; if (FAILURE == zend_call_function(&fci, &fcc)) { if (!EG(exception)) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: failed to call rewrite callback"); } if (free_pathinfo) { efree(path_info); } return; } if (Z_TYPE_P(fci.retval) == IS_UNDEF || Z_TYPE(retval) == IS_UNDEF) { if (free_pathinfo) { efree(path_info); } zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: rewrite callback must return a string or false"); return; } switch (Z_TYPE(retval)) { case IS_STRING: efree(entry); entry = estrndup(Z_STRVAL_P(fci.retval), Z_STRLEN_P(fci.retval)); entry_len = Z_STRLEN_P(fci.retval); break; case IS_TRUE: case IS_FALSE: phar_do_403(entry, entry_len); if (free_pathinfo) { efree(path_info); } zend_bailout(); return; default: if (free_pathinfo) { efree(path_info); } zend_throw_exception_ex(phar_ce_PharException, 0, "phar error: rewrite callback must return a string or false"); return; } } if (entry_len) { phar_postprocess_ru_web(fname, fname_len, &entry, &entry_len, &ru, &ru_len); } if (!entry_len || (entry_len == 1 && entry[0] == '/')) { efree(entry); /* direct request */ if (index_php_len) { entry = index_php; entry_len = index_php_len; if (entry[0] != '/') { spprintf(&entry, 0, "/%s", index_php); ++entry_len; } } else { /* assume "index.php" is starting point */ entry = estrndup("/index.php", sizeof("/index.php")); entry_len = sizeof("/index.php")-1; } if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, NULL) || (info = phar_get_entry_info(phar, entry, entry_len, NULL, 0)) == NULL) { phar_do_404(phar, fname, fname_len, f404, f404_len, entry, entry_len); if (free_pathinfo) { efree(path_info); } zend_bailout(); } else { char *tmp = NULL, sa = '\0'; sapi_header_line ctr = {0}; ctr.response_code = 301; ctr.line_len = sizeof("HTTP/1.1 301 Moved Permanently")-1; ctr.line = "HTTP/1.1 301 Moved Permanently"; sapi_header_op(SAPI_HEADER_REPLACE, &ctr); if (not_cgi) { tmp = strstr(path_info, basename) + fname_len; sa = *tmp; *tmp = '\0'; } ctr.response_code = 0; if (path_info[strlen(path_info)-1] == '/') { ctr.line_len = spprintf(&(ctr.line), 4096, "Location: %s%s", path_info, entry + 1); } else { ctr.line_len = spprintf(&(ctr.line), 4096, "Location: %s%s", path_info, entry); } if (not_cgi) { *tmp = sa; } if (free_pathinfo) { efree(path_info); } sapi_header_op(SAPI_HEADER_REPLACE, &ctr); sapi_send_headers(); efree(ctr.line); zend_bailout(); } } if (FAILURE == phar_get_archive(&phar, fname, fname_len, NULL, 0, NULL) || (info = phar_get_entry_info(phar, entry, entry_len, NULL, 0)) == NULL) { phar_do_404(phar, fname, fname_len, f404, f404_len, entry, entry_len); #ifdef PHP_WIN32 efree(fname); #endif zend_bailout(); } if (mimeoverride && zend_hash_num_elements(Z_ARRVAL_P(mimeoverride))) { const char *ext = zend_memrchr(entry, '.', entry_len); zval *val; if (ext) { ++ext; if (NULL != (val = zend_hash_str_find(Z_ARRVAL_P(mimeoverride), ext, strlen(ext)))) { switch (Z_TYPE_P(val)) { case IS_LONG: if (Z_LVAL_P(val) == PHAR_MIME_PHP || Z_LVAL_P(val) == PHAR_MIME_PHPS) { mime_type = ""; code = Z_LVAL_P(val); } else { zend_throw_exception_ex(phar_ce_PharException, 0, "Unknown mime type specifier used, only Phar::PHP, Phar::PHPS and a mime type string are allowed"); if (free_pathinfo) { efree(path_info); } efree(pt); efree(entry); #ifdef PHP_WIN32 efree(fname); #endif RETURN_FALSE; } break; case IS_STRING: mime_type = Z_STRVAL_P(val); code = PHAR_MIME_OTHER; break; default: zend_throw_exception_ex(phar_ce_PharException, 0, "Unknown mime type specifier used (not a string or int), only Phar::PHP, Phar::PHPS and a mime type string are allowed"); if (free_pathinfo) { efree(path_info); } efree(pt); efree(entry); #ifdef PHP_WIN32 efree(fname); #endif RETURN_FALSE; } } } } if (!mime_type) { code = phar_file_type(&PHAR_G(mime_types), entry, &mime_type); } phar_file_action(phar, info, mime_type, code, entry, entry_len, fname, pt, ru, ru_len); }
@@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount) size_t path_len, actual_len; phar_archive_data *pphar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) { return; } @@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub) zend_string *stub; size_t index_len = 0, webindex_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) { return; } @@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar) char *fname, *alias = NULL, *error; size_t fname_len, alias_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { return; } @@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename) int ext_len, is_executable; zend_bool executable = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) { return; } @@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct) is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data); if (is_data) { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { return; } } else { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { return; } } @@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive) int zname_len, arch_len, entry_len; phar_archive_data *phar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { RETURN_FALSE; } @@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { return; } @@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet) zend_string *sfname; PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet) return; } - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE - && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE + && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) { return; } @@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { return; } @@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { return; } @@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct) phar_archive_data *phar_data; zval *zobj = getThis(), arg1; - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; }
CWE-20
null
null
8,882
PHP_METHOD(Phar, mungServer) { zval *mungvalues, *data; if (zend_parse_parameters(ZEND_NUM_ARGS(), "a", &mungvalues) == FAILURE) { return; } if (!zend_hash_num_elements(Z_ARRVAL_P(mungvalues))) { zend_throw_exception_ex(phar_ce_PharException, 0, "No values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME"); return; } if (zend_hash_num_elements(Z_ARRVAL_P(mungvalues)) > 4) { zend_throw_exception_ex(phar_ce_PharException, 0, "Too many values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME"); return; } phar_request_initialize(); ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(mungvalues), data) { if (Z_TYPE_P(data) != IS_STRING) { zend_throw_exception_ex(phar_ce_PharException, 0, "Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME"); return; } if (Z_STRLEN_P(data) == sizeof("PHP_SELF")-1 && !strncmp(Z_STRVAL_P(data), "PHP_SELF", sizeof("PHP_SELF")-1)) { PHAR_G(phar_SERVER_mung_list) |= PHAR_MUNG_PHP_SELF; } if (Z_STRLEN_P(data) == sizeof("REQUEST_URI")-1) { if (!strncmp(Z_STRVAL_P(data), "REQUEST_URI", sizeof("REQUEST_URI")-1)) { PHAR_G(phar_SERVER_mung_list) |= PHAR_MUNG_REQUEST_URI; } if (!strncmp(Z_STRVAL_P(data), "SCRIPT_NAME", sizeof("SCRIPT_NAME")-1)) { PHAR_G(phar_SERVER_mung_list) |= PHAR_MUNG_SCRIPT_NAME; } } if (Z_STRLEN_P(data) == sizeof("SCRIPT_FILENAME")-1 && !strncmp(Z_STRVAL_P(data), "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME")-1)) { PHAR_G(phar_SERVER_mung_list) |= PHAR_MUNG_SCRIPT_FILENAME; } } ZEND_HASH_FOREACH_END(); }
Exec Code
0
PHP_METHOD(Phar, mungServer) { zval *mungvalues, *data; if (zend_parse_parameters(ZEND_NUM_ARGS(), "a", &mungvalues) == FAILURE) { return; } if (!zend_hash_num_elements(Z_ARRVAL_P(mungvalues))) { zend_throw_exception_ex(phar_ce_PharException, 0, "No values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME"); return; } if (zend_hash_num_elements(Z_ARRVAL_P(mungvalues)) > 4) { zend_throw_exception_ex(phar_ce_PharException, 0, "Too many values passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME"); return; } phar_request_initialize(); ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(mungvalues), data) { if (Z_TYPE_P(data) != IS_STRING) { zend_throw_exception_ex(phar_ce_PharException, 0, "Non-string value passed to Phar::mungServer(), expecting an array of any of these strings: PHP_SELF, REQUEST_URI, SCRIPT_FILENAME, SCRIPT_NAME"); return; } if (Z_STRLEN_P(data) == sizeof("PHP_SELF")-1 && !strncmp(Z_STRVAL_P(data), "PHP_SELF", sizeof("PHP_SELF")-1)) { PHAR_G(phar_SERVER_mung_list) |= PHAR_MUNG_PHP_SELF; } if (Z_STRLEN_P(data) == sizeof("REQUEST_URI")-1) { if (!strncmp(Z_STRVAL_P(data), "REQUEST_URI", sizeof("REQUEST_URI")-1)) { PHAR_G(phar_SERVER_mung_list) |= PHAR_MUNG_REQUEST_URI; } if (!strncmp(Z_STRVAL_P(data), "SCRIPT_NAME", sizeof("SCRIPT_NAME")-1)) { PHAR_G(phar_SERVER_mung_list) |= PHAR_MUNG_SCRIPT_NAME; } } if (Z_STRLEN_P(data) == sizeof("SCRIPT_FILENAME")-1 && !strncmp(Z_STRVAL_P(data), "SCRIPT_FILENAME", sizeof("SCRIPT_FILENAME")-1)) { PHAR_G(phar_SERVER_mung_list) |= PHAR_MUNG_SCRIPT_FILENAME; } } ZEND_HASH_FOREACH_END(); }
@@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount) size_t path_len, actual_len; phar_archive_data *pphar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) { return; } @@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub) zend_string *stub; size_t index_len = 0, webindex_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) { return; } @@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar) char *fname, *alias = NULL, *error; size_t fname_len, alias_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { return; } @@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename) int ext_len, is_executable; zend_bool executable = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) { return; } @@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct) is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data); if (is_data) { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { return; } } else { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { return; } } @@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive) int zname_len, arch_len, entry_len; phar_archive_data *phar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { RETURN_FALSE; } @@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { return; } @@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet) zend_string *sfname; PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet) return; } - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE - && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE + && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) { return; } @@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { return; } @@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { return; } @@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct) phar_archive_data *phar_data; zval *zobj = getThis(), arg1; - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; }
CWE-20
null
null
8,883
PHP_METHOD(Phar, interceptFileFuncs) { if (zend_parse_parameters_none() == FAILURE) { return; } phar_intercept_functions(); }
Exec Code
0
PHP_METHOD(Phar, interceptFileFuncs) { if (zend_parse_parameters_none() == FAILURE) { return; } phar_intercept_functions(); }
@@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount) size_t path_len, actual_len; phar_archive_data *pphar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) { return; } @@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub) zend_string *stub; size_t index_len = 0, webindex_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) { return; } @@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar) char *fname, *alias = NULL, *error; size_t fname_len, alias_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { return; } @@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename) int ext_len, is_executable; zend_bool executable = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) { return; } @@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct) is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data); if (is_data) { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { return; } } else { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { return; } } @@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive) int zname_len, arch_len, entry_len; phar_archive_data *phar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { RETURN_FALSE; } @@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { return; } @@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet) zend_string *sfname; PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet) return; } - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE - && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE + && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) { return; } @@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { return; } @@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { return; } @@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct) phar_archive_data *phar_data; zval *zobj = getThis(), arg1; - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; }
CWE-20
null
null
8,884
PHP_METHOD(Phar, mapPhar) { char *alias = NULL, *error; size_t alias_len = 0; zend_long dataoffset = 0; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!l", &alias, &alias_len, &dataoffset) == FAILURE) { return; } phar_request_initialize(); RETVAL_BOOL(phar_open_executed_filename(alias, alias_len, &error) == SUCCESS); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); efree(error); } } /* }}} */ /* {{{ proto mixed Phar::loadPhar(string filename [, string alias])
Exec Code
0
PHP_METHOD(Phar, mapPhar) { char *alias = NULL, *error; size_t alias_len = 0; zend_long dataoffset = 0; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!l", &alias, &alias_len, &dataoffset) == FAILURE) { return; } phar_request_initialize(); RETVAL_BOOL(phar_open_executed_filename(alias, alias_len, &error) == SUCCESS); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); efree(error); } } /* }}} */ /* {{{ proto mixed Phar::loadPhar(string filename [, string alias])
@@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount) size_t path_len, actual_len; phar_archive_data *pphar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) { return; } @@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub) zend_string *stub; size_t index_len = 0, webindex_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) { return; } @@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar) char *fname, *alias = NULL, *error; size_t fname_len, alias_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { return; } @@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename) int ext_len, is_executable; zend_bool executable = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) { return; } @@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct) is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data); if (is_data) { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { return; } } else { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { return; } } @@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive) int zname_len, arch_len, entry_len; phar_archive_data *phar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { RETURN_FALSE; } @@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { return; } @@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet) zend_string *sfname; PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet) return; } - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE - && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE + && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) { return; } @@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { return; } @@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { return; } @@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct) phar_archive_data *phar_data; zval *zobj = getThis(), arg1; - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; }
CWE-20
null
null
8,885
PHP_METHOD(Phar, apiVersion) { if (zend_parse_parameters_none() == FAILURE) { return; } RETURN_STRINGL(PHP_PHAR_API_VERSION, sizeof(PHP_PHAR_API_VERSION)-1); }
Exec Code
0
PHP_METHOD(Phar, apiVersion) { if (zend_parse_parameters_none() == FAILURE) { return; } RETURN_STRINGL(PHP_PHAR_API_VERSION, sizeof(PHP_PHAR_API_VERSION)-1); }
@@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount) size_t path_len, actual_len; phar_archive_data *pphar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) { return; } @@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub) zend_string *stub; size_t index_len = 0, webindex_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) { return; } @@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar) char *fname, *alias = NULL, *error; size_t fname_len, alias_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { return; } @@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename) int ext_len, is_executable; zend_bool executable = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) { return; } @@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct) is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data); if (is_data) { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { return; } } else { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { return; } } @@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive) int zname_len, arch_len, entry_len; phar_archive_data *phar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { RETURN_FALSE; } @@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { return; } @@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet) zend_string *sfname; PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet) return; } - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE - && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE + && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) { return; } @@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { return; } @@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { return; } @@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct) phar_archive_data *phar_data; zval *zobj = getThis(), arg1; - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; }
CWE-20
null
null
8,886
PHP_METHOD(Phar, canCompress) { zend_long method = 0; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &method) == FAILURE) { return; } phar_request_initialize(); switch (method) { case PHAR_ENT_COMPRESSED_GZ: if (PHAR_G(has_zlib)) { RETURN_TRUE; } else { RETURN_FALSE; } case PHAR_ENT_COMPRESSED_BZ2: if (PHAR_G(has_bz2)) { RETURN_TRUE; } else { RETURN_FALSE; } default: if (PHAR_G(has_zlib) || PHAR_G(has_bz2)) { RETURN_TRUE; } else { RETURN_FALSE; } } }
Exec Code
0
PHP_METHOD(Phar, canCompress) { zend_long method = 0; if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &method) == FAILURE) { return; } phar_request_initialize(); switch (method) { case PHAR_ENT_COMPRESSED_GZ: if (PHAR_G(has_zlib)) { RETURN_TRUE; } else { RETURN_FALSE; } case PHAR_ENT_COMPRESSED_BZ2: if (PHAR_G(has_bz2)) { RETURN_TRUE; } else { RETURN_FALSE; } default: if (PHAR_G(has_zlib) || PHAR_G(has_bz2)) { RETURN_TRUE; } else { RETURN_FALSE; } } }
@@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount) size_t path_len, actual_len; phar_archive_data *pphar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) { return; } @@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub) zend_string *stub; size_t index_len = 0, webindex_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) { return; } @@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar) char *fname, *alias = NULL, *error; size_t fname_len, alias_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { return; } @@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename) int ext_len, is_executable; zend_bool executable = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) { return; } @@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct) is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data); if (is_data) { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { return; } } else { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { return; } } @@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive) int zname_len, arch_len, entry_len; phar_archive_data *phar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { RETURN_FALSE; } @@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { return; } @@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet) zend_string *sfname; PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet) return; } - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE - && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE + && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) { return; } @@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { return; } @@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { return; } @@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct) phar_archive_data *phar_data; zval *zobj = getThis(), arg1; - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; }
CWE-20
null
null
8,887
PHP_METHOD(Phar, getSupportedSignatures) { if (zend_parse_parameters_none() == FAILURE) { return; } array_init(return_value); add_next_index_stringl(return_value, "MD5", 3); add_next_index_stringl(return_value, "SHA-1", 5); #ifdef PHAR_HASH_OK add_next_index_stringl(return_value, "SHA-256", 7); add_next_index_stringl(return_value, "SHA-512", 7); #endif #if PHAR_HAVE_OPENSSL add_next_index_stringl(return_value, "OpenSSL", 7); #else if (zend_hash_str_exists(&module_registry, "openssl", sizeof("openssl")-1)) { add_next_index_stringl(return_value, "OpenSSL", 7); } #endif }
Exec Code
0
PHP_METHOD(Phar, getSupportedSignatures) { if (zend_parse_parameters_none() == FAILURE) { return; } array_init(return_value); add_next_index_stringl(return_value, "MD5", 3); add_next_index_stringl(return_value, "SHA-1", 5); #ifdef PHAR_HASH_OK add_next_index_stringl(return_value, "SHA-256", 7); add_next_index_stringl(return_value, "SHA-512", 7); #endif #if PHAR_HAVE_OPENSSL add_next_index_stringl(return_value, "OpenSSL", 7); #else if (zend_hash_str_exists(&module_registry, "openssl", sizeof("openssl")-1)) { add_next_index_stringl(return_value, "OpenSSL", 7); } #endif }
@@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount) size_t path_len, actual_len; phar_archive_data *pphar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) { return; } @@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub) zend_string *stub; size_t index_len = 0, webindex_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) { return; } @@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar) char *fname, *alias = NULL, *error; size_t fname_len, alias_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { return; } @@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename) int ext_len, is_executable; zend_bool executable = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) { return; } @@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct) is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data); if (is_data) { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { return; } } else { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { return; } } @@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive) int zname_len, arch_len, entry_len; phar_archive_data *phar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { RETURN_FALSE; } @@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { return; } @@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet) zend_string *sfname; PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet) return; } - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE - && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE + && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) { return; } @@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { return; } @@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { return; } @@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct) phar_archive_data *phar_data; zval *zobj = getThis(), arg1; - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; }
CWE-20
null
null
8,888
PHP_METHOD(Phar, getSupportedCompression) { if (zend_parse_parameters_none() == FAILURE) { return; } array_init(return_value); phar_request_initialize(); if (PHAR_G(has_zlib)) { add_next_index_stringl(return_value, "GZ", 2); } if (PHAR_G(has_bz2)) { add_next_index_stringl(return_value, "BZIP2", 5); } }
Exec Code
0
PHP_METHOD(Phar, getSupportedCompression) { if (zend_parse_parameters_none() == FAILURE) { return; } array_init(return_value); phar_request_initialize(); if (PHAR_G(has_zlib)) { add_next_index_stringl(return_value, "GZ", 2); } if (PHAR_G(has_bz2)) { add_next_index_stringl(return_value, "BZIP2", 5); } }
@@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount) size_t path_len, actual_len; phar_archive_data *pphar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) { return; } @@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub) zend_string *stub; size_t index_len = 0, webindex_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) { return; } @@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar) char *fname, *alias = NULL, *error; size_t fname_len, alias_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { return; } @@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename) int ext_len, is_executable; zend_bool executable = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) { return; } @@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct) is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data); if (is_data) { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { return; } } else { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { return; } } @@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive) int zname_len, arch_len, entry_len; phar_archive_data *phar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { RETURN_FALSE; } @@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { return; } @@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet) zend_string *sfname; PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet) return; } - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE - && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE + && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) { return; } @@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { return; } @@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { return; } @@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct) phar_archive_data *phar_data; zval *zobj = getThis(), arg1; - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; }
CWE-20
null
null
8,889
PHP_METHOD(Phar, __destruct) { zval *zobj = getThis(); phar_archive_object *phar_obj = (phar_archive_object*)((char*)Z_OBJ_P(zobj) - Z_OBJ_P(zobj)->handlers->offset); if (phar_obj->archive && phar_obj->archive->is_persistent) { zend_hash_str_del(&PHAR_G(phar_persist_map), (const char *) phar_obj->archive, sizeof(phar_obj->archive)); } }
Exec Code
0
PHP_METHOD(Phar, __destruct) { zval *zobj = getThis(); phar_archive_object *phar_obj = (phar_archive_object*)((char*)Z_OBJ_P(zobj) - Z_OBJ_P(zobj)->handlers->offset); if (phar_obj->archive && phar_obj->archive->is_persistent) { zend_hash_str_del(&PHAR_G(phar_persist_map), (const char *) phar_obj->archive, sizeof(phar_obj->archive)); } }
@@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount) size_t path_len, actual_len; phar_archive_data *pphar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) { return; } @@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub) zend_string *stub; size_t index_len = 0, webindex_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) { return; } @@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar) char *fname, *alias = NULL, *error; size_t fname_len, alias_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { return; } @@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename) int ext_len, is_executable; zend_bool executable = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) { return; } @@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct) is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data); if (is_data) { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { return; } } else { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { return; } } @@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive) int zname_len, arch_len, entry_len; phar_archive_data *phar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { RETURN_FALSE; } @@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { return; } @@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet) zend_string *sfname; PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet) return; } - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE - && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE + && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) { return; } @@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { return; } @@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { return; } @@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct) phar_archive_data *phar_data; zval *zobj = getThis(), arg1; - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; }
CWE-20
null
null
8,890
PHP_METHOD(Phar, buildFromIterator) { zval *obj; char *error; size_t base_len = 0; char *base = NULL; struct _phar_t pass; PHAR_ARCHIVE_OBJECT(); if (PHAR_G(readonly) && !phar_obj->archive->is_data) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Cannot write out phar archive, phar is read-only"); return; } if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|s", &obj, zend_ce_traversable, &base, &base_len) == FAILURE) { RETURN_FALSE; } if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname); return; } array_init(return_value); pass.c = Z_OBJCE_P(obj); pass.p = phar_obj; pass.b = base; pass.l = base_len; pass.ret = return_value; pass.count = 0; pass.fp = php_stream_fopen_tmpfile(); if (pass.fp == NULL) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\": unable to create temporary file", phar_obj->archive->fname); return; } if (SUCCESS == spl_iterator_apply(obj, (spl_iterator_apply_func_t) phar_build, (void *) &pass)) { phar_obj->archive->ufp = pass.fp; phar_flush(phar_obj->archive, 0, 0, 0, &error); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); efree(error); } } else { php_stream_close(pass.fp); } }
Exec Code
0
PHP_METHOD(Phar, buildFromIterator) { zval *obj; char *error; size_t base_len = 0; char *base = NULL; struct _phar_t pass; PHAR_ARCHIVE_OBJECT(); if (PHAR_G(readonly) && !phar_obj->archive->is_data) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Cannot write out phar archive, phar is read-only"); return; } if (zend_parse_parameters(ZEND_NUM_ARGS(), "O|s", &obj, zend_ce_traversable, &base, &base_len) == FAILURE) { RETURN_FALSE; } if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname); return; } array_init(return_value); pass.c = Z_OBJCE_P(obj); pass.p = phar_obj; pass.b = base; pass.l = base_len; pass.ret = return_value; pass.count = 0; pass.fp = php_stream_fopen_tmpfile(); if (pass.fp == NULL) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\": unable to create temporary file", phar_obj->archive->fname); return; } if (SUCCESS == spl_iterator_apply(obj, (spl_iterator_apply_func_t) phar_build, (void *) &pass)) { phar_obj->archive->ufp = pass.fp; phar_flush(phar_obj->archive, 0, 0, 0, &error); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); efree(error); } } else { php_stream_close(pass.fp); } }
@@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount) size_t path_len, actual_len; phar_archive_data *pphar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) { return; } @@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub) zend_string *stub; size_t index_len = 0, webindex_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) { return; } @@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar) char *fname, *alias = NULL, *error; size_t fname_len, alias_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { return; } @@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename) int ext_len, is_executable; zend_bool executable = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) { return; } @@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct) is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data); if (is_data) { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { return; } } else { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { return; } } @@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive) int zname_len, arch_len, entry_len; phar_archive_data *phar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { RETURN_FALSE; } @@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { return; } @@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet) zend_string *sfname; PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet) return; } - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE - && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE + && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) { return; } @@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { return; } @@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { return; } @@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct) phar_archive_data *phar_data; zval *zobj = getThis(), arg1; - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; }
CWE-20
null
null
8,891
PHP_METHOD(Phar, isFileFormat) { zend_long type; PHAR_ARCHIVE_OBJECT(); if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &type) == FAILURE) { RETURN_FALSE; } switch (type) { case PHAR_FORMAT_TAR: RETURN_BOOL(phar_obj->archive->is_tar); case PHAR_FORMAT_ZIP: RETURN_BOOL(phar_obj->archive->is_zip); case PHAR_FORMAT_PHAR: RETURN_BOOL(!phar_obj->archive->is_tar && !phar_obj->archive->is_zip); default: zend_throw_exception_ex(phar_ce_PharException, 0, "Unknown file format specified"); } }
Exec Code
0
PHP_METHOD(Phar, isFileFormat) { zend_long type; PHAR_ARCHIVE_OBJECT(); if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &type) == FAILURE) { RETURN_FALSE; } switch (type) { case PHAR_FORMAT_TAR: RETURN_BOOL(phar_obj->archive->is_tar); case PHAR_FORMAT_ZIP: RETURN_BOOL(phar_obj->archive->is_zip); case PHAR_FORMAT_PHAR: RETURN_BOOL(!phar_obj->archive->is_tar && !phar_obj->archive->is_zip); default: zend_throw_exception_ex(phar_ce_PharException, 0, "Unknown file format specified"); } }
@@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount) size_t path_len, actual_len; phar_archive_data *pphar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) { return; } @@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub) zend_string *stub; size_t index_len = 0, webindex_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) { return; } @@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar) char *fname, *alias = NULL, *error; size_t fname_len, alias_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { return; } @@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename) int ext_len, is_executable; zend_bool executable = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) { return; } @@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct) is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data); if (is_data) { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { return; } } else { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { return; } } @@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive) int zname_len, arch_len, entry_len; phar_archive_data *phar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { RETURN_FALSE; } @@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { return; } @@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet) zend_string *sfname; PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet) return; } - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE - && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE + && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) { return; } @@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { return; } @@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { return; } @@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct) phar_archive_data *phar_data; zval *zobj = getThis(), arg1; - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; }
CWE-20
null
null
8,892
PHP_METHOD(Phar, isCompressed) { PHAR_ARCHIVE_OBJECT(); if (zend_parse_parameters_none() == FAILURE) { return; } if (phar_obj->archive->flags & PHAR_FILE_COMPRESSED_GZ) { RETURN_LONG(PHAR_ENT_COMPRESSED_GZ); } if (phar_obj->archive->flags & PHAR_FILE_COMPRESSED_BZ2) { RETURN_LONG(PHAR_ENT_COMPRESSED_BZ2); } RETURN_FALSE; }
Exec Code
0
PHP_METHOD(Phar, isCompressed) { PHAR_ARCHIVE_OBJECT(); if (zend_parse_parameters_none() == FAILURE) { return; } if (phar_obj->archive->flags & PHAR_FILE_COMPRESSED_GZ) { RETURN_LONG(PHAR_ENT_COMPRESSED_GZ); } if (phar_obj->archive->flags & PHAR_FILE_COMPRESSED_BZ2) { RETURN_LONG(PHAR_ENT_COMPRESSED_BZ2); } RETURN_FALSE; }
@@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount) size_t path_len, actual_len; phar_archive_data *pphar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) { return; } @@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub) zend_string *stub; size_t index_len = 0, webindex_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) { return; } @@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar) char *fname, *alias = NULL, *error; size_t fname_len, alias_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { return; } @@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename) int ext_len, is_executable; zend_bool executable = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) { return; } @@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct) is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data); if (is_data) { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { return; } } else { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { return; } } @@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive) int zname_len, arch_len, entry_len; phar_archive_data *phar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { RETURN_FALSE; } @@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { return; } @@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet) zend_string *sfname; PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet) return; } - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE - && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE + && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) { return; } @@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { return; } @@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { return; } @@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct) phar_archive_data *phar_data; zval *zobj = getThis(), arg1; - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; }
CWE-20
null
null
8,893
PHP_METHOD(Phar, isWritable) { php_stream_statbuf ssb; PHAR_ARCHIVE_OBJECT(); if (zend_parse_parameters_none() == FAILURE) { return; } if (!phar_obj->archive->is_writeable) { RETURN_FALSE; } if (SUCCESS != php_stream_stat_path(phar_obj->archive->fname, &ssb)) { if (phar_obj->archive->is_brandnew) { /* assume it works if the file doesn't exist yet */ RETURN_TRUE; } RETURN_FALSE; } RETURN_BOOL((ssb.sb.st_mode & (S_IWOTH | S_IWGRP | S_IWUSR)) != 0); }
Exec Code
0
PHP_METHOD(Phar, isWritable) { php_stream_statbuf ssb; PHAR_ARCHIVE_OBJECT(); if (zend_parse_parameters_none() == FAILURE) { return; } if (!phar_obj->archive->is_writeable) { RETURN_FALSE; } if (SUCCESS != php_stream_stat_path(phar_obj->archive->fname, &ssb)) { if (phar_obj->archive->is_brandnew) { /* assume it works if the file doesn't exist yet */ RETURN_TRUE; } RETURN_FALSE; } RETURN_BOOL((ssb.sb.st_mode & (S_IWOTH | S_IWGRP | S_IWUSR)) != 0); }
@@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount) size_t path_len, actual_len; phar_archive_data *pphar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) { return; } @@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub) zend_string *stub; size_t index_len = 0, webindex_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) { return; } @@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar) char *fname, *alias = NULL, *error; size_t fname_len, alias_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { return; } @@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename) int ext_len, is_executable; zend_bool executable = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) { return; } @@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct) is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data); if (is_data) { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { return; } } else { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { return; } } @@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive) int zname_len, arch_len, entry_len; phar_archive_data *phar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { RETURN_FALSE; } @@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { return; } @@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet) zend_string *sfname; PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet) return; } - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE - && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE + && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) { return; } @@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { return; } @@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { return; } @@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct) phar_archive_data *phar_data; zval *zobj = getThis(), arg1; - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; }
CWE-20
null
null
8,894
PHP_METHOD(Phar, getPath) { PHAR_ARCHIVE_OBJECT(); if (zend_parse_parameters_none() == FAILURE) { return; } RETURN_STRINGL(phar_obj->archive->fname, phar_obj->archive->fname_len); }
Exec Code
0
PHP_METHOD(Phar, getPath) { PHAR_ARCHIVE_OBJECT(); if (zend_parse_parameters_none() == FAILURE) { return; } RETURN_STRINGL(phar_obj->archive->fname, phar_obj->archive->fname_len); }
@@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount) size_t path_len, actual_len; phar_archive_data *pphar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) { return; } @@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub) zend_string *stub; size_t index_len = 0, webindex_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) { return; } @@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar) char *fname, *alias = NULL, *error; size_t fname_len, alias_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { return; } @@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename) int ext_len, is_executable; zend_bool executable = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) { return; } @@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct) is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data); if (is_data) { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { return; } } else { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { return; } } @@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive) int zname_len, arch_len, entry_len; phar_archive_data *phar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { RETURN_FALSE; } @@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { return; } @@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet) zend_string *sfname; PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet) return; } - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE - && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE + && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) { return; } @@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { return; } @@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { return; } @@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct) phar_archive_data *phar_data; zval *zobj = getThis(), arg1; - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; }
CWE-20
null
null
8,895
PHP_METHOD(Phar, setAlias) { char *alias, *error, *oldalias; phar_archive_data *fd_ptr; size_t alias_len, oldalias_len; int old_temp, readd = 0; PHAR_ARCHIVE_OBJECT(); if (PHAR_G(readonly) && !phar_obj->archive->is_data) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Cannot write out phar archive, phar is read-only"); RETURN_FALSE; } /* invalidate phar cache */ PHAR_G(last_phar) = NULL; PHAR_G(last_phar_name) = PHAR_G(last_alias) = NULL; if (phar_obj->archive->is_data) { if (phar_obj->archive->is_tar) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "A Phar alias cannot be set in a plain tar archive"); } else { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "A Phar alias cannot be set in a plain zip archive"); } RETURN_FALSE; } if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &alias, &alias_len) == SUCCESS) { if (alias_len == phar_obj->archive->alias_len && memcmp(phar_obj->archive->alias, alias, alias_len) == 0) { RETURN_TRUE; } if (alias_len && NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len))) { spprintf(&error, 0, "alias \"%s\" is already used for archive \"%s\" and cannot be used for other archives", alias, fd_ptr->fname); if (SUCCESS == phar_free_alias(fd_ptr, alias, alias_len)) { efree(error); goto valid_alias; } zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); efree(error); RETURN_FALSE; } if (!phar_validate_alias(alias, alias_len)) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Invalid alias \"%s\" specified for phar \"%s\"", alias, phar_obj->archive->fname); RETURN_FALSE; } valid_alias: if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname); return; } if (phar_obj->archive->alias_len && NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), phar_obj->archive->alias, phar_obj->archive->alias_len))) { zend_hash_str_del(&(PHAR_G(phar_alias_map)), phar_obj->archive->alias, phar_obj->archive->alias_len); readd = 1; } oldalias = phar_obj->archive->alias; oldalias_len = phar_obj->archive->alias_len; old_temp = phar_obj->archive->is_temporary_alias; if (alias_len) { phar_obj->archive->alias = estrndup(alias, alias_len); } else { phar_obj->archive->alias = NULL; } phar_obj->archive->alias_len = alias_len; phar_obj->archive->is_temporary_alias = 0; phar_flush(phar_obj->archive, NULL, 0, 0, &error); if (error) { phar_obj->archive->alias = oldalias; phar_obj->archive->alias_len = oldalias_len; phar_obj->archive->is_temporary_alias = old_temp; zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); if (readd) { zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), oldalias, oldalias_len, phar_obj->archive); } efree(error); RETURN_FALSE; } zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len, phar_obj->archive); if (oldalias) { efree(oldalias); } RETURN_TRUE; } RETURN_FALSE; }
Exec Code
0
PHP_METHOD(Phar, setAlias) { char *alias, *error, *oldalias; phar_archive_data *fd_ptr; size_t alias_len, oldalias_len; int old_temp, readd = 0; PHAR_ARCHIVE_OBJECT(); if (PHAR_G(readonly) && !phar_obj->archive->is_data) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Cannot write out phar archive, phar is read-only"); RETURN_FALSE; } /* invalidate phar cache */ PHAR_G(last_phar) = NULL; PHAR_G(last_phar_name) = PHAR_G(last_alias) = NULL; if (phar_obj->archive->is_data) { if (phar_obj->archive->is_tar) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "A Phar alias cannot be set in a plain tar archive"); } else { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "A Phar alias cannot be set in a plain zip archive"); } RETURN_FALSE; } if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &alias, &alias_len) == SUCCESS) { if (alias_len == phar_obj->archive->alias_len && memcmp(phar_obj->archive->alias, alias, alias_len) == 0) { RETURN_TRUE; } if (alias_len && NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len))) { spprintf(&error, 0, "alias \"%s\" is already used for archive \"%s\" and cannot be used for other archives", alias, fd_ptr->fname); if (SUCCESS == phar_free_alias(fd_ptr, alias, alias_len)) { efree(error); goto valid_alias; } zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); efree(error); RETURN_FALSE; } if (!phar_validate_alias(alias, alias_len)) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Invalid alias \"%s\" specified for phar \"%s\"", alias, phar_obj->archive->fname); RETURN_FALSE; } valid_alias: if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname); return; } if (phar_obj->archive->alias_len && NULL != (fd_ptr = zend_hash_str_find_ptr(&(PHAR_G(phar_alias_map)), phar_obj->archive->alias, phar_obj->archive->alias_len))) { zend_hash_str_del(&(PHAR_G(phar_alias_map)), phar_obj->archive->alias, phar_obj->archive->alias_len); readd = 1; } oldalias = phar_obj->archive->alias; oldalias_len = phar_obj->archive->alias_len; old_temp = phar_obj->archive->is_temporary_alias; if (alias_len) { phar_obj->archive->alias = estrndup(alias, alias_len); } else { phar_obj->archive->alias = NULL; } phar_obj->archive->alias_len = alias_len; phar_obj->archive->is_temporary_alias = 0; phar_flush(phar_obj->archive, NULL, 0, 0, &error); if (error) { phar_obj->archive->alias = oldalias; phar_obj->archive->alias_len = oldalias_len; phar_obj->archive->is_temporary_alias = old_temp; zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); if (readd) { zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), oldalias, oldalias_len, phar_obj->archive); } efree(error); RETURN_FALSE; } zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), alias, alias_len, phar_obj->archive); if (oldalias) { efree(oldalias); } RETURN_TRUE; } RETURN_FALSE; }
@@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount) size_t path_len, actual_len; phar_archive_data *pphar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) { return; } @@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub) zend_string *stub; size_t index_len = 0, webindex_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) { return; } @@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar) char *fname, *alias = NULL, *error; size_t fname_len, alias_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { return; } @@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename) int ext_len, is_executable; zend_bool executable = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) { return; } @@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct) is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data); if (is_data) { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { return; } } else { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { return; } } @@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive) int zname_len, arch_len, entry_len; phar_archive_data *phar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { RETURN_FALSE; } @@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { return; } @@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet) zend_string *sfname; PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet) return; } - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE - && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE + && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) { return; } @@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { return; } @@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { return; } @@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct) phar_archive_data *phar_data; zval *zobj = getThis(), arg1; - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; }
CWE-20
null
null
8,896
PHP_METHOD(Phar, getVersion) { PHAR_ARCHIVE_OBJECT(); if (zend_parse_parameters_none() == FAILURE) { return; } RETURN_STRING(phar_obj->archive->version); }
Exec Code
0
PHP_METHOD(Phar, getVersion) { PHAR_ARCHIVE_OBJECT(); if (zend_parse_parameters_none() == FAILURE) { return; } RETURN_STRING(phar_obj->archive->version); }
@@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount) size_t path_len, actual_len; phar_archive_data *pphar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) { return; } @@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub) zend_string *stub; size_t index_len = 0, webindex_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) { return; } @@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar) char *fname, *alias = NULL, *error; size_t fname_len, alias_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { return; } @@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename) int ext_len, is_executable; zend_bool executable = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) { return; } @@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct) is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data); if (is_data) { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { return; } } else { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { return; } } @@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive) int zname_len, arch_len, entry_len; phar_archive_data *phar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { RETURN_FALSE; } @@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { return; } @@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet) zend_string *sfname; PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet) return; } - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE - && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE + && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) { return; } @@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { return; } @@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { return; } @@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct) phar_archive_data *phar_data; zval *zobj = getThis(), arg1; - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; }
CWE-20
null
null
8,897
PHP_METHOD(Phar, startBuffering) { PHAR_ARCHIVE_OBJECT(); if (zend_parse_parameters_none() == FAILURE) { return; } phar_obj->archive->donotflush = 1; }
Exec Code
0
PHP_METHOD(Phar, startBuffering) { PHAR_ARCHIVE_OBJECT(); if (zend_parse_parameters_none() == FAILURE) { return; } phar_obj->archive->donotflush = 1; }
@@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount) size_t path_len, actual_len; phar_archive_data *pphar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) { return; } @@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub) zend_string *stub; size_t index_len = 0, webindex_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) { return; } @@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar) char *fname, *alias = NULL, *error; size_t fname_len, alias_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { return; } @@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename) int ext_len, is_executable; zend_bool executable = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) { return; } @@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct) is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data); if (is_data) { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { return; } } else { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { return; } } @@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive) int zname_len, arch_len, entry_len; phar_archive_data *phar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { RETURN_FALSE; } @@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { return; } @@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet) zend_string *sfname; PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet) return; } - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE - && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE + && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) { return; } @@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { return; } @@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { return; } @@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct) phar_archive_data *phar_data; zval *zobj = getThis(), arg1; - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; }
CWE-20
null
null
8,898
PHP_METHOD(Phar, setStub) { zval *zstub; char *stub, *error; size_t stub_len; zend_long len = -1; php_stream *stream; PHAR_ARCHIVE_OBJECT(); if (PHAR_G(readonly) && !phar_obj->archive->is_data) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Cannot change stub, phar is read-only"); return; } if (phar_obj->archive->is_data) { if (phar_obj->archive->is_tar) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "A Phar stub cannot be set in a plain tar archive"); } else { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "A Phar stub cannot be set in a plain zip archive"); } return; } if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "r|l", &zstub, &len) == SUCCESS) { if ((php_stream_from_zval_no_verify(stream, zstub)) != NULL) { if (len > 0) { len = -len; } else { len = -1; } if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname); return; } phar_flush(phar_obj->archive, (char *) zstub, len, 0, &error); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); efree(error); } RETURN_TRUE; } else { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Cannot change stub, unable to read from input stream"); } } else if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &stub, &stub_len) == SUCCESS) { if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname); return; } phar_flush(phar_obj->archive, stub, stub_len, 0, &error); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); efree(error); } RETURN_TRUE; } RETURN_FALSE; }
Exec Code
0
PHP_METHOD(Phar, setStub) { zval *zstub; char *stub, *error; size_t stub_len; zend_long len = -1; php_stream *stream; PHAR_ARCHIVE_OBJECT(); if (PHAR_G(readonly) && !phar_obj->archive->is_data) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Cannot change stub, phar is read-only"); return; } if (phar_obj->archive->is_data) { if (phar_obj->archive->is_tar) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "A Phar stub cannot be set in a plain tar archive"); } else { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "A Phar stub cannot be set in a plain zip archive"); } return; } if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "r|l", &zstub, &len) == SUCCESS) { if ((php_stream_from_zval_no_verify(stream, zstub)) != NULL) { if (len > 0) { len = -len; } else { len = -1; } if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname); return; } phar_flush(phar_obj->archive, (char *) zstub, len, 0, &error); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); efree(error); } RETURN_TRUE; } else { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Cannot change stub, unable to read from input stream"); } } else if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &stub, &stub_len) == SUCCESS) { if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname); return; } phar_flush(phar_obj->archive, stub, stub_len, 0, &error); if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); efree(error); } RETURN_TRUE; } RETURN_FALSE; }
@@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount) size_t path_len, actual_len; phar_archive_data *pphar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) { return; } @@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub) zend_string *stub; size_t index_len = 0, webindex_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) { return; } @@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar) char *fname, *alias = NULL, *error; size_t fname_len, alias_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { return; } @@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename) int ext_len, is_executable; zend_bool executable = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) { return; } @@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct) is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data); if (is_data) { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { return; } } else { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { return; } } @@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive) int zname_len, arch_len, entry_len; phar_archive_data *phar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { RETURN_FALSE; } @@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { return; } @@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet) zend_string *sfname; PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet) return; } - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE - && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE + && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) { return; } @@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { return; } @@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { return; } @@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct) phar_archive_data *phar_data; zval *zobj = getThis(), arg1; - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; }
CWE-20
null
null
8,899
PHP_METHOD(Phar, setDefaultStub) { char *index = NULL, *webindex = NULL, *error = NULL; zend_string *stub = NULL; size_t index_len = 0, webindex_len = 0; int created_stub = 0; PHAR_ARCHIVE_OBJECT(); if (phar_obj->archive->is_data) { if (phar_obj->archive->is_tar) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "A Phar stub cannot be set in a plain tar archive"); } else { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "A Phar stub cannot be set in a plain zip archive"); } return; } if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s", &index, &index_len, &webindex, &webindex_len) == FAILURE) { RETURN_FALSE; } if (ZEND_NUM_ARGS() > 0 && (phar_obj->archive->is_tar || phar_obj->archive->is_zip)) { php_error_docref(NULL, E_WARNING, "method accepts no arguments for a tar- or zip-based phar stub, %d given", ZEND_NUM_ARGS()); RETURN_FALSE; } if (PHAR_G(readonly)) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Cannot change stub: phar.readonly=1"); RETURN_FALSE; } if (!phar_obj->archive->is_tar && !phar_obj->archive->is_zip) { stub = phar_create_default_stub(index, webindex, &error); if (error) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "%s", error); efree(error); if (stub) { zend_string_free(stub); } RETURN_FALSE; } created_stub = 1; } if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname); return; } phar_flush(phar_obj->archive, stub ? ZSTR_VAL(stub) : 0, stub ? ZSTR_LEN(stub) : 0, 1, &error); if (created_stub) { zend_string_free(stub); } if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); efree(error); RETURN_FALSE; } RETURN_TRUE; }
Exec Code
0
PHP_METHOD(Phar, setDefaultStub) { char *index = NULL, *webindex = NULL, *error = NULL; zend_string *stub = NULL; size_t index_len = 0, webindex_len = 0; int created_stub = 0; PHAR_ARCHIVE_OBJECT(); if (phar_obj->archive->is_data) { if (phar_obj->archive->is_tar) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "A Phar stub cannot be set in a plain tar archive"); } else { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "A Phar stub cannot be set in a plain zip archive"); } return; } if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s", &index, &index_len, &webindex, &webindex_len) == FAILURE) { RETURN_FALSE; } if (ZEND_NUM_ARGS() > 0 && (phar_obj->archive->is_tar || phar_obj->archive->is_zip)) { php_error_docref(NULL, E_WARNING, "method accepts no arguments for a tar- or zip-based phar stub, %d given", ZEND_NUM_ARGS()); RETURN_FALSE; } if (PHAR_G(readonly)) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "Cannot change stub: phar.readonly=1"); RETURN_FALSE; } if (!phar_obj->archive->is_tar && !phar_obj->archive->is_zip) { stub = phar_create_default_stub(index, webindex, &error); if (error) { zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0, "%s", error); efree(error); if (stub) { zend_string_free(stub); } RETURN_FALSE; } created_stub = 1; } if (phar_obj->archive->is_persistent && FAILURE == phar_copy_on_write(&(phar_obj->archive))) { zend_throw_exception_ex(phar_ce_PharException, 0, "phar \"%s\" is persistent, unable to copy on write", phar_obj->archive->fname); return; } phar_flush(phar_obj->archive, stub ? ZSTR_VAL(stub) : 0, stub ? ZSTR_LEN(stub) : 0, 1, &error); if (created_stub) { zend_string_free(stub); } if (error) { zend_throw_exception_ex(phar_ce_PharException, 0, "%s", error); efree(error); RETURN_FALSE; } RETURN_TRUE; }
@@ -459,7 +459,7 @@ PHP_METHOD(Phar, mount) size_t path_len, actual_len; phar_archive_data *pphar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &path, &path_len, &actual, &actual_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &path, &path_len, &actual, &actual_len) == FAILURE) { return; } @@ -938,7 +938,7 @@ PHP_METHOD(Phar, createDefaultStub) zend_string *stub; size_t index_len = 0, webindex_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ss", &index, &index_len, &webindex, &webindex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|pp", &index, &index_len, &webindex, &webindex_len) == FAILURE) { return; } @@ -982,7 +982,7 @@ PHP_METHOD(Phar, loadPhar) char *fname, *alias = NULL, *error; size_t fname_len, alias_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s!", &fname, &fname_len, &alias, &alias_len) == FAILURE) { return; } @@ -1062,7 +1062,7 @@ PHP_METHOD(Phar, isValidPharFilename) int ext_len, is_executable; zend_bool executable = 1; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|b", &fname, &fname_len, &executable) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|b", &fname, &fname_len, &executable) == FAILURE) { return; } @@ -1134,11 +1134,11 @@ PHP_METHOD(Phar, __construct) is_data = instanceof_function(Z_OBJCE_P(zobj), phar_ce_data); if (is_data) { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!l", &fname, &fname_len, &flags, &alias, &alias_len, &format) == FAILURE) { return; } } else { - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p|ls!", &fname, &fname_len, &flags, &alias, &alias_len) == FAILURE) { return; } } @@ -1307,7 +1307,7 @@ PHP_METHOD(Phar, unlinkArchive) int zname_len, arch_len, entry_len; phar_archive_data *phar; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -1739,7 +1739,7 @@ PHP_METHOD(Phar, buildFromDirectory) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &dir, &dir_len, &regex, &regex_len) == FAILURE) { RETURN_FALSE; } @@ -2586,7 +2586,7 @@ PHP_METHOD(Phar, delete) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { RETURN_FALSE; } @@ -3400,7 +3400,7 @@ PHP_METHOD(Phar, copy) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "pp", &oldfile, &oldfile_len, &newfile, &newfile_len) == FAILURE) { return; } @@ -3500,7 +3500,7 @@ PHP_METHOD(Phar, offsetExists) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3538,7 +3538,7 @@ PHP_METHOD(Phar, offsetGet) zend_string *sfname; PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3685,8 +3685,8 @@ PHP_METHOD(Phar, offsetSet) return; } - if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "sr", &fname, &fname_len, &zresource) == FAILURE - && zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "pr", &fname, &fname_len, &zresource) == FAILURE + && zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &fname, &fname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -3724,7 +3724,7 @@ PHP_METHOD(Phar, offsetUnset) return; } - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; } @@ -3771,7 +3771,7 @@ PHP_METHOD(Phar, addEmptyDir) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &dirname, &dirname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p", &dirname, &dirname_len) == FAILURE) { return; } @@ -3796,7 +3796,7 @@ PHP_METHOD(Phar, addFile) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|s", &fname, &fname_len, &localname, &localname_len) == FAILURE) { return; } @@ -3838,7 +3838,7 @@ PHP_METHOD(Phar, addFromString) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ps", &localname, &localname_len, &cont_str, &cont_len) == FAILURE) { return; } @@ -4264,7 +4264,7 @@ PHP_METHOD(Phar, extractTo) PHAR_ARCHIVE_OBJECT(); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "p|z!b", &pathto, &pathto_len, &zval_files, &overwrite) == FAILURE) { return; } @@ -4396,7 +4396,7 @@ PHP_METHOD(PharFileInfo, __construct) phar_archive_data *phar_data; zval *zobj = getThis(), arg1; - if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "s", &fname, &fname_len) == FAILURE) { + if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "p", &fname, &fname_len) == FAILURE) { return; }
CWE-20
null
null