php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8176 ldap_search munges binary data
Submitted: 2000-12-08 14:59 UTC Modified: 2000-12-08 21:01 UTC
From: binkleym at nukote dot com Assigned:
Status: Closed Package: LDAP related
PHP Version: 4.0.3pl1 OS: Debian Woody (with latest update
Private report: No CVE-ID: None
 [2000-12-08 14:59 UTC] binkleym at nukote dot com
I have a clean installation of Debian Woody with PHP4, OpenLDAP 2, and the latest stable apt-get's.  I am trying to fetch a jpeg picture from the LDAP server with PHP, but I'm only getting 3-4 characters.  This looks similar to a previous LDAP bug (#5759)

I've run the script using PHP 4.0.3.pl1-7 and PHP 4.0.4-0RC3.2, and OpenLDAP 2.0.7-1.

Here's a sample script which generates the bug:

<?

Header( "Content-type: image/jpeg");

$ldap = ldap_connect("data2.nukote.com", "389");

$result = ldap_search($ldap, "o=nukote.com", "uid=binkleym");

if ($result) {
   $temp = ldap_get_entries($ldap, $result);
   if ($temp["count"] == 1) $entry = $temp[0];
}

ldap_close($ldap);

echo $entry["jpegphoto"][0];

?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-12-08 21:01 UTC] sniper@php.net
ldap_get_entries() is not  (yet) binary safe.  But this might change in
future versions.

Use ldap_get_values_len() instead.

Here is an example:

<?php

$ds=ldap_connect("localhost");
// Anonymous bind
$r=ldap_bind($ds);
if (!$r) {
    print ldap_error();
    exit();
}

$filter   = "cn=Test*";
$group    = "dc=mydomain, dc=com";
                 
$sr=ldap_search($ds,$group, $filter);
$entry = ldap_first_entry($ds,$sr);
$data = ldap_get_values_len($ds, $entry,"jpegphoto");
                 
header("Content-type: image/jpeg");
echo $data[0];

?>

I just tried this and it works just fine.

--Jani


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 12 21:01:28 2024 UTC