pike.git / lib / modules / Protocols.pmod / LDAP.pmod / protocol.pike

version» Context lines:

pike.git/lib/modules/Protocols.pmod/LDAP.pmod/protocol.pike:1:   #pike __REAL_VERSION__      // LDAP client protocol implementation for Pike.   // - // $Id: protocol.pike,v 1.8 2002/07/22 16:15:40 bill Exp $ + // $Id: protocol.pike,v 1.9 2003/01/20 17:44:01 nilsson Exp $   //   // Honza Petrous, hop@unibase.cz   //   // ----------------------------------------------------------------------   //   // History:   //   // v1.9 1999-02-19 created separate file   // - improved checking of readed bytes in 'readmsg'   // v1.9.1.1
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/protocol.pike:72:    array error() { return(({error_number(), error_string()})); }          static void read_answer() {    // ----------------------    // Reads LDAP PDU (with defined msgid) from the server       int msglen = 0, ix, ofs;    string s, shlp;    -  if(strlen(readbuf) < 2) +  if(sizeof(readbuf) < 2)    readbuf = ldapfd->read(2); // 1. byte = 0x0C, 2. byte = msglen -  if (intp(readbuf) || (strlen(readbuf) < 2)) { +  if (intp(readbuf) || (sizeof(readbuf) < 2)) {    seterr (LDAP_TIMEOUT);    DWRITE_HI("protocol.read_anwer: ERROR: connection timeout.\n");    THROW(({"LDAP: connection timeout.\n",backtrace()}));    //return(-ldap_errno);    return;    }    if (readbuf[0] != '0') {    seterr (LDAP_PROTOCOL_ERROR);    DWRITE_HI("protocol.read_anwer: ERROR: retv=<"+sprintf("%O",readbuf)+">\n");    THROW(({"LDAP: Protocol mismatch.\n",backtrace()}));
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/protocol.pike:100:    msglen = readbuf[1];    ofs = 2;    if (msglen & 0x80) { // > 0x7f    if (msglen == 0x80) { // RFC not allows unexplicitly defined length    seterr (LDAP_PROTOCOL_ERROR);    THROW(({"LDAP: Protocol mismatch.\n",backtrace()}));    //return(-ldap_errno);    return;    }    ofs = (msglen & 0x7f) + 2; -  ix = ofs - strlen(readbuf); +  ix = ofs - sizeof(readbuf);    if(ix > 0)    s = ldapfd->read(ix); -  if (!s || (strlen(s) < ix)) { +  if (!s || (sizeof(s) < ix)) {    seterr (LDAP_PROTOCOL_ERROR);    THROW(({"LDAP: Protocol mismatch.\n",backtrace()}));    //return(-ldap_errno);    return;    }    readbuf += s;    msglen = 0; // !!! RESTRICTION: 2^32 !!!    shlp = reverse(readbuf[2..ofs]); -  for (ix=0; ix<strlen(shlp); ix++) { +  for (ix=0; ix<sizeof(shlp); ix++) {    msglen += shlp[ix]*(1<<(ix*8));    }    } -  ix = (ofs + msglen) - strlen(readbuf); +  ix = (ofs + msglen) - sizeof(readbuf);    if(ix > 0)    s = ldapfd->read(ix); -  if (!s || (strlen(s) < ix)) { +  if (!s || (sizeof(s) < ix)) {    seterr (LDAP_SERVER_DOWN);    THROW(({"LDAP: connection closed by server.\n",backtrace()}));    //return(-ldap_errno);    return;    }    readbuf += s;    //DWRITE(sprintf("protocol.read_anwer: %s\n", .ldap_privates.ldap_der_decode(readbuf)->debug_string()));    DWRITE("protocol.read_anwer: ok=1.\n");    ok = 1;   
pike.git/lib/modules/Protocols.pmod/LDAP.pmod/protocol.pike:141:    con_ok(this_object(), @extra_args);    }       static int is_whole_pdu() {    // ----------------------    // Check if LDAP PDU is complete in 'readbuf'       int msglen, ix, ofs;    string shlp;    -  if (strlen(readbuf) < 3) +  if (sizeof(readbuf) < 3)    return(0); // PDU have min. 3 bytes       if (readbuf[0] != '0')    return(1); // PDU has bad header -> forced execution       msglen = readbuf[1];    if (msglen & 0x80) { // > 0x7f    if (msglen == 0x80)    return(1); // forced execution    ofs = (msglen & 0x7f) + 2; -  ix = ofs - strlen(readbuf); +  ix = ofs - sizeof(readbuf);    if(ix > 0)    return(0); // incomplete PDU    msglen = 0;    shlp = reverse(readbuf[2..ofs]); -  for (ix=0; ix<strlen(shlp); ix++) { +  for (ix=0; ix<sizeof(shlp); ix++) {    msglen += shlp[ix]*(1<<(ix*8));    }    } -  ix = (ofs + msglen) - strlen(readbuf); +  ix = (ofs + msglen) - sizeof(readbuf);    if(ix > 0)    return(0); // incomplete PDU       return(1);    }       void create(object fd) {    // -------------------    ldapfd = fd;    }