To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=76159


User sb changed the following:

                What    |Old value                 |New value
================================================================================
                      CC|'jkim,maho,sb,tra'        |'jkim,maho,obr,sb,tra'
--------------------------------------------------------------------------------




------- Additional comments from [EMAIL PROTECTED] Tue Apr 10 12:58:43 +0000 
2007 -------
This starts getting silly.  Issue 64769 introduces an #ifndef
_SC_GETPW_R_SIZE_MAX block to sal/osl/unx/system.h, defining it to 71 if not yet
defined.  Why 71?  I guess 71 is an arbitrary, hopefully unused value that
causes sysconf(71) to fail with EINVAL.

Grr.  If that guess is right, than the problem with the current security.c is
obvious.  But then, we should fix this in a direct way:

1  Completely remove the #ifndef _SC_GETPW_R_SIZE_MAX block from
sal/osl/unx/system.h.

2  Replace newSecurityImpl in sal/osl/unx/security.c (the only place that uses
_SC_GETPW_R_SIZE_MAX, btw) with something like

---8<---
enum Result { KNOWN, UNKNOWN, ERROR };

static Result sysconf_SC_GETPW_R_SIZE_MAX(size_t * value) {
#if ...<WHATEVER>...
    /* <WHATEVER> does not support sysconf(_SC_GETPW_R_SIZE_MAX): */
    return UNKNOWN;
#else
    long m;
    errno = 0;
    m = sysconf(_SC_GETPW_R_SIZE_MAX);
    if (m == -1) {
        if (errno == 0) {
            /* _SC_GETPW_R_SIZE_MAX has no limit: */
            return UNKNOWN;
        } else {
            /* sysconf failed: */
            return ERROR;
        }
    } else {
        OSL_ASSERT(m >= 0 && (unsigned long) m < SIZE_MAX);
        *value = (size_t) m;
        return KNOWN;
    }
#endif
}

static oslSecurityImpl * newSecurityImpl(size_t * bufSize) {
    size_t n;
    switch (sysconf_SC_GETPW_R_SIZE_MAX(&n)) {
    case KNOWN:
        break;
    case UNKNOWN:
        /* choose something sensible (the callers of newSecurityImpl should
           detect it if the allocated buffer is too small, so this could lead to
           an error upstream, but not a crash): */
        n = 1024;
        break;
    default: /* ERROR */
        return NULL;
    }
    if (n <= SIZE_MAX - offsetof(oslSecurityImpl, m_buffer)) {
        *bufSize = n;
        n += offsetof(oslSecurityImpl, m_buffer);
    } else {
        *bufSize = SIZE_MAX - offsetof(oslSecurityImpl, m_buffer);
        n = SIZE_MAX;
    }
    return malloc(n);
}
---8<---

---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to