]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw ldap: safe_read_file can return < 0
authorMatt Benjamin <mbenjamin@redhat.com>
Fri, 4 Jan 2019 20:31:56 +0000 (15:31 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 4 Jan 2019 22:10:11 +0000 (17:10 -0500)
Avoid invalid string access when LDAP auth is enabled, but LDAP
secret is not set.  This is Casey's fix for the problem.

Fixes: https://tracker.ceph.com/issues/24228
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/rgw_ldap.cc

index 9c1e69476aae6bd1c6dec2cce30afa43142083ea..ffb82b9e2e694725efb6d28d6015b162e0b9e7c4 100644 (file)
@@ -27,7 +27,7 @@ std::string parse_rgw_ldap_bindpw(CephContext* ctx)
       memset(bindpw, 0, 1024);
       int pwlen = safe_read_file("" /* base */, ldap_secret.c_str(),
                                 bindpw, 1023);
-    if (pwlen) {
+    if (pwlen > 0) {
       ldap_bindpw = bindpw;
       boost::algorithm::trim(ldap_bindpw);
       if (ldap_bindpw.back() == '\n')