idx
int64
func_before
string
Vulnerability Classification
string
vul
int64
func_after
string
patch
string
CWE ID
string
lines_before
string
lines_after
string
5,900
ZEND_API int zend_ts_hash_rehash(TsHashTable *ht) { int retval; begin_write(ht); retval = zend_hash_rehash(TS_HASH(ht)); end_write(ht); return retval; }
DoS
0
ZEND_API int zend_ts_hash_rehash(TsHashTable *ht) { int retval; begin_write(ht); retval = zend_hash_rehash(TS_HASH(ht)); end_write(ht); return retval; }
@@ -140,7 +140,7 @@ ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht) #ifdef ZTS tsrm_mutex_free(ht->mx_reader); - tsrm_mutex_free(ht->mx_reader); + tsrm_mutex_free(ht->mx_writer); #endif }
null
null
null
5,901
ZEND_API void zend_ts_hash_reverse_apply(TsHashTable *ht, apply_func_t apply_func) { begin_write(ht); zend_hash_reverse_apply(TS_HASH(ht), apply_func); end_write(ht); }
DoS
0
ZEND_API void zend_ts_hash_reverse_apply(TsHashTable *ht, apply_func_t apply_func) { begin_write(ht); zend_hash_reverse_apply(TS_HASH(ht), apply_func); end_write(ht); }
@@ -140,7 +140,7 @@ ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht) #ifdef ZTS tsrm_mutex_free(ht->mx_reader); - tsrm_mutex_free(ht->mx_reader); + tsrm_mutex_free(ht->mx_writer); #endif }
null
null
null
5,902
ZEND_API zval *zend_ts_hash_str_find(TsHashTable *ht, const char *key, size_t len) { zval *retval; begin_read(ht); retval = zend_hash_str_find(TS_HASH(ht), key, len); end_read(ht); return retval; }
DoS
0
ZEND_API zval *zend_ts_hash_str_find(TsHashTable *ht, const char *key, size_t len) { zval *retval; begin_read(ht); retval = zend_hash_str_find(TS_HASH(ht), key, len); end_read(ht); return retval; }
@@ -140,7 +140,7 @@ ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht) #ifdef ZTS tsrm_mutex_free(ht->mx_reader); - tsrm_mutex_free(ht->mx_reader); + tsrm_mutex_free(ht->mx_writer); #endif }
null
null
null
5,903
ZEND_API int _zend_ts_hash_init_ex(TsHashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection ZEND_FILE_LINE_DC) { #ifdef ZTS ht->mx_reader = tsrm_mutex_alloc(); ht->mx_writer = tsrm_mutex_alloc(); ht->reader = 0; #endif return _zend_hash_init_ex(TS_HASH(ht), nSize, pHashFunction, pDestructor, persistent, bApplyProtection ZEND_FILE_LINE_RELAY_CC); }
DoS
0
ZEND_API int _zend_ts_hash_init_ex(TsHashTable *ht, uint nSize, hash_func_t pHashFunction, dtor_func_t pDestructor, zend_bool persistent, zend_bool bApplyProtection ZEND_FILE_LINE_DC) { #ifdef ZTS ht->mx_reader = tsrm_mutex_alloc(); ht->mx_writer = tsrm_mutex_alloc(); ht->reader = 0; #endif return _zend_hash_init_ex(TS_HASH(ht), nSize, pHashFunction, pDestructor, persistent, bApplyProtection ZEND_FILE_LINE_RELAY_CC); }
@@ -151,7 +151,7 @@ ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht) #ifdef ZTS tsrm_mutex_free(ht->mx_reader); - tsrm_mutex_free(ht->mx_reader); + tsrm_mutex_free(ht->mx_writer); #endif }
null
null
null
5,904
ZEND_API int _zend_ts_hash_quick_add_or_update(TsHashTable *ht, char *arKey, uint nKeyLength, ulong h, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC) { int retval; begin_write(ht); retval = _zend_hash_quick_add_or_update(TS_HASH(ht), arKey, nKeyLength, h, pData, nDataSize, pDest, flag ZEND_FILE_LINE_RELAY_CC); end_write(ht); return retval; }
DoS
0
ZEND_API int _zend_ts_hash_quick_add_or_update(TsHashTable *ht, char *arKey, uint nKeyLength, ulong h, void *pData, uint nDataSize, void **pDest, int flag ZEND_FILE_LINE_DC) { int retval; begin_write(ht); retval = _zend_hash_quick_add_or_update(TS_HASH(ht), arKey, nKeyLength, h, pData, nDataSize, pDest, flag ZEND_FILE_LINE_RELAY_CC); end_write(ht); return retval; }
@@ -151,7 +151,7 @@ ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht) #ifdef ZTS tsrm_mutex_free(ht->mx_reader); - tsrm_mutex_free(ht->mx_reader); + tsrm_mutex_free(ht->mx_writer); #endif }
null
null
null
5,905
ZEND_API ulong zend_ts_get_hash_value(TsHashTable *ht, char *arKey, uint nKeyLength) { ulong retval; begin_read(ht); retval = zend_get_hash_value(arKey, nKeyLength); end_read(ht); return retval; }
DoS
0
ZEND_API ulong zend_ts_get_hash_value(TsHashTable *ht, char *arKey, uint nKeyLength) { ulong retval; begin_read(ht); retval = zend_get_hash_value(arKey, nKeyLength); end_read(ht); return retval; }
@@ -151,7 +151,7 @@ ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht) #ifdef ZTS tsrm_mutex_free(ht->mx_reader); - tsrm_mutex_free(ht->mx_reader); + tsrm_mutex_free(ht->mx_writer); #endif }
null
null
null
5,906
ZEND_API int zend_ts_hash_add_empty_element(TsHashTable *ht, char *arKey, uint nKeyLength) { int retval; begin_write(ht); retval = zend_hash_add_empty_element(TS_HASH(ht), arKey, nKeyLength); end_write(ht); return retval; }
DoS
0
ZEND_API int zend_ts_hash_add_empty_element(TsHashTable *ht, char *arKey, uint nKeyLength) { int retval; begin_write(ht); retval = zend_hash_add_empty_element(TS_HASH(ht), arKey, nKeyLength); end_write(ht); return retval; }
@@ -151,7 +151,7 @@ ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht) #ifdef ZTS tsrm_mutex_free(ht->mx_reader); - tsrm_mutex_free(ht->mx_reader); + tsrm_mutex_free(ht->mx_writer); #endif }
null
null
null
5,907
ZEND_API void zend_ts_hash_apply_with_argument(TsHashTable *ht, apply_func_arg_t apply_func, void *argument TSRMLS_DC) { begin_write(ht); zend_hash_apply_with_argument(TS_HASH(ht), apply_func, argument TSRMLS_CC); end_write(ht); }
DoS
0
ZEND_API void zend_ts_hash_apply_with_argument(TsHashTable *ht, apply_func_arg_t apply_func, void *argument TSRMLS_DC) { begin_write(ht); zend_hash_apply_with_argument(TS_HASH(ht), apply_func, argument TSRMLS_CC); end_write(ht); }
@@ -151,7 +151,7 @@ ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht) #ifdef ZTS tsrm_mutex_free(ht->mx_reader); - tsrm_mutex_free(ht->mx_reader); + tsrm_mutex_free(ht->mx_writer); #endif }
null
null
null
5,908
ZEND_API void zend_ts_hash_apply_with_arguments(TsHashTable *ht TSRMLS_DC, apply_func_args_t apply_func, int num_args, ...) { va_list args; va_start(args, num_args); begin_write(ht); zend_hash_apply_with_arguments(TS_HASH(ht) TSRMLS_CC, apply_func, num_args, args); end_write(ht); va_end(args); }
DoS
0
ZEND_API void zend_ts_hash_apply_with_arguments(TsHashTable *ht TSRMLS_DC, apply_func_args_t apply_func, int num_args, ...) { va_list args; va_start(args, num_args); begin_write(ht); zend_hash_apply_with_arguments(TS_HASH(ht) TSRMLS_CC, apply_func, num_args, args); end_write(ht); va_end(args); }
@@ -151,7 +151,7 @@ ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht) #ifdef ZTS tsrm_mutex_free(ht->mx_reader); - tsrm_mutex_free(ht->mx_reader); + tsrm_mutex_free(ht->mx_writer); #endif }
null
null
null
5,909
ZEND_API int zend_ts_hash_compare(TsHashTable *ht1, TsHashTable *ht2, compare_func_t compar, zend_bool ordered TSRMLS_DC) { int retval; begin_read(ht1); begin_read(ht2); retval = zend_hash_compare(TS_HASH(ht1), TS_HASH(ht2), compar, ordered TSRMLS_CC); end_read(ht2); end_read(ht1); return retval; }
DoS
0
ZEND_API int zend_ts_hash_compare(TsHashTable *ht1, TsHashTable *ht2, compare_func_t compar, zend_bool ordered TSRMLS_DC) { int retval; begin_read(ht1); begin_read(ht2); retval = zend_hash_compare(TS_HASH(ht1), TS_HASH(ht2), compar, ordered TSRMLS_CC); end_read(ht2); end_read(ht1); return retval; }
@@ -151,7 +151,7 @@ ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht) #ifdef ZTS tsrm_mutex_free(ht->mx_reader); - tsrm_mutex_free(ht->mx_reader); + tsrm_mutex_free(ht->mx_writer); #endif }
null
null
null
5,910
ZEND_API void zend_ts_hash_copy(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size) { begin_read(source); begin_write(target); zend_hash_copy(TS_HASH(target), TS_HASH(source), pCopyConstructor, tmp, size); end_write(target); end_read(source); }
DoS
0
ZEND_API void zend_ts_hash_copy(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size) { begin_read(source); begin_write(target); zend_hash_copy(TS_HASH(target), TS_HASH(source), pCopyConstructor, tmp, size); end_write(target); end_read(source); }
@@ -151,7 +151,7 @@ ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht) #ifdef ZTS tsrm_mutex_free(ht->mx_reader); - tsrm_mutex_free(ht->mx_reader); + tsrm_mutex_free(ht->mx_writer); #endif }
null
null
null
5,911
ZEND_API void zend_ts_hash_copy_to_hash(HashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size) { begin_read(source); zend_hash_copy(target, TS_HASH(source), pCopyConstructor, tmp, size); end_read(source); }
DoS
0
ZEND_API void zend_ts_hash_copy_to_hash(HashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, void *tmp, uint size) { begin_read(source); zend_hash_copy(target, TS_HASH(source), pCopyConstructor, tmp, size); end_read(source); }
@@ -151,7 +151,7 @@ ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht) #ifdef ZTS tsrm_mutex_free(ht->mx_reader); - tsrm_mutex_free(ht->mx_reader); + tsrm_mutex_free(ht->mx_writer); #endif }
null
null
null
5,912
void zend_ts_hash_display_pListTail(TsHashTable *ht) { begin_read(ht); zend_hash_display_pListTail(TS_HASH(ht)); end_read(ht); }
DoS
0
void zend_ts_hash_display_pListTail(TsHashTable *ht) { begin_read(ht); zend_hash_display_pListTail(TS_HASH(ht)); end_read(ht); }
@@ -151,7 +151,7 @@ ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht) #ifdef ZTS tsrm_mutex_free(ht->mx_reader); - tsrm_mutex_free(ht->mx_reader); + tsrm_mutex_free(ht->mx_writer); #endif }
null
null
null
5,913
ZEND_API int zend_ts_hash_exists(TsHashTable *ht, char *arKey, uint nKeyLength) { int retval; begin_read(ht); retval = zend_hash_exists(TS_HASH(ht), arKey, nKeyLength); end_read(ht); return retval; }
DoS
0
ZEND_API int zend_ts_hash_exists(TsHashTable *ht, char *arKey, uint nKeyLength) { int retval; begin_read(ht); retval = zend_hash_exists(TS_HASH(ht), arKey, nKeyLength); end_read(ht); return retval; }
@@ -151,7 +151,7 @@ ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht) #ifdef ZTS tsrm_mutex_free(ht->mx_reader); - tsrm_mutex_free(ht->mx_reader); + tsrm_mutex_free(ht->mx_writer); #endif }
null
null
null
5,914
ZEND_API void zend_ts_hash_merge_ex(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, uint size, merge_checker_func_t pMergeSource, void *pParam) { begin_read(source); begin_write(target); zend_hash_merge_ex(TS_HASH(target), TS_HASH(source), pCopyConstructor, size, pMergeSource, pParam); end_write(target); end_read(source); }
DoS
0
ZEND_API void zend_ts_hash_merge_ex(TsHashTable *target, TsHashTable *source, copy_ctor_func_t pCopyConstructor, uint size, merge_checker_func_t pMergeSource, void *pParam) { begin_read(source); begin_write(target); zend_hash_merge_ex(TS_HASH(target), TS_HASH(source), pCopyConstructor, size, pMergeSource, pParam); end_write(target); end_read(source); }
@@ -151,7 +151,7 @@ ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht) #ifdef ZTS tsrm_mutex_free(ht->mx_reader); - tsrm_mutex_free(ht->mx_reader); + tsrm_mutex_free(ht->mx_writer); #endif }
null
null
null
5,915
ZEND_API int zend_ts_hash_minmax(TsHashTable *ht, compare_func_t compar, int flag, void **pData TSRMLS_DC) { int retval; begin_read(ht); retval = zend_hash_minmax(TS_HASH(ht), compar, flag, pData TSRMLS_CC); end_read(ht); return retval; }
DoS
0
ZEND_API int zend_ts_hash_minmax(TsHashTable *ht, compare_func_t compar, int flag, void **pData TSRMLS_DC) { int retval; begin_read(ht); retval = zend_hash_minmax(TS_HASH(ht), compar, flag, pData TSRMLS_CC); end_read(ht); return retval; }
@@ -151,7 +151,7 @@ ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht) #ifdef ZTS tsrm_mutex_free(ht->mx_reader); - tsrm_mutex_free(ht->mx_reader); + tsrm_mutex_free(ht->mx_writer); #endif }
null
null
null
5,916
ZEND_API void zend_ts_hash_reverse_apply(TsHashTable *ht, apply_func_t apply_func TSRMLS_DC) { begin_write(ht); zend_hash_reverse_apply(TS_HASH(ht), apply_func TSRMLS_CC); end_write(ht); }
DoS
0
ZEND_API void zend_ts_hash_reverse_apply(TsHashTable *ht, apply_func_t apply_func TSRMLS_DC) { begin_write(ht); zend_hash_reverse_apply(TS_HASH(ht), apply_func TSRMLS_CC); end_write(ht); }
@@ -151,7 +151,7 @@ ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht) #ifdef ZTS tsrm_mutex_free(ht->mx_reader); - tsrm_mutex_free(ht->mx_reader); + tsrm_mutex_free(ht->mx_writer); #endif }
null
null
null
5,917
ZEND_API int zend_ts_hash_sort(TsHashTable *ht, sort_func_t sort_func, compare_func_t compare_func, int renumber TSRMLS_DC) { int retval; begin_write(ht); retval = zend_hash_sort(TS_HASH(ht), sort_func, compare_func, renumber TSRMLS_CC); end_write(ht); return retval; }
DoS
0
ZEND_API int zend_ts_hash_sort(TsHashTable *ht, sort_func_t sort_func, compare_func_t compare_func, int renumber TSRMLS_DC) { int retval; begin_write(ht); retval = zend_hash_sort(TS_HASH(ht), sort_func, compare_func, renumber TSRMLS_CC); end_write(ht); return retval; }
@@ -151,7 +151,7 @@ ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht) #ifdef ZTS tsrm_mutex_free(ht->mx_reader); - tsrm_mutex_free(ht->mx_reader); + tsrm_mutex_free(ht->mx_writer); #endif }
null
null
null
5,918
ZEND_API int _zend_ts_hash_init(TsHashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC) { #ifdef ZTS ht->mx_reader = tsrm_mutex_alloc(); ht->mx_writer = tsrm_mutex_alloc(); ht->reader = 0; #endif return _zend_hash_init(TS_HASH(ht), nSize, pDestructor, persistent ZEND_FILE_LINE_RELAY_CC); }
DoS
0
ZEND_API int _zend_ts_hash_init(TsHashTable *ht, uint nSize, dtor_func_t pDestructor, zend_bool persistent ZEND_FILE_LINE_DC) { #ifdef ZTS ht->mx_reader = tsrm_mutex_alloc(); ht->mx_writer = tsrm_mutex_alloc(); ht->reader = 0; #endif return _zend_hash_init(TS_HASH(ht), nSize, pDestructor, persistent ZEND_FILE_LINE_RELAY_CC); }
@@ -151,7 +151,7 @@ ZEND_API void zend_ts_hash_graceful_destroy(TsHashTable *ht) #ifdef ZTS tsrm_mutex_free(ht->mx_reader); - tsrm_mutex_free(ht->mx_reader); + tsrm_mutex_free(ht->mx_writer); #endif }
null
null
null
5,919
bool DBusHelperProxy::isCallerAuthorized(const QString &action, const QByteArray &callerID) { switch (BackendsManager::authBackend()->extraCallerIDVerificationMethod()) { case AuthBackend::NoExtraCallerIDVerificationMethod: break; case AuthBackend::VerifyAgainstDBusServiceName: if (message().service().toUtf8() != callerID) { return false; } break; case AuthBackend::VerifyAgainstDBusServicePid: if (connection().interface()->servicePid(message().service()).value() != callerID.toUInt()) { return false; } break; } return BackendsManager::authBackend()->isCallerAuthorized(action, callerID); }
null
0
bool DBusHelperProxy::isCallerAuthorized(const QString &action, const QByteArray &callerID) { switch (BackendsManager::authBackend()->extraCallerIDVerificationMethod()) { case AuthBackend::NoExtraCallerIDVerificationMethod: break; case AuthBackend::VerifyAgainstDBusServiceName: if (message().service().toUtf8() != callerID) { return false; } break; case AuthBackend::VerifyAgainstDBusServicePid: if (connection().interface()->servicePid(message().service()).value() != callerID.toUInt()) { return false; } break; } return BackendsManager::authBackend()->isCallerAuthorized(action, callerID); }
@@ -31,6 +31,8 @@ #include "kf5authadaptor.h" #include "kauthdebug.h" +extern Q_CORE_EXPORT const QMetaTypeInterface *qMetaTypeGuiHelper; + namespace KAuth { @@ -229,10 +231,17 @@ QByteArray DBusHelperProxy::performAction(const QString &action, const QByteArra return ActionReply::HelperBusyReply().serialized(); } + // Make sure we don't try restoring gui variants, in particular QImage/QPixmap/QIcon are super dangerous + // since they end up calling the image loaders and thus are a vector for crashing → executing code + auto origMetaTypeGuiHelper = qMetaTypeGuiHelper; + qMetaTypeGuiHelper = nullptr; + QVariantMap args; QDataStream s(&arguments, QIODevice::ReadOnly); s >> args; + qMetaTypeGuiHelper = origMetaTypeGuiHelper; + m_currentAction = action; emit remoteSignal(ActionStarted, action, QByteArray()); QEventLoop e;
CWE-20
null
null
5,920
QByteArray DBusHelperProxy::performAction(const QString &action, const QByteArray &callerID, QByteArray arguments) { if (!responder) { return ActionReply::NoResponderReply().serialized(); } if (!m_currentAction.isEmpty()) { return ActionReply::HelperBusyReply().serialized(); } return ActionReply::HelperBusyReply().serialized(); }
null
0
QByteArray DBusHelperProxy::performAction(const QString &action, const QByteArray &callerID, QByteArray arguments) { if (!responder) { return ActionReply::NoResponderReply().serialized(); } if (!m_currentAction.isEmpty()) { return ActionReply::HelperBusyReply().serialized(); } return ActionReply::HelperBusyReply().serialized(); }
@@ -31,6 +31,8 @@ #include "kf5authadaptor.h" #include "kauthdebug.h" +extern Q_CORE_EXPORT const QMetaTypeInterface *qMetaTypeGuiHelper; + namespace KAuth { @@ -229,10 +231,17 @@ QByteArray DBusHelperProxy::performAction(const QString &action, const QByteArra return ActionReply::HelperBusyReply().serialized(); } + // Make sure we don't try restoring gui variants, in particular QImage/QPixmap/QIcon are super dangerous + // since they end up calling the image loaders and thus are a vector for crashing → executing code + auto origMetaTypeGuiHelper = qMetaTypeGuiHelper; + qMetaTypeGuiHelper = nullptr; + QVariantMap args; QDataStream s(&arguments, QIODevice::ReadOnly); s >> args; + qMetaTypeGuiHelper = origMetaTypeGuiHelper; + m_currentAction = action; emit remoteSignal(ActionStarted, action, QByteArray()); QEventLoop e;
CWE-20
null
null
5,921
void DBusHelperProxy::setHelperResponder(QObject *o) { responder = o; }
null
0
void DBusHelperProxy::setHelperResponder(QObject *o) { responder = o; }
@@ -31,6 +31,8 @@ #include "kf5authadaptor.h" #include "kauthdebug.h" +extern Q_CORE_EXPORT const QMetaTypeInterface *qMetaTypeGuiHelper; + namespace KAuth { @@ -229,10 +231,17 @@ QByteArray DBusHelperProxy::performAction(const QString &action, const QByteArra return ActionReply::HelperBusyReply().serialized(); } + // Make sure we don't try restoring gui variants, in particular QImage/QPixmap/QIcon are super dangerous + // since they end up calling the image loaders and thus are a vector for crashing → executing code + auto origMetaTypeGuiHelper = qMetaTypeGuiHelper; + qMetaTypeGuiHelper = nullptr; + QVariantMap args; QDataStream s(&arguments, QIODevice::ReadOnly); s >> args; + qMetaTypeGuiHelper = origMetaTypeGuiHelper; + m_currentAction = action; emit remoteSignal(ActionStarted, action, QByteArray()); QEventLoop e;
CWE-20
null
null
5,922
void DBusHelperProxy::stopAction(const QString &action, const QString &helperID) { QDBusMessage message; message = QDBusMessage::createMethodCall(helperID, QLatin1String("/"), QLatin1String("org.kde.kf5auth"), QLatin1String("stopAction")); QList<QVariant> args; args << action; message.setArguments(args); m_busConnection.asyncCall(message); }
null
0
void DBusHelperProxy::stopAction(const QString &action, const QString &helperID) { QDBusMessage message; message = QDBusMessage::createMethodCall(helperID, QLatin1String("/"), QLatin1String("org.kde.kf5auth"), QLatin1String("stopAction")); QList<QVariant> args; args << action; message.setArguments(args); m_busConnection.asyncCall(message); }
@@ -31,6 +31,8 @@ #include "kf5authadaptor.h" #include "kauthdebug.h" +extern Q_CORE_EXPORT const QMetaTypeInterface *qMetaTypeGuiHelper; + namespace KAuth { @@ -229,10 +231,17 @@ QByteArray DBusHelperProxy::performAction(const QString &action, const QByteArra return ActionReply::HelperBusyReply().serialized(); } + // Make sure we don't try restoring gui variants, in particular QImage/QPixmap/QIcon are super dangerous + // since they end up calling the image loaders and thus are a vector for crashing → executing code + auto origMetaTypeGuiHelper = qMetaTypeGuiHelper; + qMetaTypeGuiHelper = nullptr; + QVariantMap args; QDataStream s(&arguments, QIODevice::ReadOnly); s >> args; + qMetaTypeGuiHelper = origMetaTypeGuiHelper; + m_currentAction = action; emit remoteSignal(ActionStarted, action, QByteArray()); QEventLoop e;
CWE-20
null
null
5,923
t1_decoder_done( T1_Decoder decoder ) { t1_builder_done( &decoder->builder ); }
Overflow
0
t1_decoder_done( T1_Decoder decoder ) { t1_builder_done( &decoder->builder ); }
@@ -780,10 +780,19 @@ /* point without adding any point to the outline */ idx = decoder->num_flex_vectors++; if ( idx > 0 && idx < 7 ) + { + /* in malformed fonts it is possible to have other */ + /* opcodes in the middle of a flex (which don't */ + /* increase `num_flex_vectors'); we thus have to */ + /* check whether we can add a point */ + if ( FT_SET_ERROR( t1_builder_check_points( builder, 1 ) ) ) + goto Syntax_Error; + t1_builder_add_point( builder, x, y, (FT_Byte)( idx == 3 || idx == 6 ) ); + } } break;
CWE-787
null
null
5,924
t1_decoder_init( T1_Decoder decoder, FT_Face face, FT_Size size, FT_GlyphSlot slot, FT_Byte** glyph_names, PS_Blend blend, FT_Bool hinting, FT_Render_Mode hint_mode, T1_Decoder_Callback parse_callback ) { FT_ZERO( decoder ); /* retrieve PSNames interface from list of current modules */ { FT_Service_PsCMaps psnames; FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS ); if ( !psnames ) { FT_ERROR(( "t1_decoder_init:" " the `psnames' module is not available\n" )); return FT_THROW( Unimplemented_Feature ); } decoder->psnames = psnames; } t1_builder_init( &decoder->builder, face, size, slot, hinting ); /* decoder->buildchar and decoder->len_buildchar have to be */ /* initialized by the caller since we cannot know the length */ /* of the BuildCharArray */ decoder->num_glyphs = (FT_UInt)face->num_glyphs; decoder->glyph_names = glyph_names; decoder->hint_mode = hint_mode; decoder->blend = blend; decoder->parse_callback = parse_callback; decoder->funcs = t1_decoder_funcs; return FT_Err_Ok; }
Overflow
0
t1_decoder_init( T1_Decoder decoder, FT_Face face, FT_Size size, FT_GlyphSlot slot, FT_Byte** glyph_names, PS_Blend blend, FT_Bool hinting, FT_Render_Mode hint_mode, T1_Decoder_Callback parse_callback ) { FT_ZERO( decoder ); /* retrieve PSNames interface from list of current modules */ { FT_Service_PsCMaps psnames; FT_FACE_FIND_GLOBAL_SERVICE( face, psnames, POSTSCRIPT_CMAPS ); if ( !psnames ) { FT_ERROR(( "t1_decoder_init:" " the `psnames' module is not available\n" )); return FT_THROW( Unimplemented_Feature ); } decoder->psnames = psnames; } t1_builder_init( &decoder->builder, face, size, slot, hinting ); /* decoder->buildchar and decoder->len_buildchar have to be */ /* initialized by the caller since we cannot know the length */ /* of the BuildCharArray */ decoder->num_glyphs = (FT_UInt)face->num_glyphs; decoder->glyph_names = glyph_names; decoder->hint_mode = hint_mode; decoder->blend = blend; decoder->parse_callback = parse_callback; decoder->funcs = t1_decoder_funcs; return FT_Err_Ok; }
@@ -780,10 +780,19 @@ /* point without adding any point to the outline */ idx = decoder->num_flex_vectors++; if ( idx > 0 && idx < 7 ) + { + /* in malformed fonts it is possible to have other */ + /* opcodes in the middle of a flex (which don't */ + /* increase `num_flex_vectors'); we thus have to */ + /* check whether we can add a point */ + if ( FT_SET_ERROR( t1_builder_check_points( builder, 1 ) ) ) + goto Syntax_Error; + t1_builder_add_point( builder, x, y, (FT_Byte)( idx == 3 || idx == 6 ) ); + } } break;
CWE-787
null
null
5,925
t1_decoder_parse_glyph( T1_Decoder decoder, FT_UInt glyph ) { return decoder->parse_callback( decoder, glyph ); }
Overflow
0
t1_decoder_parse_glyph( T1_Decoder decoder, FT_UInt glyph ) { return decoder->parse_callback( decoder, glyph ); }
@@ -780,10 +780,19 @@ /* point without adding any point to the outline */ idx = decoder->num_flex_vectors++; if ( idx > 0 && idx < 7 ) + { + /* in malformed fonts it is possible to have other */ + /* opcodes in the middle of a flex (which don't */ + /* increase `num_flex_vectors'); we thus have to */ + /* check whether we can add a point */ + if ( FT_SET_ERROR( t1_builder_check_points( builder, 1 ) ) ) + goto Syntax_Error; + t1_builder_add_point( builder, x, y, (FT_Byte)( idx == 3 || idx == 6 ) ); + } } break;
CWE-787
null
null
5,926
t1_lookup_glyph_by_stdcharcode( T1_Decoder decoder, FT_Int charcode ) { FT_UInt n; const FT_String* glyph_name; FT_Service_PsCMaps psnames = decoder->psnames; /* check range of standard char code */ if ( charcode < 0 || charcode > 255 ) return -1; glyph_name = psnames->adobe_std_strings( psnames->adobe_std_encoding[charcode]); for ( n = 0; n < decoder->num_glyphs; n++ ) { FT_String* name = (FT_String*)decoder->glyph_names[n]; if ( name && name[0] == glyph_name[0] && ft_strcmp( name, glyph_name ) == 0 ) return (FT_Int)n; } return -1; }
Overflow
0
t1_lookup_glyph_by_stdcharcode( T1_Decoder decoder, FT_Int charcode ) { FT_UInt n; const FT_String* glyph_name; FT_Service_PsCMaps psnames = decoder->psnames; /* check range of standard char code */ if ( charcode < 0 || charcode > 255 ) return -1; glyph_name = psnames->adobe_std_strings( psnames->adobe_std_encoding[charcode]); for ( n = 0; n < decoder->num_glyphs; n++ ) { FT_String* name = (FT_String*)decoder->glyph_names[n]; if ( name && name[0] == glyph_name[0] && ft_strcmp( name, glyph_name ) == 0 ) return (FT_Int)n; } return -1; }
@@ -780,10 +780,19 @@ /* point without adding any point to the outline */ idx = decoder->num_flex_vectors++; if ( idx > 0 && idx < 7 ) + { + /* in malformed fonts it is possible to have other */ + /* opcodes in the middle of a flex (which don't */ + /* increase `num_flex_vectors'); we thus have to */ + /* check whether we can add a point */ + if ( FT_SET_ERROR( t1_builder_check_points( builder, 1 ) ) ) + goto Syntax_Error; + t1_builder_add_point( builder, x, y, (FT_Byte)( idx == 3 || idx == 6 ) ); + } } break;
CWE-787
null
null
5,927
t1operator_seac( T1_Decoder decoder, FT_Pos asb, FT_Pos adx, FT_Pos ady, FT_Int bchar, FT_Int achar ) { FT_Error error; FT_Int bchar_index, achar_index; #if 0 FT_Int n_base_points; FT_Outline* base = decoder->builder.base; #endif FT_Vector left_bearing, advance; #ifdef FT_CONFIG_OPTION_INCREMENTAL T1_Face face = (T1_Face)decoder->builder.face; #endif if ( decoder->seac ) { FT_ERROR(( "t1operator_seac: invalid nested seac\n" )); return FT_THROW( Syntax_Error ); } if ( decoder->builder.metrics_only ) { FT_ERROR(( "t1operator_seac: unexpected seac\n" )); return FT_THROW( Syntax_Error ); } /* seac weirdness */ adx += decoder->builder.left_bearing.x; /* `glyph_names' is set to 0 for CID fonts which do not */ /* include an encoding. How can we deal with these? */ #ifdef FT_CONFIG_OPTION_INCREMENTAL if ( decoder->glyph_names == 0 && !face->root.internal->incremental_interface ) #else if ( decoder->glyph_names == 0 ) #endif /* FT_CONFIG_OPTION_INCREMENTAL */ { FT_ERROR(( "t1operator_seac:" " glyph names table not available in this font\n" )); return FT_THROW( Syntax_Error ); } #ifdef FT_CONFIG_OPTION_INCREMENTAL if ( face->root.internal->incremental_interface ) { /* the caller must handle the font encoding also */ bchar_index = bchar; achar_index = achar; } else #endif { bchar_index = t1_lookup_glyph_by_stdcharcode( decoder, bchar ); achar_index = t1_lookup_glyph_by_stdcharcode( decoder, achar ); } if ( bchar_index < 0 || achar_index < 0 ) { FT_ERROR(( "t1operator_seac:" " invalid seac character code arguments\n" )); return FT_THROW( Syntax_Error ); } /* if we are trying to load a composite glyph, do not load the */ /* accent character and return the array of subglyphs. */ if ( decoder->builder.no_recurse ) { FT_GlyphSlot glyph = (FT_GlyphSlot)decoder->builder.glyph; FT_GlyphLoader loader = glyph->internal->loader; FT_SubGlyph subg; /* reallocate subglyph array if necessary */ error = FT_GlyphLoader_CheckSubGlyphs( loader, 2 ); if ( error ) goto Exit; subg = loader->current.subglyphs; /* subglyph 0 = base character */ subg->index = bchar_index; subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES | FT_SUBGLYPH_FLAG_USE_MY_METRICS; subg->arg1 = 0; subg->arg2 = 0; subg++; /* subglyph 1 = accent character */ subg->index = achar_index; subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES; subg->arg1 = (FT_Int)FIXED_TO_INT( adx - asb ); subg->arg2 = (FT_Int)FIXED_TO_INT( ady ); /* set up remaining glyph fields */ glyph->num_subglyphs = 2; glyph->subglyphs = loader->base.subglyphs; glyph->format = FT_GLYPH_FORMAT_COMPOSITE; loader->current.num_subglyphs = 2; goto Exit; } /* First load `bchar' in builder */ /* now load the unscaled outline */ FT_GlyphLoader_Prepare( decoder->builder.loader ); /* prepare loader */ /* the seac operator must not be nested */ decoder->seac = TRUE; error = t1_decoder_parse_glyph( decoder, (FT_UInt)bchar_index ); decoder->seac = FALSE; if ( error ) goto Exit; /* save the left bearing and width of the base character */ /* as they will be erased by the next load. */ left_bearing = decoder->builder.left_bearing; advance = decoder->builder.advance; decoder->builder.left_bearing.x = 0; decoder->builder.left_bearing.y = 0; decoder->builder.pos_x = adx - asb; decoder->builder.pos_y = ady; /* Now load `achar' on top of */ /* the base outline */ /* the seac operator must not be nested */ decoder->seac = TRUE; error = t1_decoder_parse_glyph( decoder, (FT_UInt)achar_index ); decoder->seac = FALSE; if ( error ) goto Exit; /* restore the left side bearing and */ /* advance width of the base character */ decoder->builder.left_bearing = left_bearing; decoder->builder.advance = advance; decoder->builder.pos_x = 0; decoder->builder.pos_y = 0; Exit: return error; }
Overflow
0
t1operator_seac( T1_Decoder decoder, FT_Pos asb, FT_Pos adx, FT_Pos ady, FT_Int bchar, FT_Int achar ) { FT_Error error; FT_Int bchar_index, achar_index; #if 0 FT_Int n_base_points; FT_Outline* base = decoder->builder.base; #endif FT_Vector left_bearing, advance; #ifdef FT_CONFIG_OPTION_INCREMENTAL T1_Face face = (T1_Face)decoder->builder.face; #endif if ( decoder->seac ) { FT_ERROR(( "t1operator_seac: invalid nested seac\n" )); return FT_THROW( Syntax_Error ); } if ( decoder->builder.metrics_only ) { FT_ERROR(( "t1operator_seac: unexpected seac\n" )); return FT_THROW( Syntax_Error ); } /* seac weirdness */ adx += decoder->builder.left_bearing.x; /* `glyph_names' is set to 0 for CID fonts which do not */ /* include an encoding. How can we deal with these? */ #ifdef FT_CONFIG_OPTION_INCREMENTAL if ( decoder->glyph_names == 0 && !face->root.internal->incremental_interface ) #else if ( decoder->glyph_names == 0 ) #endif /* FT_CONFIG_OPTION_INCREMENTAL */ { FT_ERROR(( "t1operator_seac:" " glyph names table not available in this font\n" )); return FT_THROW( Syntax_Error ); } #ifdef FT_CONFIG_OPTION_INCREMENTAL if ( face->root.internal->incremental_interface ) { /* the caller must handle the font encoding also */ bchar_index = bchar; achar_index = achar; } else #endif { bchar_index = t1_lookup_glyph_by_stdcharcode( decoder, bchar ); achar_index = t1_lookup_glyph_by_stdcharcode( decoder, achar ); } if ( bchar_index < 0 || achar_index < 0 ) { FT_ERROR(( "t1operator_seac:" " invalid seac character code arguments\n" )); return FT_THROW( Syntax_Error ); } /* if we are trying to load a composite glyph, do not load the */ /* accent character and return the array of subglyphs. */ if ( decoder->builder.no_recurse ) { FT_GlyphSlot glyph = (FT_GlyphSlot)decoder->builder.glyph; FT_GlyphLoader loader = glyph->internal->loader; FT_SubGlyph subg; /* reallocate subglyph array if necessary */ error = FT_GlyphLoader_CheckSubGlyphs( loader, 2 ); if ( error ) goto Exit; subg = loader->current.subglyphs; /* subglyph 0 = base character */ subg->index = bchar_index; subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES | FT_SUBGLYPH_FLAG_USE_MY_METRICS; subg->arg1 = 0; subg->arg2 = 0; subg++; /* subglyph 1 = accent character */ subg->index = achar_index; subg->flags = FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES; subg->arg1 = (FT_Int)FIXED_TO_INT( adx - asb ); subg->arg2 = (FT_Int)FIXED_TO_INT( ady ); /* set up remaining glyph fields */ glyph->num_subglyphs = 2; glyph->subglyphs = loader->base.subglyphs; glyph->format = FT_GLYPH_FORMAT_COMPOSITE; loader->current.num_subglyphs = 2; goto Exit; } /* First load `bchar' in builder */ /* now load the unscaled outline */ FT_GlyphLoader_Prepare( decoder->builder.loader ); /* prepare loader */ /* the seac operator must not be nested */ decoder->seac = TRUE; error = t1_decoder_parse_glyph( decoder, (FT_UInt)bchar_index ); decoder->seac = FALSE; if ( error ) goto Exit; /* save the left bearing and width of the base character */ /* as they will be erased by the next load. */ left_bearing = decoder->builder.left_bearing; advance = decoder->builder.advance; decoder->builder.left_bearing.x = 0; decoder->builder.left_bearing.y = 0; decoder->builder.pos_x = adx - asb; decoder->builder.pos_y = ady; /* Now load `achar' on top of */ /* the base outline */ /* the seac operator must not be nested */ decoder->seac = TRUE; error = t1_decoder_parse_glyph( decoder, (FT_UInt)achar_index ); decoder->seac = FALSE; if ( error ) goto Exit; /* restore the left side bearing and */ /* advance width of the base character */ decoder->builder.left_bearing = left_bearing; decoder->builder.advance = advance; decoder->builder.pos_x = 0; decoder->builder.pos_y = 0; Exit: return error; }
@@ -780,10 +780,19 @@ /* point without adding any point to the outline */ idx = decoder->num_flex_vectors++; if ( idx > 0 && idx < 7 ) + { + /* in malformed fonts it is possible to have other */ + /* opcodes in the middle of a flex (which don't */ + /* increase `num_flex_vectors'); we thus have to */ + /* check whether we can add a point */ + if ( FT_SET_ERROR( t1_builder_check_points( builder, 1 ) ) ) + goto Syntax_Error; + t1_builder_add_point( builder, x, y, (FT_Byte)( idx == 3 || idx == 6 ) ); + } } break;
CWE-787
null
null
5,928
static ssize_t flistxattrat_nofollow(int dirfd, const char *filename, char *list, size_t size) { char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); int ret; ret = llistxattr(proc_path, list, size); g_free(proc_path); return ret; }
DoS
0
static ssize_t flistxattrat_nofollow(int dirfd, const char *filename, char *list, size_t size) { char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); int ret; ret = llistxattr(proc_path, list, size); g_free(proc_path); return ret; }
@@ -108,6 +108,7 @@ ssize_t v9fs_list_xattr(FsContext *ctx, const char *path, g_free(name); close_preserve_errno(dirfd); if (xattr_len < 0) { + g_free(orig_value); return -1; }
CWE-772
null
null
5,929
static ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, const char *name) { char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); int ret; ret = lremovexattr(proc_path, name); g_free(proc_path); return ret; }
DoS
0
static ssize_t fremovexattrat_nofollow(int dirfd, const char *filename, const char *name) { char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); int ret; ret = lremovexattr(proc_path, name); g_free(proc_path); return ret; }
@@ -108,6 +108,7 @@ ssize_t v9fs_list_xattr(FsContext *ctx, const char *path, g_free(name); close_preserve_errno(dirfd); if (xattr_len < 0) { + g_free(orig_value); return -1; }
CWE-772
null
null
5,930
int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, void *value, size_t size, int flags) { char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); int ret; ret = lsetxattr(proc_path, name, value, size, flags); g_free(proc_path); return ret; }
DoS
0
int fsetxattrat_nofollow(int dirfd, const char *filename, const char *name, void *value, size_t size, int flags) { char *proc_path = g_strdup_printf("/proc/self/fd/%d/%s", dirfd, filename); int ret; ret = lsetxattr(proc_path, name, value, size, flags); g_free(proc_path); return ret; }
@@ -108,6 +108,7 @@ ssize_t v9fs_list_xattr(FsContext *ctx, const char *path, g_free(name); close_preserve_errno(dirfd); if (xattr_len < 0) { + g_free(orig_value); return -1; }
CWE-772
null
null
5,931
static XattrOperations *get_xattr_operations(XattrOperations **h, const char *name) { XattrOperations *xops; for (xops = *(h)++; xops != NULL; xops = *(h)++) { if (!strncmp(name, xops->name, strlen(xops->name))) { return xops; } } return NULL; }
DoS
0
static XattrOperations *get_xattr_operations(XattrOperations **h, const char *name) { XattrOperations *xops; for (xops = *(h)++; xops != NULL; xops = *(h)++) { if (!strncmp(name, xops->name, strlen(xops->name))) { return xops; } } return NULL; }
@@ -108,6 +108,7 @@ ssize_t v9fs_list_xattr(FsContext *ctx, const char *path, g_free(name); close_preserve_errno(dirfd); if (xattr_len < 0) { + g_free(orig_value); return -1; }
CWE-772
null
null
5,932
ssize_t local_getxattr_nofollow(FsContext *ctx, const char *path, const char *name, void *value, size_t size) { char *dirpath = g_path_get_dirname(path); char *filename = g_path_get_basename(path); int dirfd; ssize_t ret = -1; dirfd = local_opendir_nofollow(ctx, dirpath); if (dirfd == -1) { goto out; } ret = fgetxattrat_nofollow(dirfd, filename, name, value, size); close_preserve_errno(dirfd); out: g_free(dirpath); g_free(filename); return ret; }
DoS
0
ssize_t local_getxattr_nofollow(FsContext *ctx, const char *path, const char *name, void *value, size_t size) { char *dirpath = g_path_get_dirname(path); char *filename = g_path_get_basename(path); int dirfd; ssize_t ret = -1; dirfd = local_opendir_nofollow(ctx, dirpath); if (dirfd == -1) { goto out; } ret = fgetxattrat_nofollow(dirfd, filename, name, value, size); close_preserve_errno(dirfd); out: g_free(dirpath); g_free(filename); return ret; }
@@ -108,6 +108,7 @@ ssize_t v9fs_list_xattr(FsContext *ctx, const char *path, g_free(name); close_preserve_errno(dirfd); if (xattr_len < 0) { + g_free(orig_value); return -1; }
CWE-772
null
null
5,933
ssize_t local_removexattr_nofollow(FsContext *ctx, const char *path, const char *name) { char *dirpath = g_path_get_dirname(path); char *filename = g_path_get_basename(path); int dirfd; ssize_t ret = -1; dirfd = local_opendir_nofollow(ctx, dirpath); if (dirfd == -1) { goto out; } ret = fremovexattrat_nofollow(dirfd, filename, name); close_preserve_errno(dirfd); out: g_free(dirpath); g_free(filename); return ret; }
DoS
0
ssize_t local_removexattr_nofollow(FsContext *ctx, const char *path, const char *name) { char *dirpath = g_path_get_dirname(path); char *filename = g_path_get_basename(path); int dirfd; ssize_t ret = -1; dirfd = local_opendir_nofollow(ctx, dirpath); if (dirfd == -1) { goto out; } ret = fremovexattrat_nofollow(dirfd, filename, name); close_preserve_errno(dirfd); out: g_free(dirpath); g_free(filename); return ret; }
@@ -108,6 +108,7 @@ ssize_t v9fs_list_xattr(FsContext *ctx, const char *path, g_free(name); close_preserve_errno(dirfd); if (xattr_len < 0) { + g_free(orig_value); return -1; }
CWE-772
null
null
5,934
ssize_t notsup_getxattr(FsContext *ctx, const char *path, const char *name, void *value, size_t size) { errno = ENOTSUP; return -1; }
DoS
0
ssize_t notsup_getxattr(FsContext *ctx, const char *path, const char *name, void *value, size_t size) { errno = ENOTSUP; return -1; }
@@ -108,6 +108,7 @@ ssize_t v9fs_list_xattr(FsContext *ctx, const char *path, g_free(name); close_preserve_errno(dirfd); if (xattr_len < 0) { + g_free(orig_value); return -1; }
CWE-772
null
null
5,935
ssize_t notsup_listxattr(FsContext *ctx, const char *path, char *name, void *value, size_t size) { return 0; }
DoS
0
ssize_t notsup_listxattr(FsContext *ctx, const char *path, char *name, void *value, size_t size) { return 0; }
@@ -108,6 +108,7 @@ ssize_t v9fs_list_xattr(FsContext *ctx, const char *path, g_free(name); close_preserve_errno(dirfd); if (xattr_len < 0) { + g_free(orig_value); return -1; }
CWE-772
null
null
5,936
int notsup_setxattr(FsContext *ctx, const char *path, const char *name, void *value, size_t size, int flags) { errno = ENOTSUP; return -1; }
DoS
0
int notsup_setxattr(FsContext *ctx, const char *path, const char *name, void *value, size_t size, int flags) { errno = ENOTSUP; return -1; }
@@ -108,6 +108,7 @@ ssize_t v9fs_list_xattr(FsContext *ctx, const char *path, g_free(name); close_preserve_errno(dirfd); if (xattr_len < 0) { + g_free(orig_value); return -1; }
CWE-772
null
null
5,937
ssize_t pt_getxattr(FsContext *ctx, const char *path, const char *name, void *value, size_t size) { return local_getxattr_nofollow(ctx, path, name, value, size); }
DoS
0
ssize_t pt_getxattr(FsContext *ctx, const char *path, const char *name, void *value, size_t size) { return local_getxattr_nofollow(ctx, path, name, value, size); }
@@ -108,6 +108,7 @@ ssize_t v9fs_list_xattr(FsContext *ctx, const char *path, g_free(name); close_preserve_errno(dirfd); if (xattr_len < 0) { + g_free(orig_value); return -1; }
CWE-772
null
null
5,938
ssize_t pt_listxattr(FsContext *ctx, const char *path, char *name, void *value, size_t size) { int name_size = strlen(name) + 1; if (!value) { return name_size; } if (size < name_size) { errno = ERANGE; return -1; } /* no need for strncpy: name_size is strlen(name)+1 */ memcpy(value, name, name_size); return name_size; }
DoS
0
ssize_t pt_listxattr(FsContext *ctx, const char *path, char *name, void *value, size_t size) { int name_size = strlen(name) + 1; if (!value) { return name_size; } if (size < name_size) { errno = ERANGE; return -1; } /* no need for strncpy: name_size is strlen(name)+1 */ memcpy(value, name, name_size); return name_size; }
@@ -108,6 +108,7 @@ ssize_t v9fs_list_xattr(FsContext *ctx, const char *path, g_free(name); close_preserve_errno(dirfd); if (xattr_len < 0) { + g_free(orig_value); return -1; }
CWE-772
null
null
5,939
int pt_removexattr(FsContext *ctx, const char *path, const char *name) { return local_removexattr_nofollow(ctx, path, name); }
DoS
0
int pt_removexattr(FsContext *ctx, const char *path, const char *name) { return local_removexattr_nofollow(ctx, path, name); }
@@ -108,6 +108,7 @@ ssize_t v9fs_list_xattr(FsContext *ctx, const char *path, g_free(name); close_preserve_errno(dirfd); if (xattr_len < 0) { + g_free(orig_value); return -1; }
CWE-772
null
null
5,940
ssize_t v9fs_get_xattr(FsContext *ctx, const char *path, const char *name, void *value, size_t size) { XattrOperations *xops = get_xattr_operations(ctx->xops, name); if (xops) { return xops->getxattr(ctx, path, name, value, size); } errno = EOPNOTSUPP; return -1; }
DoS
0
ssize_t v9fs_get_xattr(FsContext *ctx, const char *path, const char *name, void *value, size_t size) { XattrOperations *xops = get_xattr_operations(ctx->xops, name); if (xops) { return xops->getxattr(ctx, path, name, value, size); } errno = EOPNOTSUPP; return -1; }
@@ -108,6 +108,7 @@ ssize_t v9fs_list_xattr(FsContext *ctx, const char *path, g_free(name); close_preserve_errno(dirfd); if (xattr_len < 0) { + g_free(orig_value); return -1; }
CWE-772
null
null
5,941
int v9fs_remove_xattr(FsContext *ctx, const char *path, const char *name) { XattrOperations *xops = get_xattr_operations(ctx->xops, name); if (xops) { return xops->removexattr(ctx, path, name); } errno = EOPNOTSUPP; return -1; }
DoS
0
int v9fs_remove_xattr(FsContext *ctx, const char *path, const char *name) { XattrOperations *xops = get_xattr_operations(ctx->xops, name); if (xops) { return xops->removexattr(ctx, path, name); } errno = EOPNOTSUPP; return -1; }
@@ -108,6 +108,7 @@ ssize_t v9fs_list_xattr(FsContext *ctx, const char *path, g_free(name); close_preserve_errno(dirfd); if (xattr_len < 0) { + g_free(orig_value); return -1; }
CWE-772
null
null
5,942
int v9fs_set_xattr(FsContext *ctx, const char *path, const char *name, void *value, size_t size, int flags) { XattrOperations *xops = get_xattr_operations(ctx->xops, name); if (xops) { return xops->setxattr(ctx, path, name, value, size, flags); } errno = EOPNOTSUPP; return -1; }
DoS
0
int v9fs_set_xattr(FsContext *ctx, const char *path, const char *name, void *value, size_t size, int flags) { XattrOperations *xops = get_xattr_operations(ctx->xops, name); if (xops) { return xops->setxattr(ctx, path, name, value, size, flags); } errno = EOPNOTSUPP; return -1; }
@@ -108,6 +108,7 @@ ssize_t v9fs_list_xattr(FsContext *ctx, const char *path, g_free(name); close_preserve_errno(dirfd); if (xattr_len < 0) { + g_free(orig_value); return -1; }
CWE-772
null
null
5,943
_dbus_validate_signature_with_reason (const DBusString *type_str, int type_pos, int len) { const unsigned char *p; const unsigned char *end; int last; int struct_depth; int array_depth; int dict_entry_depth; DBusValidity result; int element_count; DBusList *element_count_stack; result = DBUS_VALID; element_count_stack = NULL; if (!_dbus_list_append (&element_count_stack, _DBUS_INT_TO_POINTER (0))) { result = DBUS_VALIDITY_UNKNOWN_OOM_ERROR; goto out; } _dbus_assert (type_str != NULL); _dbus_assert (type_pos < _DBUS_INT32_MAX - len); _dbus_assert (len >= 0); _dbus_assert (type_pos >= 0); if (len > DBUS_MAXIMUM_SIGNATURE_LENGTH) { result = DBUS_INVALID_SIGNATURE_TOO_LONG; goto out; } p = _dbus_string_get_const_data_len (type_str, type_pos, 0); end = _dbus_string_get_const_data_len (type_str, type_pos + len, 0); struct_depth = 0; array_depth = 0; dict_entry_depth = 0; last = DBUS_TYPE_INVALID; while (p != end) { switch (*p) { case DBUS_TYPE_BYTE: case DBUS_TYPE_BOOLEAN: case DBUS_TYPE_INT16: case DBUS_TYPE_UINT16: case DBUS_TYPE_INT32: case DBUS_TYPE_UINT32: case DBUS_TYPE_UNIX_FD: case DBUS_TYPE_INT64: case DBUS_TYPE_UINT64: case DBUS_TYPE_DOUBLE: case DBUS_TYPE_STRING: case DBUS_TYPE_OBJECT_PATH: case DBUS_TYPE_SIGNATURE: case DBUS_TYPE_VARIANT: break; case DBUS_TYPE_ARRAY: array_depth += 1; if (array_depth > DBUS_MAXIMUM_TYPE_RECURSION_DEPTH) { result = DBUS_INVALID_EXCEEDED_MAXIMUM_ARRAY_RECURSION; goto out; } break; case DBUS_STRUCT_BEGIN_CHAR: struct_depth += 1; if (struct_depth > DBUS_MAXIMUM_TYPE_RECURSION_DEPTH) { result = DBUS_INVALID_EXCEEDED_MAXIMUM_STRUCT_RECURSION; goto out; } if (!_dbus_list_append (&element_count_stack, _DBUS_INT_TO_POINTER (0))) { result = DBUS_VALIDITY_UNKNOWN_OOM_ERROR; goto out; } break; case DBUS_STRUCT_END_CHAR: if (struct_depth == 0) { result = DBUS_INVALID_STRUCT_ENDED_BUT_NOT_STARTED; goto out; } if (last == DBUS_STRUCT_BEGIN_CHAR) { result = DBUS_INVALID_STRUCT_HAS_NO_FIELDS; goto out; } _dbus_list_pop_last (&element_count_stack); struct_depth -= 1; break; case DBUS_DICT_ENTRY_BEGIN_CHAR: if (last != DBUS_TYPE_ARRAY) { result = DBUS_INVALID_DICT_ENTRY_NOT_INSIDE_ARRAY; goto out; } dict_entry_depth += 1; if (dict_entry_depth > DBUS_MAXIMUM_TYPE_RECURSION_DEPTH) { result = DBUS_INVALID_EXCEEDED_MAXIMUM_DICT_ENTRY_RECURSION; goto out; } if (!_dbus_list_append (&element_count_stack, _DBUS_INT_TO_POINTER (0))) { result = DBUS_VALIDITY_UNKNOWN_OOM_ERROR; goto out; } break; case DBUS_DICT_ENTRY_END_CHAR: if (dict_entry_depth == 0) { result = DBUS_INVALID_DICT_ENTRY_ENDED_BUT_NOT_STARTED; goto out; } dict_entry_depth -= 1; element_count = _DBUS_POINTER_TO_INT (_dbus_list_pop_last (&element_count_stack)); if (element_count != 2) { if (element_count == 0) result = DBUS_INVALID_DICT_ENTRY_HAS_NO_FIELDS; else if (element_count == 1) result = DBUS_INVALID_DICT_ENTRY_HAS_ONLY_ONE_FIELD; else result = DBUS_INVALID_DICT_ENTRY_HAS_TOO_MANY_FIELDS; goto out; } break; case DBUS_TYPE_STRUCT: /* doesn't appear in signatures */ case DBUS_TYPE_DICT_ENTRY: /* ditto */ default: result = DBUS_INVALID_UNKNOWN_TYPECODE; goto out; } if (*p != DBUS_TYPE_ARRAY && *p != DBUS_DICT_ENTRY_BEGIN_CHAR && *p != DBUS_STRUCT_BEGIN_CHAR) { element_count = _DBUS_POINTER_TO_INT (_dbus_list_pop_last (&element_count_stack)); ++element_count; if (!_dbus_list_append (&element_count_stack, _DBUS_INT_TO_POINTER (element_count))) { result = DBUS_VALIDITY_UNKNOWN_OOM_ERROR; goto out; } } if (array_depth > 0) { if (*p == DBUS_TYPE_ARRAY && p != end) { const char *p1; p1 = p + 1; if (*p1 == DBUS_STRUCT_END_CHAR || *p1 == DBUS_DICT_ENTRY_END_CHAR) { result = DBUS_INVALID_MISSING_ARRAY_ELEMENT_TYPE; goto out; } } else { array_depth = 0; } } if (last == DBUS_DICT_ENTRY_BEGIN_CHAR) { if (!(_dbus_type_is_valid (*p) && dbus_type_is_basic (*p))) { result = DBUS_INVALID_DICT_KEY_MUST_BE_BASIC_TYPE; goto out; } } last = *p; ++p; } if (array_depth > 0) { result = DBUS_INVALID_MISSING_ARRAY_ELEMENT_TYPE; goto out; } if (struct_depth > 0) { result = DBUS_INVALID_STRUCT_STARTED_BUT_NOT_ENDED; goto out; } if (dict_entry_depth > 0) { result = DBUS_INVALID_DICT_ENTRY_STARTED_BUT_NOT_ENDED; goto out; } _dbus_assert (last != DBUS_TYPE_ARRAY); _dbus_assert (last != DBUS_STRUCT_BEGIN_CHAR); _dbus_assert (last != DBUS_DICT_ENTRY_BEGIN_CHAR); result = DBUS_VALID; out: _dbus_list_clear (&element_count_stack); return result; }
DoS
0
_dbus_validate_signature_with_reason (const DBusString *type_str, int type_pos, int len) { const unsigned char *p; const unsigned char *end; int last; int struct_depth; int array_depth; int dict_entry_depth; DBusValidity result; int element_count; DBusList *element_count_stack; result = DBUS_VALID; element_count_stack = NULL; if (!_dbus_list_append (&element_count_stack, _DBUS_INT_TO_POINTER (0))) { result = DBUS_VALIDITY_UNKNOWN_OOM_ERROR; goto out; } _dbus_assert (type_str != NULL); _dbus_assert (type_pos < _DBUS_INT32_MAX - len); _dbus_assert (len >= 0); _dbus_assert (type_pos >= 0); if (len > DBUS_MAXIMUM_SIGNATURE_LENGTH) { result = DBUS_INVALID_SIGNATURE_TOO_LONG; goto out; } p = _dbus_string_get_const_data_len (type_str, type_pos, 0); end = _dbus_string_get_const_data_len (type_str, type_pos + len, 0); struct_depth = 0; array_depth = 0; dict_entry_depth = 0; last = DBUS_TYPE_INVALID; while (p != end) { switch (*p) { case DBUS_TYPE_BYTE: case DBUS_TYPE_BOOLEAN: case DBUS_TYPE_INT16: case DBUS_TYPE_UINT16: case DBUS_TYPE_INT32: case DBUS_TYPE_UINT32: case DBUS_TYPE_UNIX_FD: case DBUS_TYPE_INT64: case DBUS_TYPE_UINT64: case DBUS_TYPE_DOUBLE: case DBUS_TYPE_STRING: case DBUS_TYPE_OBJECT_PATH: case DBUS_TYPE_SIGNATURE: case DBUS_TYPE_VARIANT: break; case DBUS_TYPE_ARRAY: array_depth += 1; if (array_depth > DBUS_MAXIMUM_TYPE_RECURSION_DEPTH) { result = DBUS_INVALID_EXCEEDED_MAXIMUM_ARRAY_RECURSION; goto out; } break; case DBUS_STRUCT_BEGIN_CHAR: struct_depth += 1; if (struct_depth > DBUS_MAXIMUM_TYPE_RECURSION_DEPTH) { result = DBUS_INVALID_EXCEEDED_MAXIMUM_STRUCT_RECURSION; goto out; } if (!_dbus_list_append (&element_count_stack, _DBUS_INT_TO_POINTER (0))) { result = DBUS_VALIDITY_UNKNOWN_OOM_ERROR; goto out; } break; case DBUS_STRUCT_END_CHAR: if (struct_depth == 0) { result = DBUS_INVALID_STRUCT_ENDED_BUT_NOT_STARTED; goto out; } if (last == DBUS_STRUCT_BEGIN_CHAR) { result = DBUS_INVALID_STRUCT_HAS_NO_FIELDS; goto out; } _dbus_list_pop_last (&element_count_stack); struct_depth -= 1; break; case DBUS_DICT_ENTRY_BEGIN_CHAR: if (last != DBUS_TYPE_ARRAY) { result = DBUS_INVALID_DICT_ENTRY_NOT_INSIDE_ARRAY; goto out; } dict_entry_depth += 1; if (dict_entry_depth > DBUS_MAXIMUM_TYPE_RECURSION_DEPTH) { result = DBUS_INVALID_EXCEEDED_MAXIMUM_DICT_ENTRY_RECURSION; goto out; } if (!_dbus_list_append (&element_count_stack, _DBUS_INT_TO_POINTER (0))) { result = DBUS_VALIDITY_UNKNOWN_OOM_ERROR; goto out; } break; case DBUS_DICT_ENTRY_END_CHAR: if (dict_entry_depth == 0) { result = DBUS_INVALID_DICT_ENTRY_ENDED_BUT_NOT_STARTED; goto out; } dict_entry_depth -= 1; element_count = _DBUS_POINTER_TO_INT (_dbus_list_pop_last (&element_count_stack)); if (element_count != 2) { if (element_count == 0) result = DBUS_INVALID_DICT_ENTRY_HAS_NO_FIELDS; else if (element_count == 1) result = DBUS_INVALID_DICT_ENTRY_HAS_ONLY_ONE_FIELD; else result = DBUS_INVALID_DICT_ENTRY_HAS_TOO_MANY_FIELDS; goto out; } break; case DBUS_TYPE_STRUCT: /* doesn't appear in signatures */ case DBUS_TYPE_DICT_ENTRY: /* ditto */ default: result = DBUS_INVALID_UNKNOWN_TYPECODE; goto out; } if (*p != DBUS_TYPE_ARRAY && *p != DBUS_DICT_ENTRY_BEGIN_CHAR && *p != DBUS_STRUCT_BEGIN_CHAR) { element_count = _DBUS_POINTER_TO_INT (_dbus_list_pop_last (&element_count_stack)); ++element_count; if (!_dbus_list_append (&element_count_stack, _DBUS_INT_TO_POINTER (element_count))) { result = DBUS_VALIDITY_UNKNOWN_OOM_ERROR; goto out; } } if (array_depth > 0) { if (*p == DBUS_TYPE_ARRAY && p != end) { const char *p1; p1 = p + 1; if (*p1 == DBUS_STRUCT_END_CHAR || *p1 == DBUS_DICT_ENTRY_END_CHAR) { result = DBUS_INVALID_MISSING_ARRAY_ELEMENT_TYPE; goto out; } } else { array_depth = 0; } } if (last == DBUS_DICT_ENTRY_BEGIN_CHAR) { if (!(_dbus_type_is_valid (*p) && dbus_type_is_basic (*p))) { result = DBUS_INVALID_DICT_KEY_MUST_BE_BASIC_TYPE; goto out; } } last = *p; ++p; } if (array_depth > 0) { result = DBUS_INVALID_MISSING_ARRAY_ELEMENT_TYPE; goto out; } if (struct_depth > 0) { result = DBUS_INVALID_STRUCT_STARTED_BUT_NOT_ENDED; goto out; } if (dict_entry_depth > 0) { result = DBUS_INVALID_DICT_ENTRY_STARTED_BUT_NOT_ENDED; goto out; } _dbus_assert (last != DBUS_TYPE_ARRAY); _dbus_assert (last != DBUS_STRUCT_BEGIN_CHAR); _dbus_assert (last != DBUS_DICT_ENTRY_BEGIN_CHAR); result = DBUS_VALID; out: _dbus_list_clear (&element_count_stack); return result; }
@@ -291,16 +291,30 @@ out: return result; } +/* note: this function is also used to validate the header's values, + * since the header is a valid body with a particular signature. + */ static DBusValidity validate_body_helper (DBusTypeReader *reader, int byte_order, dbus_bool_t walk_reader_to_end, + int total_depth, const unsigned char *p, const unsigned char *end, const unsigned char **new_p) { int current_type; + /* The spec allows arrays and structs to each nest 32, for total + * nesting of 2*32. We want to impose the same limit on "dynamic" + * value nesting (not visible in the signature) which is introduced + * by DBUS_TYPE_VARIANT. + */ + if (total_depth > (DBUS_MAXIMUM_TYPE_RECURSION_DEPTH * 2)) + { + return DBUS_INVALID_NESTED_TOO_DEEPLY; + } + while ((current_type = _dbus_type_reader_get_current_type (reader)) != DBUS_TYPE_INVALID) { const unsigned char *a; @@ -477,7 +491,9 @@ validate_body_helper (DBusTypeReader *reader, { while (p < array_end) { - validity = validate_body_helper (&sub, byte_order, FALSE, p, end, &p); + validity = validate_body_helper (&sub, byte_order, FALSE, + total_depth + 1, + p, end, &p); if (validity != DBUS_VALID) return validity; } @@ -594,7 +610,9 @@ validate_body_helper (DBusTypeReader *reader, _dbus_assert (_dbus_type_reader_get_current_type (&sub) != DBUS_TYPE_INVALID); - validity = validate_body_helper (&sub, byte_order, FALSE, p, end, &p); + validity = validate_body_helper (&sub, byte_order, FALSE, + total_depth + 1, + p, end, &p); if (validity != DBUS_VALID) return validity; @@ -623,7 +641,9 @@ validate_body_helper (DBusTypeReader *reader, _dbus_type_reader_recurse (reader, &sub); - validity = validate_body_helper (&sub, byte_order, TRUE, p, end, &p); + validity = validate_body_helper (&sub, byte_order, TRUE, + total_depth + 1, + p, end, &p); if (validity != DBUS_VALID) return validity; } @@ -708,7 +728,7 @@ _dbus_validate_body_with_reason (const DBusString *expected_signature, p = _dbus_string_get_const_data_len (value_str, value_pos, len); end = p + len; - validity = validate_body_helper (&reader, byte_order, TRUE, p, end, &p); + validity = validate_body_helper (&reader, byte_order, TRUE, 0, p, end, &p); if (validity != DBUS_VALID) return validity; @@ -878,7 +898,7 @@ _dbus_validity_to_error_message (DBusValidity validity) case DBUS_INVALID_DICT_ENTRY_HAS_TOO_MANY_FIELDS: return "Dict entry has too many fields"; case DBUS_INVALID_DICT_ENTRY_NOT_INSIDE_ARRAY: return "Dict entry not inside array"; case DBUS_INVALID_DICT_KEY_MUST_BE_BASIC_TYPE: return "Dict key must be basic type"; - + case DBUS_INVALID_NESTED_TOO_DEEPLY: return "Variants cannot be used to create a hugely recursive tree of values"; default: return "Invalid"; }
CWE-399
null
null
5,944
generate_from_message (DBusString *data, DBusValidity *expected_validity, DBusMessage *message) { dbus_message_set_serial (message, 1); dbus_message_lock (message); *expected_validity = DBUS_VALID; /* move for efficiency, since we'll nuke the message anyway */ if (!_dbus_string_move (&message->header.data, 0, data, 0)) _dbus_assert_not_reached ("oom"); if (!_dbus_string_copy (&message->body, 0, data, _dbus_string_get_length (data))) _dbus_assert_not_reached ("oom"); }
DoS
0
generate_from_message (DBusString *data, DBusValidity *expected_validity, DBusMessage *message) { dbus_message_set_serial (message, 1); dbus_message_lock (message); *expected_validity = DBUS_VALID; /* move for efficiency, since we'll nuke the message anyway */ if (!_dbus_string_move (&message->header.data, 0, data, 0)) _dbus_assert_not_reached ("oom"); if (!_dbus_string_copy (&message->body, 0, data, _dbus_string_get_length (data))) _dbus_assert_not_reached ("oom"); }
@@ -333,6 +333,53 @@ simple_error (void) return message; } +static DBusMessage* +message_with_nesting_levels (int levels) +{ + DBusMessage *message; + dbus_int32_t v_INT32; + DBusMessageIter *parents; + DBusMessageIter *children; + int i; + + /* If levels is higher it breaks sig_refcount in DBusMessageRealIter + * in dbus-message.c, this assert is just to help you know you need + * to fix that if you hit it + */ + _dbus_assert (levels < 256); + + parents = dbus_new(DBusMessageIter, levels + 1); + children = dbus_new(DBusMessageIter, levels + 1); + + v_INT32 = 42; + message = simple_method_call (); + + i = 0; + dbus_message_iter_init_append (message, &parents[i]); + while (i < levels) + { + dbus_message_iter_open_container (&parents[i], DBUS_TYPE_VARIANT, + i == (levels - 1) ? + DBUS_TYPE_INT32_AS_STRING : + DBUS_TYPE_VARIANT_AS_STRING, + &children[i]); + ++i; + parents[i] = children[i-1]; + } + --i; + dbus_message_iter_append_basic (&children[i], DBUS_TYPE_INT32, &v_INT32); + while (i >= 0) + { + dbus_message_iter_close_container (&parents[i], &children[i]); + --i; + } + + dbus_free(parents); + dbus_free(children); + + return message; +} + static dbus_bool_t generate_special (DBusMessageDataIter *iter, DBusString *data, @@ -735,6 +782,24 @@ generate_special (DBusMessageDataIter *iter, *expected_validity = DBUS_INVALID_DICT_ENTRY_HAS_NO_FIELDS; } + else if (item_seq == 20) + { + /* 64 levels of nesting is OK */ + message = message_with_nesting_levels(64); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_VALID; + } + else if (item_seq == 21) + { + /* 65 levels of nesting is not OK */ + message = message_with_nesting_levels(65); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_INVALID_NESTED_TOO_DEEPLY; + } else { return FALSE;
CWE-399
null
null
5,945
generate_many_bodies (DBusMessageDataIter *iter, DBusString *data, DBusValidity *expected_validity) { return generate_outer (iter, data, expected_validity, generate_many_bodies_inner); }
DoS
0
generate_many_bodies (DBusMessageDataIter *iter, DBusString *data, DBusValidity *expected_validity) { return generate_outer (iter, data, expected_validity, generate_many_bodies_inner); }
@@ -333,6 +333,53 @@ simple_error (void) return message; } +static DBusMessage* +message_with_nesting_levels (int levels) +{ + DBusMessage *message; + dbus_int32_t v_INT32; + DBusMessageIter *parents; + DBusMessageIter *children; + int i; + + /* If levels is higher it breaks sig_refcount in DBusMessageRealIter + * in dbus-message.c, this assert is just to help you know you need + * to fix that if you hit it + */ + _dbus_assert (levels < 256); + + parents = dbus_new(DBusMessageIter, levels + 1); + children = dbus_new(DBusMessageIter, levels + 1); + + v_INT32 = 42; + message = simple_method_call (); + + i = 0; + dbus_message_iter_init_append (message, &parents[i]); + while (i < levels) + { + dbus_message_iter_open_container (&parents[i], DBUS_TYPE_VARIANT, + i == (levels - 1) ? + DBUS_TYPE_INT32_AS_STRING : + DBUS_TYPE_VARIANT_AS_STRING, + &children[i]); + ++i; + parents[i] = children[i-1]; + } + --i; + dbus_message_iter_append_basic (&children[i], DBUS_TYPE_INT32, &v_INT32); + while (i >= 0) + { + dbus_message_iter_close_container (&parents[i], &children[i]); + --i; + } + + dbus_free(parents); + dbus_free(children); + + return message; +} + static dbus_bool_t generate_special (DBusMessageDataIter *iter, DBusString *data, @@ -735,6 +782,24 @@ generate_special (DBusMessageDataIter *iter, *expected_validity = DBUS_INVALID_DICT_ENTRY_HAS_NO_FIELDS; } + else if (item_seq == 20) + { + /* 64 levels of nesting is OK */ + message = message_with_nesting_levels(64); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_VALID; + } + else if (item_seq == 21) + { + /* 65 levels of nesting is not OK */ + message = message_with_nesting_levels(65); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_INVALID_NESTED_TOO_DEEPLY; + } else { return FALSE;
CWE-399
null
null
5,946
generate_many_bodies_inner (DBusMessageDataIter *iter, DBusMessage **message_p) { DBusMessage *message; DBusString signature; DBusString body; /* Keeping this small makes things go faster */ message = dbus_message_new_method_call ("o.z.F", "/", "o.z.B", "Nah"); if (message == NULL) _dbus_assert_not_reached ("oom"); set_reply_serial (message); if (!_dbus_string_init (&signature) || !_dbus_string_init (&body)) _dbus_assert_not_reached ("oom"); if (dbus_internal_do_not_use_generate_bodies (iter_get_sequence (iter), message->byte_order, &signature, &body)) { const char *v_SIGNATURE; v_SIGNATURE = _dbus_string_get_const_data (&signature); if (!_dbus_header_set_field_basic (&message->header, DBUS_HEADER_FIELD_SIGNATURE, DBUS_TYPE_SIGNATURE, &v_SIGNATURE)) _dbus_assert_not_reached ("oom"); if (!_dbus_string_move (&body, 0, &message->body, 0)) _dbus_assert_not_reached ("oom"); _dbus_marshal_set_uint32 (&message->header.data, BODY_LENGTH_OFFSET, _dbus_string_get_length (&message->body), message->byte_order); *message_p = message; } else { dbus_message_unref (message); *message_p = NULL; } _dbus_string_free (&signature); _dbus_string_free (&body); return *message_p != NULL; }
DoS
0
generate_many_bodies_inner (DBusMessageDataIter *iter, DBusMessage **message_p) { DBusMessage *message; DBusString signature; DBusString body; /* Keeping this small makes things go faster */ message = dbus_message_new_method_call ("o.z.F", "/", "o.z.B", "Nah"); if (message == NULL) _dbus_assert_not_reached ("oom"); set_reply_serial (message); if (!_dbus_string_init (&signature) || !_dbus_string_init (&body)) _dbus_assert_not_reached ("oom"); if (dbus_internal_do_not_use_generate_bodies (iter_get_sequence (iter), message->byte_order, &signature, &body)) { const char *v_SIGNATURE; v_SIGNATURE = _dbus_string_get_const_data (&signature); if (!_dbus_header_set_field_basic (&message->header, DBUS_HEADER_FIELD_SIGNATURE, DBUS_TYPE_SIGNATURE, &v_SIGNATURE)) _dbus_assert_not_reached ("oom"); if (!_dbus_string_move (&body, 0, &message->body, 0)) _dbus_assert_not_reached ("oom"); _dbus_marshal_set_uint32 (&message->header.data, BODY_LENGTH_OFFSET, _dbus_string_get_length (&message->body), message->byte_order); *message_p = message; } else { dbus_message_unref (message); *message_p = NULL; } _dbus_string_free (&signature); _dbus_string_free (&body); return *message_p != NULL; }
@@ -333,6 +333,53 @@ simple_error (void) return message; } +static DBusMessage* +message_with_nesting_levels (int levels) +{ + DBusMessage *message; + dbus_int32_t v_INT32; + DBusMessageIter *parents; + DBusMessageIter *children; + int i; + + /* If levels is higher it breaks sig_refcount in DBusMessageRealIter + * in dbus-message.c, this assert is just to help you know you need + * to fix that if you hit it + */ + _dbus_assert (levels < 256); + + parents = dbus_new(DBusMessageIter, levels + 1); + children = dbus_new(DBusMessageIter, levels + 1); + + v_INT32 = 42; + message = simple_method_call (); + + i = 0; + dbus_message_iter_init_append (message, &parents[i]); + while (i < levels) + { + dbus_message_iter_open_container (&parents[i], DBUS_TYPE_VARIANT, + i == (levels - 1) ? + DBUS_TYPE_INT32_AS_STRING : + DBUS_TYPE_VARIANT_AS_STRING, + &children[i]); + ++i; + parents[i] = children[i-1]; + } + --i; + dbus_message_iter_append_basic (&children[i], DBUS_TYPE_INT32, &v_INT32); + while (i >= 0) + { + dbus_message_iter_close_container (&parents[i], &children[i]); + --i; + } + + dbus_free(parents); + dbus_free(children); + + return message; +} + static dbus_bool_t generate_special (DBusMessageDataIter *iter, DBusString *data, @@ -735,6 +782,24 @@ generate_special (DBusMessageDataIter *iter, *expected_validity = DBUS_INVALID_DICT_ENTRY_HAS_NO_FIELDS; } + else if (item_seq == 20) + { + /* 64 levels of nesting is OK */ + message = message_with_nesting_levels(64); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_VALID; + } + else if (item_seq == 21) + { + /* 65 levels of nesting is not OK */ + message = message_with_nesting_levels(65); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_INVALID_NESTED_TOO_DEEPLY; + } else { return FALSE;
CWE-399
null
null
5,947
generate_trivial (DBusMessageDataIter *iter, DBusString *data, DBusValidity *expected_validity) { return generate_outer (iter, data, expected_validity, generate_trivial_inner); }
DoS
0
generate_trivial (DBusMessageDataIter *iter, DBusString *data, DBusValidity *expected_validity) { return generate_outer (iter, data, expected_validity, generate_trivial_inner); }
@@ -333,6 +333,53 @@ simple_error (void) return message; } +static DBusMessage* +message_with_nesting_levels (int levels) +{ + DBusMessage *message; + dbus_int32_t v_INT32; + DBusMessageIter *parents; + DBusMessageIter *children; + int i; + + /* If levels is higher it breaks sig_refcount in DBusMessageRealIter + * in dbus-message.c, this assert is just to help you know you need + * to fix that if you hit it + */ + _dbus_assert (levels < 256); + + parents = dbus_new(DBusMessageIter, levels + 1); + children = dbus_new(DBusMessageIter, levels + 1); + + v_INT32 = 42; + message = simple_method_call (); + + i = 0; + dbus_message_iter_init_append (message, &parents[i]); + while (i < levels) + { + dbus_message_iter_open_container (&parents[i], DBUS_TYPE_VARIANT, + i == (levels - 1) ? + DBUS_TYPE_INT32_AS_STRING : + DBUS_TYPE_VARIANT_AS_STRING, + &children[i]); + ++i; + parents[i] = children[i-1]; + } + --i; + dbus_message_iter_append_basic (&children[i], DBUS_TYPE_INT32, &v_INT32); + while (i >= 0) + { + dbus_message_iter_close_container (&parents[i], &children[i]); + --i; + } + + dbus_free(parents); + dbus_free(children); + + return message; +} + static dbus_bool_t generate_special (DBusMessageDataIter *iter, DBusString *data, @@ -735,6 +782,24 @@ generate_special (DBusMessageDataIter *iter, *expected_validity = DBUS_INVALID_DICT_ENTRY_HAS_NO_FIELDS; } + else if (item_seq == 20) + { + /* 64 levels of nesting is OK */ + message = message_with_nesting_levels(64); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_VALID; + } + else if (item_seq == 21) + { + /* 65 levels of nesting is not OK */ + message = message_with_nesting_levels(65); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_INVALID_NESTED_TOO_DEEPLY; + } else { return FALSE;
CWE-399
null
null
5,948
generate_trivial_inner (DBusMessageDataIter *iter, DBusMessage **message_p) { DBusMessage *message; switch (iter_get_sequence (iter)) { case 0: message = dbus_message_new_method_call ("org.freedesktop.TextEditor", "/foo/bar", "org.freedesktop.DocumentFactory", "Create"); break; case 1: message = dbus_message_new (DBUS_MESSAGE_TYPE_METHOD_RETURN); set_reply_serial (message); break; case 2: message = dbus_message_new_signal ("/foo/bar", "org.freedesktop.DocumentFactory", "Created"); break; case 3: message = dbus_message_new (DBUS_MESSAGE_TYPE_ERROR); if (!dbus_message_set_error_name (message, "org.freedesktop.TestErrorName")) _dbus_assert_not_reached ("oom"); { DBusMessageIter iter; const char *v_STRING = "This is an error"; dbus_message_iter_init_append (message, &iter); if (!dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &v_STRING)) _dbus_assert_not_reached ("oom"); } set_reply_serial (message); break; default: return FALSE; } if (message == NULL) _dbus_assert_not_reached ("oom"); *message_p = message; return TRUE; }
DoS
0
generate_trivial_inner (DBusMessageDataIter *iter, DBusMessage **message_p) { DBusMessage *message; switch (iter_get_sequence (iter)) { case 0: message = dbus_message_new_method_call ("org.freedesktop.TextEditor", "/foo/bar", "org.freedesktop.DocumentFactory", "Create"); break; case 1: message = dbus_message_new (DBUS_MESSAGE_TYPE_METHOD_RETURN); set_reply_serial (message); break; case 2: message = dbus_message_new_signal ("/foo/bar", "org.freedesktop.DocumentFactory", "Created"); break; case 3: message = dbus_message_new (DBUS_MESSAGE_TYPE_ERROR); if (!dbus_message_set_error_name (message, "org.freedesktop.TestErrorName")) _dbus_assert_not_reached ("oom"); { DBusMessageIter iter; const char *v_STRING = "This is an error"; dbus_message_iter_init_append (message, &iter); if (!dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &v_STRING)) _dbus_assert_not_reached ("oom"); } set_reply_serial (message); break; default: return FALSE; } if (message == NULL) _dbus_assert_not_reached ("oom"); *message_p = message; return TRUE; }
@@ -333,6 +333,53 @@ simple_error (void) return message; } +static DBusMessage* +message_with_nesting_levels (int levels) +{ + DBusMessage *message; + dbus_int32_t v_INT32; + DBusMessageIter *parents; + DBusMessageIter *children; + int i; + + /* If levels is higher it breaks sig_refcount in DBusMessageRealIter + * in dbus-message.c, this assert is just to help you know you need + * to fix that if you hit it + */ + _dbus_assert (levels < 256); + + parents = dbus_new(DBusMessageIter, levels + 1); + children = dbus_new(DBusMessageIter, levels + 1); + + v_INT32 = 42; + message = simple_method_call (); + + i = 0; + dbus_message_iter_init_append (message, &parents[i]); + while (i < levels) + { + dbus_message_iter_open_container (&parents[i], DBUS_TYPE_VARIANT, + i == (levels - 1) ? + DBUS_TYPE_INT32_AS_STRING : + DBUS_TYPE_VARIANT_AS_STRING, + &children[i]); + ++i; + parents[i] = children[i-1]; + } + --i; + dbus_message_iter_append_basic (&children[i], DBUS_TYPE_INT32, &v_INT32); + while (i >= 0) + { + dbus_message_iter_close_container (&parents[i], &children[i]); + --i; + } + + dbus_free(parents); + dbus_free(children); + + return message; +} + static dbus_bool_t generate_special (DBusMessageDataIter *iter, DBusString *data, @@ -735,6 +782,24 @@ generate_special (DBusMessageDataIter *iter, *expected_validity = DBUS_INVALID_DICT_ENTRY_HAS_NO_FIELDS; } + else if (item_seq == 20) + { + /* 64 levels of nesting is OK */ + message = message_with_nesting_levels(64); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_VALID; + } + else if (item_seq == 21) + { + /* 65 levels of nesting is not OK */ + message = message_with_nesting_levels(65); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_INVALID_NESTED_TOO_DEEPLY; + } else { return FALSE;
CWE-399
null
null
5,949
iter_first_in_series (DBusMessageDataIter *iter) { int i; i = iter->depth; while (i < _DBUS_MESSAGE_DATA_MAX_NESTING) { if (iter->sequence_nos[i] != 0) return FALSE; ++i; } return TRUE; }
DoS
0
iter_first_in_series (DBusMessageDataIter *iter) { int i; i = iter->depth; while (i < _DBUS_MESSAGE_DATA_MAX_NESTING) { if (iter->sequence_nos[i] != 0) return FALSE; ++i; } return TRUE; }
@@ -333,6 +333,53 @@ simple_error (void) return message; } +static DBusMessage* +message_with_nesting_levels (int levels) +{ + DBusMessage *message; + dbus_int32_t v_INT32; + DBusMessageIter *parents; + DBusMessageIter *children; + int i; + + /* If levels is higher it breaks sig_refcount in DBusMessageRealIter + * in dbus-message.c, this assert is just to help you know you need + * to fix that if you hit it + */ + _dbus_assert (levels < 256); + + parents = dbus_new(DBusMessageIter, levels + 1); + children = dbus_new(DBusMessageIter, levels + 1); + + v_INT32 = 42; + message = simple_method_call (); + + i = 0; + dbus_message_iter_init_append (message, &parents[i]); + while (i < levels) + { + dbus_message_iter_open_container (&parents[i], DBUS_TYPE_VARIANT, + i == (levels - 1) ? + DBUS_TYPE_INT32_AS_STRING : + DBUS_TYPE_VARIANT_AS_STRING, + &children[i]); + ++i; + parents[i] = children[i-1]; + } + --i; + dbus_message_iter_append_basic (&children[i], DBUS_TYPE_INT32, &v_INT32); + while (i >= 0) + { + dbus_message_iter_close_container (&parents[i], &children[i]); + --i; + } + + dbus_free(parents); + dbus_free(children); + + return message; +} + static dbus_bool_t generate_special (DBusMessageDataIter *iter, DBusString *data, @@ -735,6 +782,24 @@ generate_special (DBusMessageDataIter *iter, *expected_validity = DBUS_INVALID_DICT_ENTRY_HAS_NO_FIELDS; } + else if (item_seq == 20) + { + /* 64 levels of nesting is OK */ + message = message_with_nesting_levels(64); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_VALID; + } + else if (item_seq == 21) + { + /* 65 levels of nesting is not OK */ + message = message_with_nesting_levels(65); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_INVALID_NESTED_TOO_DEEPLY; + } else { return FALSE;
CWE-399
null
null
5,950
iter_get_sequence (DBusMessageDataIter *iter) { _dbus_assert (iter->sequence_nos[iter->depth] >= 0); return iter->sequence_nos[iter->depth]; }
DoS
0
iter_get_sequence (DBusMessageDataIter *iter) { _dbus_assert (iter->sequence_nos[iter->depth] >= 0); return iter->sequence_nos[iter->depth]; }
@@ -333,6 +333,53 @@ simple_error (void) return message; } +static DBusMessage* +message_with_nesting_levels (int levels) +{ + DBusMessage *message; + dbus_int32_t v_INT32; + DBusMessageIter *parents; + DBusMessageIter *children; + int i; + + /* If levels is higher it breaks sig_refcount in DBusMessageRealIter + * in dbus-message.c, this assert is just to help you know you need + * to fix that if you hit it + */ + _dbus_assert (levels < 256); + + parents = dbus_new(DBusMessageIter, levels + 1); + children = dbus_new(DBusMessageIter, levels + 1); + + v_INT32 = 42; + message = simple_method_call (); + + i = 0; + dbus_message_iter_init_append (message, &parents[i]); + while (i < levels) + { + dbus_message_iter_open_container (&parents[i], DBUS_TYPE_VARIANT, + i == (levels - 1) ? + DBUS_TYPE_INT32_AS_STRING : + DBUS_TYPE_VARIANT_AS_STRING, + &children[i]); + ++i; + parents[i] = children[i-1]; + } + --i; + dbus_message_iter_append_basic (&children[i], DBUS_TYPE_INT32, &v_INT32); + while (i >= 0) + { + dbus_message_iter_close_container (&parents[i], &children[i]); + --i; + } + + dbus_free(parents); + dbus_free(children); + + return message; +} + static dbus_bool_t generate_special (DBusMessageDataIter *iter, DBusString *data, @@ -735,6 +782,24 @@ generate_special (DBusMessageDataIter *iter, *expected_validity = DBUS_INVALID_DICT_ENTRY_HAS_NO_FIELDS; } + else if (item_seq == 20) + { + /* 64 levels of nesting is OK */ + message = message_with_nesting_levels(64); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_VALID; + } + else if (item_seq == 21) + { + /* 65 levels of nesting is not OK */ + message = message_with_nesting_levels(65); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_INVALID_NESTED_TOO_DEEPLY; + } else { return FALSE;
CWE-399
null
null
5,951
iter_next (DBusMessageDataIter *iter) { iter->sequence_nos[iter->depth] += 1; }
DoS
0
iter_next (DBusMessageDataIter *iter) { iter->sequence_nos[iter->depth] += 1; }
@@ -333,6 +333,53 @@ simple_error (void) return message; } +static DBusMessage* +message_with_nesting_levels (int levels) +{ + DBusMessage *message; + dbus_int32_t v_INT32; + DBusMessageIter *parents; + DBusMessageIter *children; + int i; + + /* If levels is higher it breaks sig_refcount in DBusMessageRealIter + * in dbus-message.c, this assert is just to help you know you need + * to fix that if you hit it + */ + _dbus_assert (levels < 256); + + parents = dbus_new(DBusMessageIter, levels + 1); + children = dbus_new(DBusMessageIter, levels + 1); + + v_INT32 = 42; + message = simple_method_call (); + + i = 0; + dbus_message_iter_init_append (message, &parents[i]); + while (i < levels) + { + dbus_message_iter_open_container (&parents[i], DBUS_TYPE_VARIANT, + i == (levels - 1) ? + DBUS_TYPE_INT32_AS_STRING : + DBUS_TYPE_VARIANT_AS_STRING, + &children[i]); + ++i; + parents[i] = children[i-1]; + } + --i; + dbus_message_iter_append_basic (&children[i], DBUS_TYPE_INT32, &v_INT32); + while (i >= 0) + { + dbus_message_iter_close_container (&parents[i], &children[i]); + --i; + } + + dbus_free(parents); + dbus_free(children); + + return message; +} + static dbus_bool_t generate_special (DBusMessageDataIter *iter, DBusString *data, @@ -735,6 +782,24 @@ generate_special (DBusMessageDataIter *iter, *expected_validity = DBUS_INVALID_DICT_ENTRY_HAS_NO_FIELDS; } + else if (item_seq == 20) + { + /* 64 levels of nesting is OK */ + message = message_with_nesting_levels(64); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_VALID; + } + else if (item_seq == 21) + { + /* 65 levels of nesting is not OK */ + message = message_with_nesting_levels(65); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_INVALID_NESTED_TOO_DEEPLY; + } else { return FALSE;
CWE-399
null
null
5,952
iter_recurse (DBusMessageDataIter *iter) { iter->depth += 1; _dbus_assert (iter->depth < _DBUS_MESSAGE_DATA_MAX_NESTING); _dbus_assert (iter->sequence_nos[iter->depth] >= 0); }
DoS
0
iter_recurse (DBusMessageDataIter *iter) { iter->depth += 1; _dbus_assert (iter->depth < _DBUS_MESSAGE_DATA_MAX_NESTING); _dbus_assert (iter->sequence_nos[iter->depth] >= 0); }
@@ -333,6 +333,53 @@ simple_error (void) return message; } +static DBusMessage* +message_with_nesting_levels (int levels) +{ + DBusMessage *message; + dbus_int32_t v_INT32; + DBusMessageIter *parents; + DBusMessageIter *children; + int i; + + /* If levels is higher it breaks sig_refcount in DBusMessageRealIter + * in dbus-message.c, this assert is just to help you know you need + * to fix that if you hit it + */ + _dbus_assert (levels < 256); + + parents = dbus_new(DBusMessageIter, levels + 1); + children = dbus_new(DBusMessageIter, levels + 1); + + v_INT32 = 42; + message = simple_method_call (); + + i = 0; + dbus_message_iter_init_append (message, &parents[i]); + while (i < levels) + { + dbus_message_iter_open_container (&parents[i], DBUS_TYPE_VARIANT, + i == (levels - 1) ? + DBUS_TYPE_INT32_AS_STRING : + DBUS_TYPE_VARIANT_AS_STRING, + &children[i]); + ++i; + parents[i] = children[i-1]; + } + --i; + dbus_message_iter_append_basic (&children[i], DBUS_TYPE_INT32, &v_INT32); + while (i >= 0) + { + dbus_message_iter_close_container (&parents[i], &children[i]); + --i; + } + + dbus_free(parents); + dbus_free(children); + + return message; +} + static dbus_bool_t generate_special (DBusMessageDataIter *iter, DBusString *data, @@ -735,6 +782,24 @@ generate_special (DBusMessageDataIter *iter, *expected_validity = DBUS_INVALID_DICT_ENTRY_HAS_NO_FIELDS; } + else if (item_seq == 20) + { + /* 64 levels of nesting is OK */ + message = message_with_nesting_levels(64); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_VALID; + } + else if (item_seq == 21) + { + /* 65 levels of nesting is not OK */ + message = message_with_nesting_levels(65); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_INVALID_NESTED_TOO_DEEPLY; + } else { return FALSE;
CWE-399
null
null
5,953
iter_set_sequence (DBusMessageDataIter *iter, int sequence) { _dbus_assert (sequence >= 0); iter->sequence_nos[iter->depth] = sequence; }
DoS
0
iter_set_sequence (DBusMessageDataIter *iter, int sequence) { _dbus_assert (sequence >= 0); iter->sequence_nos[iter->depth] = sequence; }
@@ -333,6 +333,53 @@ simple_error (void) return message; } +static DBusMessage* +message_with_nesting_levels (int levels) +{ + DBusMessage *message; + dbus_int32_t v_INT32; + DBusMessageIter *parents; + DBusMessageIter *children; + int i; + + /* If levels is higher it breaks sig_refcount in DBusMessageRealIter + * in dbus-message.c, this assert is just to help you know you need + * to fix that if you hit it + */ + _dbus_assert (levels < 256); + + parents = dbus_new(DBusMessageIter, levels + 1); + children = dbus_new(DBusMessageIter, levels + 1); + + v_INT32 = 42; + message = simple_method_call (); + + i = 0; + dbus_message_iter_init_append (message, &parents[i]); + while (i < levels) + { + dbus_message_iter_open_container (&parents[i], DBUS_TYPE_VARIANT, + i == (levels - 1) ? + DBUS_TYPE_INT32_AS_STRING : + DBUS_TYPE_VARIANT_AS_STRING, + &children[i]); + ++i; + parents[i] = children[i-1]; + } + --i; + dbus_message_iter_append_basic (&children[i], DBUS_TYPE_INT32, &v_INT32); + while (i >= 0) + { + dbus_message_iter_close_container (&parents[i], &children[i]); + --i; + } + + dbus_free(parents); + dbus_free(children); + + return message; +} + static dbus_bool_t generate_special (DBusMessageDataIter *iter, DBusString *data, @@ -735,6 +782,24 @@ generate_special (DBusMessageDataIter *iter, *expected_validity = DBUS_INVALID_DICT_ENTRY_HAS_NO_FIELDS; } + else if (item_seq == 20) + { + /* 64 levels of nesting is OK */ + message = message_with_nesting_levels(64); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_VALID; + } + else if (item_seq == 21) + { + /* 65 levels of nesting is not OK */ + message = message_with_nesting_levels(65); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_INVALID_NESTED_TOO_DEEPLY; + } else { return FALSE;
CWE-399
null
null
5,954
iter_unrecurse (DBusMessageDataIter *iter) { iter->depth -= 1; _dbus_assert (iter->depth >= 0); }
DoS
0
iter_unrecurse (DBusMessageDataIter *iter) { iter->depth -= 1; _dbus_assert (iter->depth >= 0); }
@@ -333,6 +333,53 @@ simple_error (void) return message; } +static DBusMessage* +message_with_nesting_levels (int levels) +{ + DBusMessage *message; + dbus_int32_t v_INT32; + DBusMessageIter *parents; + DBusMessageIter *children; + int i; + + /* If levels is higher it breaks sig_refcount in DBusMessageRealIter + * in dbus-message.c, this assert is just to help you know you need + * to fix that if you hit it + */ + _dbus_assert (levels < 256); + + parents = dbus_new(DBusMessageIter, levels + 1); + children = dbus_new(DBusMessageIter, levels + 1); + + v_INT32 = 42; + message = simple_method_call (); + + i = 0; + dbus_message_iter_init_append (message, &parents[i]); + while (i < levels) + { + dbus_message_iter_open_container (&parents[i], DBUS_TYPE_VARIANT, + i == (levels - 1) ? + DBUS_TYPE_INT32_AS_STRING : + DBUS_TYPE_VARIANT_AS_STRING, + &children[i]); + ++i; + parents[i] = children[i-1]; + } + --i; + dbus_message_iter_append_basic (&children[i], DBUS_TYPE_INT32, &v_INT32); + while (i >= 0) + { + dbus_message_iter_close_container (&parents[i], &children[i]); + --i; + } + + dbus_free(parents); + dbus_free(children); + + return message; +} + static dbus_bool_t generate_special (DBusMessageDataIter *iter, DBusString *data, @@ -735,6 +782,24 @@ generate_special (DBusMessageDataIter *iter, *expected_validity = DBUS_INVALID_DICT_ENTRY_HAS_NO_FIELDS; } + else if (item_seq == 20) + { + /* 64 levels of nesting is OK */ + message = message_with_nesting_levels(64); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_VALID; + } + else if (item_seq == 21) + { + /* 65 levels of nesting is not OK */ + message = message_with_nesting_levels(65); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_INVALID_NESTED_TOO_DEEPLY; + } else { return FALSE;
CWE-399
null
null
5,955
set_reply_serial (DBusMessage *message) { if (message == NULL) _dbus_assert_not_reached ("oom"); if (!dbus_message_set_reply_serial (message, 100)) _dbus_assert_not_reached ("oom"); }
DoS
0
set_reply_serial (DBusMessage *message) { if (message == NULL) _dbus_assert_not_reached ("oom"); if (!dbus_message_set_reply_serial (message, 100)) _dbus_assert_not_reached ("oom"); }
@@ -333,6 +333,53 @@ simple_error (void) return message; } +static DBusMessage* +message_with_nesting_levels (int levels) +{ + DBusMessage *message; + dbus_int32_t v_INT32; + DBusMessageIter *parents; + DBusMessageIter *children; + int i; + + /* If levels is higher it breaks sig_refcount in DBusMessageRealIter + * in dbus-message.c, this assert is just to help you know you need + * to fix that if you hit it + */ + _dbus_assert (levels < 256); + + parents = dbus_new(DBusMessageIter, levels + 1); + children = dbus_new(DBusMessageIter, levels + 1); + + v_INT32 = 42; + message = simple_method_call (); + + i = 0; + dbus_message_iter_init_append (message, &parents[i]); + while (i < levels) + { + dbus_message_iter_open_container (&parents[i], DBUS_TYPE_VARIANT, + i == (levels - 1) ? + DBUS_TYPE_INT32_AS_STRING : + DBUS_TYPE_VARIANT_AS_STRING, + &children[i]); + ++i; + parents[i] = children[i-1]; + } + --i; + dbus_message_iter_append_basic (&children[i], DBUS_TYPE_INT32, &v_INT32); + while (i >= 0) + { + dbus_message_iter_close_container (&parents[i], &children[i]); + --i; + } + + dbus_free(parents); + dbus_free(children); + + return message; +} + static dbus_bool_t generate_special (DBusMessageDataIter *iter, DBusString *data, @@ -735,6 +782,24 @@ generate_special (DBusMessageDataIter *iter, *expected_validity = DBUS_INVALID_DICT_ENTRY_HAS_NO_FIELDS; } + else if (item_seq == 20) + { + /* 64 levels of nesting is OK */ + message = message_with_nesting_levels(64); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_VALID; + } + else if (item_seq == 21) + { + /* 65 levels of nesting is not OK */ + message = message_with_nesting_levels(65); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_INVALID_NESTED_TOO_DEEPLY; + } else { return FALSE;
CWE-399
null
null
5,956
simple_error (void) { DBusMessage *message; message = dbus_message_new (DBUS_MESSAGE_TYPE_ERROR); if (message == NULL) _dbus_assert_not_reached ("oom"); if (!dbus_message_set_error_name (message, "foo.bar")) _dbus_assert_not_reached ("oom"); set_reply_serial (message); return message; }
DoS
0
simple_error (void) { DBusMessage *message; message = dbus_message_new (DBUS_MESSAGE_TYPE_ERROR); if (message == NULL) _dbus_assert_not_reached ("oom"); if (!dbus_message_set_error_name (message, "foo.bar")) _dbus_assert_not_reached ("oom"); set_reply_serial (message); return message; }
@@ -333,6 +333,53 @@ simple_error (void) return message; } +static DBusMessage* +message_with_nesting_levels (int levels) +{ + DBusMessage *message; + dbus_int32_t v_INT32; + DBusMessageIter *parents; + DBusMessageIter *children; + int i; + + /* If levels is higher it breaks sig_refcount in DBusMessageRealIter + * in dbus-message.c, this assert is just to help you know you need + * to fix that if you hit it + */ + _dbus_assert (levels < 256); + + parents = dbus_new(DBusMessageIter, levels + 1); + children = dbus_new(DBusMessageIter, levels + 1); + + v_INT32 = 42; + message = simple_method_call (); + + i = 0; + dbus_message_iter_init_append (message, &parents[i]); + while (i < levels) + { + dbus_message_iter_open_container (&parents[i], DBUS_TYPE_VARIANT, + i == (levels - 1) ? + DBUS_TYPE_INT32_AS_STRING : + DBUS_TYPE_VARIANT_AS_STRING, + &children[i]); + ++i; + parents[i] = children[i-1]; + } + --i; + dbus_message_iter_append_basic (&children[i], DBUS_TYPE_INT32, &v_INT32); + while (i >= 0) + { + dbus_message_iter_close_container (&parents[i], &children[i]); + --i; + } + + dbus_free(parents); + dbus_free(children); + + return message; +} + static dbus_bool_t generate_special (DBusMessageDataIter *iter, DBusString *data, @@ -735,6 +782,24 @@ generate_special (DBusMessageDataIter *iter, *expected_validity = DBUS_INVALID_DICT_ENTRY_HAS_NO_FIELDS; } + else if (item_seq == 20) + { + /* 64 levels of nesting is OK */ + message = message_with_nesting_levels(64); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_VALID; + } + else if (item_seq == 21) + { + /* 65 levels of nesting is not OK */ + message = message_with_nesting_levels(65); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_INVALID_NESTED_TOO_DEEPLY; + } else { return FALSE;
CWE-399
null
null
5,957
simple_method_return (void) { DBusMessage *message; message = dbus_message_new (DBUS_MESSAGE_TYPE_METHOD_RETURN); if (message == NULL) _dbus_assert_not_reached ("oom"); set_reply_serial (message); return message; }
DoS
0
simple_method_return (void) { DBusMessage *message; message = dbus_message_new (DBUS_MESSAGE_TYPE_METHOD_RETURN); if (message == NULL) _dbus_assert_not_reached ("oom"); set_reply_serial (message); return message; }
@@ -333,6 +333,53 @@ simple_error (void) return message; } +static DBusMessage* +message_with_nesting_levels (int levels) +{ + DBusMessage *message; + dbus_int32_t v_INT32; + DBusMessageIter *parents; + DBusMessageIter *children; + int i; + + /* If levels is higher it breaks sig_refcount in DBusMessageRealIter + * in dbus-message.c, this assert is just to help you know you need + * to fix that if you hit it + */ + _dbus_assert (levels < 256); + + parents = dbus_new(DBusMessageIter, levels + 1); + children = dbus_new(DBusMessageIter, levels + 1); + + v_INT32 = 42; + message = simple_method_call (); + + i = 0; + dbus_message_iter_init_append (message, &parents[i]); + while (i < levels) + { + dbus_message_iter_open_container (&parents[i], DBUS_TYPE_VARIANT, + i == (levels - 1) ? + DBUS_TYPE_INT32_AS_STRING : + DBUS_TYPE_VARIANT_AS_STRING, + &children[i]); + ++i; + parents[i] = children[i-1]; + } + --i; + dbus_message_iter_append_basic (&children[i], DBUS_TYPE_INT32, &v_INT32); + while (i >= 0) + { + dbus_message_iter_close_container (&parents[i], &children[i]); + --i; + } + + dbus_free(parents); + dbus_free(children); + + return message; +} + static dbus_bool_t generate_special (DBusMessageDataIter *iter, DBusString *data, @@ -735,6 +782,24 @@ generate_special (DBusMessageDataIter *iter, *expected_validity = DBUS_INVALID_DICT_ENTRY_HAS_NO_FIELDS; } + else if (item_seq == 20) + { + /* 64 levels of nesting is OK */ + message = message_with_nesting_levels(64); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_VALID; + } + else if (item_seq == 21) + { + /* 65 levels of nesting is not OK */ + message = message_with_nesting_levels(65); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_INVALID_NESTED_TOO_DEEPLY; + } else { return FALSE;
CWE-399
null
null
5,958
simple_signal (void) { DBusMessage *message; message = dbus_message_new_signal ("/f/b", "o.b.Z", "Fro"); if (message == NULL) _dbus_assert_not_reached ("oom"); return message; }
DoS
0
simple_signal (void) { DBusMessage *message; message = dbus_message_new_signal ("/f/b", "o.b.Z", "Fro"); if (message == NULL) _dbus_assert_not_reached ("oom"); return message; }
@@ -333,6 +333,53 @@ simple_error (void) return message; } +static DBusMessage* +message_with_nesting_levels (int levels) +{ + DBusMessage *message; + dbus_int32_t v_INT32; + DBusMessageIter *parents; + DBusMessageIter *children; + int i; + + /* If levels is higher it breaks sig_refcount in DBusMessageRealIter + * in dbus-message.c, this assert is just to help you know you need + * to fix that if you hit it + */ + _dbus_assert (levels < 256); + + parents = dbus_new(DBusMessageIter, levels + 1); + children = dbus_new(DBusMessageIter, levels + 1); + + v_INT32 = 42; + message = simple_method_call (); + + i = 0; + dbus_message_iter_init_append (message, &parents[i]); + while (i < levels) + { + dbus_message_iter_open_container (&parents[i], DBUS_TYPE_VARIANT, + i == (levels - 1) ? + DBUS_TYPE_INT32_AS_STRING : + DBUS_TYPE_VARIANT_AS_STRING, + &children[i]); + ++i; + parents[i] = children[i-1]; + } + --i; + dbus_message_iter_append_basic (&children[i], DBUS_TYPE_INT32, &v_INT32); + while (i >= 0) + { + dbus_message_iter_close_container (&parents[i], &children[i]); + --i; + } + + dbus_free(parents); + dbus_free(children); + + return message; +} + static dbus_bool_t generate_special (DBusMessageDataIter *iter, DBusString *data, @@ -735,6 +782,24 @@ generate_special (DBusMessageDataIter *iter, *expected_validity = DBUS_INVALID_DICT_ENTRY_HAS_NO_FIELDS; } + else if (item_seq == 20) + { + /* 64 levels of nesting is OK */ + message = message_with_nesting_levels(64); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_VALID; + } + else if (item_seq == 21) + { + /* 65 levels of nesting is not OK */ + message = message_with_nesting_levels(65); + + generate_from_message (data, expected_validity, message); + + *expected_validity = DBUS_INVALID_NESTED_TOO_DEEPLY; + } else { return FALSE;
CWE-399
null
null
5,959
tt_check_single_notdef( FT_Face ttface ) { FT_Bool result = FALSE; TT_Face face = (TT_Face)ttface; FT_UInt asize; FT_ULong i; FT_ULong glyph_index = 0; FT_UInt count = 0; for( i = 0; i < face->num_locations; i++ ) { tt_face_get_location( face, i, &asize ); if ( asize > 0 ) { count += 1; if ( count > 1 ) break; glyph_index = i; } } /* Only have a single outline. */ if ( count == 1 ) { if ( glyph_index == 0 ) result = TRUE; else { /* FIXME: Need to test glyphname == .notdef ? */ FT_Error error; char buf[8]; error = FT_Get_Glyph_Name( ttface, glyph_index, buf, 8 ); if ( !error && buf[0] == '.' && !ft_strncmp( buf, ".notdef", 8 ) ) result = TRUE; } } return result; }
Overflow
0
tt_check_single_notdef( FT_Face ttface ) { FT_Bool result = FALSE; TT_Face face = (TT_Face)ttface; FT_UInt asize; FT_ULong i; FT_ULong glyph_index = 0; FT_UInt count = 0; for( i = 0; i < face->num_locations; i++ ) { tt_face_get_location( face, i, &asize ); if ( asize > 0 ) { count += 1; if ( count > 1 ) break; glyph_index = i; } } /* Only have a single outline. */ if ( count == 1 ) { if ( glyph_index == 0 ) result = TRUE; else { /* FIXME: Need to test glyphname == .notdef ? */ FT_Error error; char buf[8]; error = FT_Get_Glyph_Name( ttface, glyph_index, buf, 8 ); if ( !error && buf[0] == '.' && !ft_strncmp( buf, ".notdef", 8 ) ) result = TRUE; } } return result; }
@@ -1212,10 +1212,14 @@ FT_Size_Metrics* metrics; - size->ttmetrics.valid = FALSE; - face = (TT_Face)size->root.face; + /* nothing to do for CFF2 */ + if ( face->isCFF2 ) + return FT_Err_Ok; + + size->ttmetrics.valid = FALSE; + metrics = &size->metrics; /* copy the result from base layer */
CWE-787
null
null
5,960
tt_check_trickyness( FT_Face face ) { if ( !face ) return FALSE; /* For first, check the face name for quick check. */ if ( face->family_name && tt_check_trickyness_family( face->family_name ) ) return TRUE; /* Type42 fonts may lack `name' tables, we thus try to identify */ /* tricky fonts by checking the checksums of Type42-persistent */ /* sfnt tables (`cvt', `fpgm', and `prep'). */ if ( tt_check_trickyness_sfnt_ids( (TT_Face)face ) ) return TRUE; return FALSE; }
Overflow
0
tt_check_trickyness( FT_Face face ) { if ( !face ) return FALSE; /* For first, check the face name for quick check. */ if ( face->family_name && tt_check_trickyness_family( face->family_name ) ) return TRUE; /* Type42 fonts may lack `name' tables, we thus try to identify */ /* tricky fonts by checking the checksums of Type42-persistent */ /* sfnt tables (`cvt', `fpgm', and `prep'). */ if ( tt_check_trickyness_sfnt_ids( (TT_Face)face ) ) return TRUE; return FALSE; }
@@ -1212,10 +1212,14 @@ FT_Size_Metrics* metrics; - size->ttmetrics.valid = FALSE; - face = (TT_Face)size->root.face; + /* nothing to do for CFF2 */ + if ( face->isCFF2 ) + return FT_Err_Ok; + + size->ttmetrics.valid = FALSE; + metrics = &size->metrics; /* copy the result from base layer */
CWE-787
null
null
5,961
tt_driver_done( FT_Module ttdriver ) /* TT_Driver */ { FT_UNUSED( ttdriver ); }
Overflow
0
tt_driver_done( FT_Module ttdriver ) /* TT_Driver */ { FT_UNUSED( ttdriver ); }
@@ -1212,10 +1212,14 @@ FT_Size_Metrics* metrics; - size->ttmetrics.valid = FALSE; - face = (TT_Face)size->root.face; + /* nothing to do for CFF2 */ + if ( face->isCFF2 ) + return FT_Err_Ok; + + size->ttmetrics.valid = FALSE; + metrics = &size->metrics; /* copy the result from base layer */
CWE-787
null
null
5,962
tt_driver_init( FT_Module ttdriver ) /* TT_Driver */ { #ifdef TT_USE_BYTECODE_INTERPRETER TT_Driver driver = (TT_Driver)ttdriver; driver->interpreter_version = TT_INTERPRETER_VERSION_35; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY driver->interpreter_version = TT_INTERPRETER_VERSION_38; #endif #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL driver->interpreter_version = TT_INTERPRETER_VERSION_40; #endif #else /* !TT_USE_BYTECODE_INTERPRETER */ FT_UNUSED( ttdriver ); #endif /* !TT_USE_BYTECODE_INTERPRETER */ return FT_Err_Ok; }
Overflow
0
tt_driver_init( FT_Module ttdriver ) /* TT_Driver */ { #ifdef TT_USE_BYTECODE_INTERPRETER TT_Driver driver = (TT_Driver)ttdriver; driver->interpreter_version = TT_INTERPRETER_VERSION_35; #ifdef TT_SUPPORT_SUBPIXEL_HINTING_INFINALITY driver->interpreter_version = TT_INTERPRETER_VERSION_38; #endif #ifdef TT_SUPPORT_SUBPIXEL_HINTING_MINIMAL driver->interpreter_version = TT_INTERPRETER_VERSION_40; #endif #else /* !TT_USE_BYTECODE_INTERPRETER */ FT_UNUSED( ttdriver ); #endif /* !TT_USE_BYTECODE_INTERPRETER */ return FT_Err_Ok; }
@@ -1212,10 +1212,14 @@ FT_Size_Metrics* metrics; - size->ttmetrics.valid = FALSE; - face = (TT_Face)size->root.face; + /* nothing to do for CFF2 */ + if ( face->isCFF2 ) + return FT_Err_Ok; + + size->ttmetrics.valid = FALSE; + metrics = &size->metrics; /* copy the result from base layer */
CWE-787
null
null
5,963
tt_face_init( FT_Stream stream, FT_Face ttface, /* TT_Face */ FT_Int face_index, FT_Int num_params, FT_Parameter* params ) { FT_Error error; FT_Library library; SFNT_Service sfnt; TT_Face face = (TT_Face)ttface; FT_TRACE2(( "TTF driver\n" )); library = ttface->driver->root.library; sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" ); if ( !sfnt ) { FT_ERROR(( "tt_face_init: cannot access `sfnt' module\n" )); error = FT_THROW( Missing_Module ); goto Exit; } /* create input stream from resource */ if ( FT_STREAM_SEEK( 0 ) ) goto Exit; /* check that we have a valid TrueType file */ FT_TRACE2(( " " )); error = sfnt->init_face( stream, face, face_index, num_params, params ); /* Stream may have changed. */ stream = face->root.stream; if ( error ) goto Exit; /* We must also be able to accept Mac/GX fonts, as well as OT ones. */ /* The 0x00020000 tag is completely undocumented; some fonts from */ /* Arphic made for Chinese Windows 3.1 have this. */ if ( face->format_tag != 0x00010000L && /* MS fonts */ face->format_tag != 0x00020000L && /* CJK fonts for Win 3.1 */ face->format_tag != TTAG_true ) /* Mac fonts */ { FT_TRACE2(( " not a TTF font\n" )); goto Bad_Format; } #ifdef TT_USE_BYTECODE_INTERPRETER ttface->face_flags |= FT_FACE_FLAG_HINTER; #endif /* If we are performing a simple font format check, exit immediately. */ if ( face_index < 0 ) return FT_Err_Ok; /* Load font directory */ error = sfnt->load_face( stream, face, face_index, num_params, params ); if ( error ) goto Exit; if ( tt_check_trickyness( ttface ) ) ttface->face_flags |= FT_FACE_FLAG_TRICKY; error = tt_face_load_hdmx( face, stream ); if ( error ) goto Exit; if ( FT_IS_SCALABLE( ttface ) ) { #ifdef FT_CONFIG_OPTION_INCREMENTAL if ( !ttface->internal->incremental_interface ) #endif { error = tt_face_load_loca( face, stream ); /* having a (non-zero) `glyf' table without */ /* a `loca' table is not valid */ if ( face->glyf_len && FT_ERR_EQ( error, Table_Missing ) ) goto Exit; if ( error ) goto Exit; } /* `fpgm', `cvt', and `prep' are optional */ error = tt_face_load_cvt( face, stream ); if ( error && FT_ERR_NEQ( error, Table_Missing ) ) goto Exit; error = tt_face_load_fpgm( face, stream ); if ( error && FT_ERR_NEQ( error, Table_Missing ) ) goto Exit; error = tt_face_load_prep( face, stream ); if ( error && FT_ERR_NEQ( error, Table_Missing ) ) goto Exit; /* Check the scalable flag based on `loca'. */ #ifdef FT_CONFIG_OPTION_INCREMENTAL if ( !ttface->internal->incremental_interface ) #endif { if ( ttface->num_fixed_sizes && face->glyph_locations && tt_check_single_notdef( ttface ) ) { FT_TRACE5(( "tt_face_init:" " Only the `.notdef' glyph has an outline.\n" " " " Resetting scalable flag to FALSE.\n" )); ttface->face_flags &= ~FT_FACE_FLAG_SCALABLE; } } } #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT { FT_Int instance_index = face_index >> 16; if ( FT_HAS_MULTIPLE_MASTERS( ttface ) && instance_index > 0 ) { error = TT_Get_MM_Var( face, NULL ); if ( error ) goto Exit; if ( face->blend->mmvar->namedstyle ) { FT_Memory memory = ttface->memory; FT_Var_Named_Style* named_style; FT_String* style_name; /* in `face_index', the instance index starts with value 1 */ named_style = face->blend->mmvar->namedstyle + instance_index - 1; error = sfnt->get_name( face, (FT_UShort)named_style->strid, &style_name ); if ( error ) goto Exit; /* set style name; if already set, replace it */ if ( face->root.style_name ) FT_FREE( face->root.style_name ); face->root.style_name = style_name; /* finally, select the named instance */ error = TT_Set_Var_Design( face, face->blend->mmvar->num_axis, named_style->coords ); if ( error ) goto Exit; tt_apply_mvar( face ); } } } #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ /* initialize standard glyph loading routines */ TT_Init_Glyph_Loading( face ); Exit: return error; Bad_Format: error = FT_THROW( Unknown_File_Format ); goto Exit; }
Overflow
0
tt_face_init( FT_Stream stream, FT_Face ttface, /* TT_Face */ FT_Int face_index, FT_Int num_params, FT_Parameter* params ) { FT_Error error; FT_Library library; SFNT_Service sfnt; TT_Face face = (TT_Face)ttface; FT_TRACE2(( "TTF driver\n" )); library = ttface->driver->root.library; sfnt = (SFNT_Service)FT_Get_Module_Interface( library, "sfnt" ); if ( !sfnt ) { FT_ERROR(( "tt_face_init: cannot access `sfnt' module\n" )); error = FT_THROW( Missing_Module ); goto Exit; } /* create input stream from resource */ if ( FT_STREAM_SEEK( 0 ) ) goto Exit; /* check that we have a valid TrueType file */ FT_TRACE2(( " " )); error = sfnt->init_face( stream, face, face_index, num_params, params ); /* Stream may have changed. */ stream = face->root.stream; if ( error ) goto Exit; /* We must also be able to accept Mac/GX fonts, as well as OT ones. */ /* The 0x00020000 tag is completely undocumented; some fonts from */ /* Arphic made for Chinese Windows 3.1 have this. */ if ( face->format_tag != 0x00010000L && /* MS fonts */ face->format_tag != 0x00020000L && /* CJK fonts for Win 3.1 */ face->format_tag != TTAG_true ) /* Mac fonts */ { FT_TRACE2(( " not a TTF font\n" )); goto Bad_Format; } #ifdef TT_USE_BYTECODE_INTERPRETER ttface->face_flags |= FT_FACE_FLAG_HINTER; #endif /* If we are performing a simple font format check, exit immediately. */ if ( face_index < 0 ) return FT_Err_Ok; /* Load font directory */ error = sfnt->load_face( stream, face, face_index, num_params, params ); if ( error ) goto Exit; if ( tt_check_trickyness( ttface ) ) ttface->face_flags |= FT_FACE_FLAG_TRICKY; error = tt_face_load_hdmx( face, stream ); if ( error ) goto Exit; if ( FT_IS_SCALABLE( ttface ) ) { #ifdef FT_CONFIG_OPTION_INCREMENTAL if ( !ttface->internal->incremental_interface ) #endif { error = tt_face_load_loca( face, stream ); /* having a (non-zero) `glyf' table without */ /* a `loca' table is not valid */ if ( face->glyf_len && FT_ERR_EQ( error, Table_Missing ) ) goto Exit; if ( error ) goto Exit; } /* `fpgm', `cvt', and `prep' are optional */ error = tt_face_load_cvt( face, stream ); if ( error && FT_ERR_NEQ( error, Table_Missing ) ) goto Exit; error = tt_face_load_fpgm( face, stream ); if ( error && FT_ERR_NEQ( error, Table_Missing ) ) goto Exit; error = tt_face_load_prep( face, stream ); if ( error && FT_ERR_NEQ( error, Table_Missing ) ) goto Exit; /* Check the scalable flag based on `loca'. */ #ifdef FT_CONFIG_OPTION_INCREMENTAL if ( !ttface->internal->incremental_interface ) #endif { if ( ttface->num_fixed_sizes && face->glyph_locations && tt_check_single_notdef( ttface ) ) { FT_TRACE5(( "tt_face_init:" " Only the `.notdef' glyph has an outline.\n" " " " Resetting scalable flag to FALSE.\n" )); ttface->face_flags &= ~FT_FACE_FLAG_SCALABLE; } } } #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT { FT_Int instance_index = face_index >> 16; if ( FT_HAS_MULTIPLE_MASTERS( ttface ) && instance_index > 0 ) { error = TT_Get_MM_Var( face, NULL ); if ( error ) goto Exit; if ( face->blend->mmvar->namedstyle ) { FT_Memory memory = ttface->memory; FT_Var_Named_Style* named_style; FT_String* style_name; /* in `face_index', the instance index starts with value 1 */ named_style = face->blend->mmvar->namedstyle + instance_index - 1; error = sfnt->get_name( face, (FT_UShort)named_style->strid, &style_name ); if ( error ) goto Exit; /* set style name; if already set, replace it */ if ( face->root.style_name ) FT_FREE( face->root.style_name ); face->root.style_name = style_name; /* finally, select the named instance */ error = TT_Set_Var_Design( face, face->blend->mmvar->num_axis, named_style->coords ); if ( error ) goto Exit; tt_apply_mvar( face ); } } } #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ /* initialize standard glyph loading routines */ TT_Init_Glyph_Loading( face ); Exit: return error; Bad_Format: error = FT_THROW( Unknown_File_Format ); goto Exit; }
@@ -1212,10 +1212,14 @@ FT_Size_Metrics* metrics; - size->ttmetrics.valid = FALSE; - face = (TT_Face)size->root.face; + /* nothing to do for CFF2 */ + if ( face->isCFF2 ) + return FT_Err_Ok; + + size->ttmetrics.valid = FALSE; + metrics = &size->metrics; /* copy the result from base layer */
CWE-787
null
null
5,964
tt_get_sfnt_checksum( TT_Face face, FT_UShort i ) { #if 0 /* if we believe the written value, use following part. */ if ( face->dir_tables[i].CheckSum ) return face->dir_tables[i].CheckSum; #endif if ( !face->goto_table ) return 0; if ( face->goto_table( face, face->dir_tables[i].Tag, face->root.stream, NULL ) ) return 0; return (FT_ULong)tt_synth_sfnt_checksum( face->root.stream, face->dir_tables[i].Length ); }
Overflow
0
tt_get_sfnt_checksum( TT_Face face, FT_UShort i ) { #if 0 /* if we believe the written value, use following part. */ if ( face->dir_tables[i].CheckSum ) return face->dir_tables[i].CheckSum; #endif if ( !face->goto_table ) return 0; if ( face->goto_table( face, face->dir_tables[i].Tag, face->root.stream, NULL ) ) return 0; return (FT_ULong)tt_synth_sfnt_checksum( face->root.stream, face->dir_tables[i].Length ); }
@@ -1212,10 +1212,14 @@ FT_Size_Metrics* metrics; - size->ttmetrics.valid = FALSE; - face = (TT_Face)size->root.face; + /* nothing to do for CFF2 */ + if ( face->isCFF2 ) + return FT_Err_Ok; + + size->ttmetrics.valid = FALSE; + metrics = &size->metrics; /* copy the result from base layer */
CWE-787
null
null
5,965
tt_glyphzone_done( TT_GlyphZone zone ) { FT_Memory memory = zone->memory; if ( memory ) { FT_FREE( zone->contours ); FT_FREE( zone->tags ); FT_FREE( zone->cur ); FT_FREE( zone->org ); FT_FREE( zone->orus ); zone->max_points = zone->n_points = 0; zone->max_contours = zone->n_contours = 0; zone->memory = NULL; } }
Overflow
0
tt_glyphzone_done( TT_GlyphZone zone ) { FT_Memory memory = zone->memory; if ( memory ) { FT_FREE( zone->contours ); FT_FREE( zone->tags ); FT_FREE( zone->cur ); FT_FREE( zone->org ); FT_FREE( zone->orus ); zone->max_points = zone->n_points = 0; zone->max_contours = zone->n_contours = 0; zone->memory = NULL; } }
@@ -1212,10 +1212,14 @@ FT_Size_Metrics* metrics; - size->ttmetrics.valid = FALSE; - face = (TT_Face)size->root.face; + /* nothing to do for CFF2 */ + if ( face->isCFF2 ) + return FT_Err_Ok; + + size->ttmetrics.valid = FALSE; + metrics = &size->metrics; /* copy the result from base layer */
CWE-787
null
null
5,966
tt_size_done( FT_Size ttsize ) /* TT_Size */ { TT_Size size = (TT_Size)ttsize; #ifdef TT_USE_BYTECODE_INTERPRETER tt_size_done_bytecode( ttsize ); #endif size->ttmetrics.valid = FALSE; }
Overflow
0
tt_size_done( FT_Size ttsize ) /* TT_Size */ { TT_Size size = (TT_Size)ttsize; #ifdef TT_USE_BYTECODE_INTERPRETER tt_size_done_bytecode( ttsize ); #endif size->ttmetrics.valid = FALSE; }
@@ -1212,10 +1212,14 @@ FT_Size_Metrics* metrics; - size->ttmetrics.valid = FALSE; - face = (TT_Face)size->root.face; + /* nothing to do for CFF2 */ + if ( face->isCFF2 ) + return FT_Err_Ok; + + size->ttmetrics.valid = FALSE; + metrics = &size->metrics; /* copy the result from base layer */
CWE-787
null
null
5,967
tt_size_init( FT_Size ttsize ) /* TT_Size */ { TT_Size size = (TT_Size)ttsize; FT_Error error = FT_Err_Ok; #ifdef TT_USE_BYTECODE_INTERPRETER size->bytecode_ready = -1; size->cvt_ready = -1; #endif size->ttmetrics.valid = FALSE; size->strike_index = 0xFFFFFFFFUL; return error; }
Overflow
0
tt_size_init( FT_Size ttsize ) /* TT_Size */ { TT_Size size = (TT_Size)ttsize; FT_Error error = FT_Err_Ok; #ifdef TT_USE_BYTECODE_INTERPRETER size->bytecode_ready = -1; size->cvt_ready = -1; #endif size->ttmetrics.valid = FALSE; size->strike_index = 0xFFFFFFFFUL; return error; }
@@ -1212,10 +1212,14 @@ FT_Size_Metrics* metrics; - size->ttmetrics.valid = FALSE; - face = (TT_Face)size->root.face; + /* nothing to do for CFF2 */ + if ( face->isCFF2 ) + return FT_Err_Ok; + + size->ttmetrics.valid = FALSE; + metrics = &size->metrics; /* copy the result from base layer */
CWE-787
null
null
5,968
tt_size_init_bytecode( FT_Size ftsize, FT_Bool pedantic ) { FT_Error error; TT_Size size = (TT_Size)ftsize; TT_Face face = (TT_Face)ftsize->face; FT_Memory memory = face->root.memory; FT_UShort n_twilight; TT_MaxProfile* maxp = &face->max_profile; /* clean up bytecode related data */ FT_FREE( size->function_defs ); FT_FREE( size->instruction_defs ); FT_FREE( size->cvt ); FT_FREE( size->storage ); if ( size->context ) TT_Done_Context( size->context ); tt_glyphzone_done( &size->twilight ); size->bytecode_ready = -1; size->cvt_ready = -1; size->context = TT_New_Context( (TT_Driver)face->root.driver ); size->max_function_defs = maxp->maxFunctionDefs; size->max_instruction_defs = maxp->maxInstructionDefs; size->num_function_defs = 0; size->num_instruction_defs = 0; size->max_func = 0; size->max_ins = 0; size->cvt_size = face->cvt_size; size->storage_size = maxp->maxStorage; /* Set default metrics */ { TT_Size_Metrics* metrics = &size->ttmetrics; metrics->rotated = FALSE; metrics->stretched = FALSE; /* set default engine compensation */ metrics->compensations[0] = 0; /* gray */ metrics->compensations[1] = 0; /* black */ metrics->compensations[2] = 0; /* white */ metrics->compensations[3] = 0; /* reserved */ } /* allocate function defs, instruction defs, cvt, and storage area */ if ( FT_NEW_ARRAY( size->function_defs, size->max_function_defs ) || FT_NEW_ARRAY( size->instruction_defs, size->max_instruction_defs ) || FT_NEW_ARRAY( size->cvt, size->cvt_size ) || FT_NEW_ARRAY( size->storage, size->storage_size ) ) goto Exit; /* reserve twilight zone */ n_twilight = maxp->maxTwilightPoints; /* there are 4 phantom points (do we need this?) */ n_twilight += 4; error = tt_glyphzone_new( memory, n_twilight, 0, &size->twilight ); if ( error ) goto Exit; size->twilight.n_points = n_twilight; size->GS = tt_default_graphics_state; /* set `face->interpreter' according to the debug hook present */ { FT_Library library = face->root.driver->root.library; face->interpreter = (TT_Interpreter) library->debug_hooks[FT_DEBUG_HOOK_TRUETYPE]; if ( !face->interpreter ) face->interpreter = (TT_Interpreter)TT_RunIns; } /* Fine, now run the font program! */ /* In case of an error while executing `fpgm', we intentionally don't */ /* clean up immediately – bugs in the `fpgm' are so fundamental that */ /* all following hinting calls should fail. Additionally, `fpgm' is */ /* to be executed just once; calling it again is completely useless */ /* and might even lead to extremely slow behaviour if it is malformed */ /* (containing an infinite loop, for example). */ error = tt_size_run_fpgm( size, pedantic ); return error; Exit: if ( error ) tt_size_done_bytecode( ftsize ); return error; }
Overflow
0
tt_size_init_bytecode( FT_Size ftsize, FT_Bool pedantic ) { FT_Error error; TT_Size size = (TT_Size)ftsize; TT_Face face = (TT_Face)ftsize->face; FT_Memory memory = face->root.memory; FT_UShort n_twilight; TT_MaxProfile* maxp = &face->max_profile; /* clean up bytecode related data */ FT_FREE( size->function_defs ); FT_FREE( size->instruction_defs ); FT_FREE( size->cvt ); FT_FREE( size->storage ); if ( size->context ) TT_Done_Context( size->context ); tt_glyphzone_done( &size->twilight ); size->bytecode_ready = -1; size->cvt_ready = -1; size->context = TT_New_Context( (TT_Driver)face->root.driver ); size->max_function_defs = maxp->maxFunctionDefs; size->max_instruction_defs = maxp->maxInstructionDefs; size->num_function_defs = 0; size->num_instruction_defs = 0; size->max_func = 0; size->max_ins = 0; size->cvt_size = face->cvt_size; size->storage_size = maxp->maxStorage; /* Set default metrics */ { TT_Size_Metrics* metrics = &size->ttmetrics; metrics->rotated = FALSE; metrics->stretched = FALSE; /* set default engine compensation */ metrics->compensations[0] = 0; /* gray */ metrics->compensations[1] = 0; /* black */ metrics->compensations[2] = 0; /* white */ metrics->compensations[3] = 0; /* reserved */ } /* allocate function defs, instruction defs, cvt, and storage area */ if ( FT_NEW_ARRAY( size->function_defs, size->max_function_defs ) || FT_NEW_ARRAY( size->instruction_defs, size->max_instruction_defs ) || FT_NEW_ARRAY( size->cvt, size->cvt_size ) || FT_NEW_ARRAY( size->storage, size->storage_size ) ) goto Exit; /* reserve twilight zone */ n_twilight = maxp->maxTwilightPoints; /* there are 4 phantom points (do we need this?) */ n_twilight += 4; error = tt_glyphzone_new( memory, n_twilight, 0, &size->twilight ); if ( error ) goto Exit; size->twilight.n_points = n_twilight; size->GS = tt_default_graphics_state; /* set `face->interpreter' according to the debug hook present */ { FT_Library library = face->root.driver->root.library; face->interpreter = (TT_Interpreter) library->debug_hooks[FT_DEBUG_HOOK_TRUETYPE]; if ( !face->interpreter ) face->interpreter = (TT_Interpreter)TT_RunIns; } /* Fine, now run the font program! */ /* In case of an error while executing `fpgm', we intentionally don't */ /* clean up immediately – bugs in the `fpgm' are so fundamental that */ /* all following hinting calls should fail. Additionally, `fpgm' is */ /* to be executed just once; calling it again is completely useless */ /* and might even lead to extremely slow behaviour if it is malformed */ /* (containing an infinite loop, for example). */ error = tt_size_run_fpgm( size, pedantic ); return error; Exit: if ( error ) tt_size_done_bytecode( ftsize ); return error; }
@@ -1212,10 +1212,14 @@ FT_Size_Metrics* metrics; - size->ttmetrics.valid = FALSE; - face = (TT_Face)size->root.face; + /* nothing to do for CFF2 */ + if ( face->isCFF2 ) + return FT_Err_Ok; + + size->ttmetrics.valid = FALSE; + metrics = &size->metrics; /* copy the result from base layer */
CWE-787
null
null
5,969
tt_size_ready_bytecode( TT_Size size, FT_Bool pedantic ) { FT_Error error = FT_Err_Ok; if ( size->bytecode_ready < 0 ) error = tt_size_init_bytecode( (FT_Size)size, pedantic ); else error = size->bytecode_ready; if ( error ) goto Exit; /* rescale CVT when needed */ if ( size->cvt_ready < 0 ) { FT_UInt i; TT_Face face = (TT_Face)size->root.face; /* Scale the cvt values to the new ppem. */ /* We use by default the y ppem to scale the CVT. */ for ( i = 0; i < size->cvt_size; i++ ) size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale ); /* all twilight points are originally zero */ for ( i = 0; i < (FT_UInt)size->twilight.n_points; i++ ) { size->twilight.org[i].x = 0; size->twilight.org[i].y = 0; size->twilight.cur[i].x = 0; size->twilight.cur[i].y = 0; } /* clear storage area */ for ( i = 0; i < (FT_UInt)size->storage_size; i++ ) size->storage[i] = 0; size->GS = tt_default_graphics_state; error = tt_size_run_prep( size, pedantic ); } else error = size->cvt_ready; Exit: return error; }
Overflow
0
tt_size_ready_bytecode( TT_Size size, FT_Bool pedantic ) { FT_Error error = FT_Err_Ok; if ( size->bytecode_ready < 0 ) error = tt_size_init_bytecode( (FT_Size)size, pedantic ); else error = size->bytecode_ready; if ( error ) goto Exit; /* rescale CVT when needed */ if ( size->cvt_ready < 0 ) { FT_UInt i; TT_Face face = (TT_Face)size->root.face; /* Scale the cvt values to the new ppem. */ /* We use by default the y ppem to scale the CVT. */ for ( i = 0; i < size->cvt_size; i++ ) size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale ); /* all twilight points are originally zero */ for ( i = 0; i < (FT_UInt)size->twilight.n_points; i++ ) { size->twilight.org[i].x = 0; size->twilight.org[i].y = 0; size->twilight.cur[i].x = 0; size->twilight.cur[i].y = 0; } /* clear storage area */ for ( i = 0; i < (FT_UInt)size->storage_size; i++ ) size->storage[i] = 0; size->GS = tt_default_graphics_state; error = tt_size_run_prep( size, pedantic ); } else error = size->cvt_ready; Exit: return error; }
@@ -1212,10 +1212,14 @@ FT_Size_Metrics* metrics; - size->ttmetrics.valid = FALSE; - face = (TT_Face)size->root.face; + /* nothing to do for CFF2 */ + if ( face->isCFF2 ) + return FT_Err_Ok; + + size->ttmetrics.valid = FALSE; + metrics = &size->metrics; /* copy the result from base layer */
CWE-787
null
null
5,970
tt_size_run_fpgm( TT_Size size, FT_Bool pedantic ) { TT_Face face = (TT_Face)size->root.face; TT_ExecContext exec; FT_Error error; exec = size->context; error = TT_Load_Context( exec, face, size ); if ( error ) return error; exec->callTop = 0; exec->top = 0; exec->period = 64; exec->phase = 0; exec->threshold = 0; exec->instruction_trap = FALSE; exec->F_dot_P = 0x4000L; exec->pedantic_hinting = pedantic; { FT_Size_Metrics* metrics = &exec->metrics; TT_Size_Metrics* tt_metrics = &exec->tt_metrics; metrics->x_ppem = 0; metrics->y_ppem = 0; metrics->x_scale = 0; metrics->y_scale = 0; tt_metrics->ppem = 0; tt_metrics->scale = 0; tt_metrics->ratio = 0x10000L; } /* allow font program execution */ TT_Set_CodeRange( exec, tt_coderange_font, face->font_program, (FT_Long)face->font_program_size ); /* disable CVT and glyph programs coderange */ TT_Clear_CodeRange( exec, tt_coderange_cvt ); TT_Clear_CodeRange( exec, tt_coderange_glyph ); if ( face->font_program_size > 0 ) { TT_Goto_CodeRange( exec, tt_coderange_font, 0 ); FT_TRACE4(( "Executing `fpgm' table.\n" )); error = face->interpreter( exec ); #ifdef FT_DEBUG_LEVEL_TRACE if ( error ) FT_TRACE4(( " interpretation failed with error code 0x%x\n", error )); #endif } else error = FT_Err_Ok; size->bytecode_ready = error; if ( !error ) TT_Save_Context( exec, size ); return error; }
Overflow
0
tt_size_run_fpgm( TT_Size size, FT_Bool pedantic ) { TT_Face face = (TT_Face)size->root.face; TT_ExecContext exec; FT_Error error; exec = size->context; error = TT_Load_Context( exec, face, size ); if ( error ) return error; exec->callTop = 0; exec->top = 0; exec->period = 64; exec->phase = 0; exec->threshold = 0; exec->instruction_trap = FALSE; exec->F_dot_P = 0x4000L; exec->pedantic_hinting = pedantic; { FT_Size_Metrics* metrics = &exec->metrics; TT_Size_Metrics* tt_metrics = &exec->tt_metrics; metrics->x_ppem = 0; metrics->y_ppem = 0; metrics->x_scale = 0; metrics->y_scale = 0; tt_metrics->ppem = 0; tt_metrics->scale = 0; tt_metrics->ratio = 0x10000L; } /* allow font program execution */ TT_Set_CodeRange( exec, tt_coderange_font, face->font_program, (FT_Long)face->font_program_size ); /* disable CVT and glyph programs coderange */ TT_Clear_CodeRange( exec, tt_coderange_cvt ); TT_Clear_CodeRange( exec, tt_coderange_glyph ); if ( face->font_program_size > 0 ) { TT_Goto_CodeRange( exec, tt_coderange_font, 0 ); FT_TRACE4(( "Executing `fpgm' table.\n" )); error = face->interpreter( exec ); #ifdef FT_DEBUG_LEVEL_TRACE if ( error ) FT_TRACE4(( " interpretation failed with error code 0x%x\n", error )); #endif } else error = FT_Err_Ok; size->bytecode_ready = error; if ( !error ) TT_Save_Context( exec, size ); return error; }
@@ -1212,10 +1212,14 @@ FT_Size_Metrics* metrics; - size->ttmetrics.valid = FALSE; - face = (TT_Face)size->root.face; + /* nothing to do for CFF2 */ + if ( face->isCFF2 ) + return FT_Err_Ok; + + size->ttmetrics.valid = FALSE; + metrics = &size->metrics; /* copy the result from base layer */
CWE-787
null
null
5,971
tt_size_run_prep( TT_Size size, FT_Bool pedantic ) { TT_Face face = (TT_Face)size->root.face; TT_ExecContext exec; FT_Error error; exec = size->context; error = TT_Load_Context( exec, face, size ); if ( error ) return error; exec->callTop = 0; exec->top = 0; exec->instruction_trap = FALSE; exec->pedantic_hinting = pedantic; TT_Set_CodeRange( exec, tt_coderange_cvt, face->cvt_program, (FT_Long)face->cvt_program_size ); TT_Clear_CodeRange( exec, tt_coderange_glyph ); if ( face->cvt_program_size > 0 ) { TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 ); FT_TRACE4(( "Executing `prep' table.\n" )); error = face->interpreter( exec ); #ifdef FT_DEBUG_LEVEL_TRACE if ( error ) FT_TRACE4(( " interpretation failed with error code 0x%x\n", error )); #endif } else error = FT_Err_Ok; size->cvt_ready = error; /* UNDOCUMENTED! The MS rasterizer doesn't allow the following */ /* graphics state variables to be modified by the CVT program. */ exec->GS.dualVector.x = 0x4000; exec->GS.dualVector.y = 0; exec->GS.projVector.x = 0x4000; exec->GS.projVector.y = 0x0; exec->GS.freeVector.x = 0x4000; exec->GS.freeVector.y = 0x0; exec->GS.rp0 = 0; exec->GS.rp1 = 0; exec->GS.rp2 = 0; exec->GS.gep0 = 1; exec->GS.gep1 = 1; exec->GS.gep2 = 1; exec->GS.loop = 1; /* save as default graphics state */ size->GS = exec->GS; TT_Save_Context( exec, size ); return error; }
Overflow
0
tt_size_run_prep( TT_Size size, FT_Bool pedantic ) { TT_Face face = (TT_Face)size->root.face; TT_ExecContext exec; FT_Error error; exec = size->context; error = TT_Load_Context( exec, face, size ); if ( error ) return error; exec->callTop = 0; exec->top = 0; exec->instruction_trap = FALSE; exec->pedantic_hinting = pedantic; TT_Set_CodeRange( exec, tt_coderange_cvt, face->cvt_program, (FT_Long)face->cvt_program_size ); TT_Clear_CodeRange( exec, tt_coderange_glyph ); if ( face->cvt_program_size > 0 ) { TT_Goto_CodeRange( exec, tt_coderange_cvt, 0 ); FT_TRACE4(( "Executing `prep' table.\n" )); error = face->interpreter( exec ); #ifdef FT_DEBUG_LEVEL_TRACE if ( error ) FT_TRACE4(( " interpretation failed with error code 0x%x\n", error )); #endif } else error = FT_Err_Ok; size->cvt_ready = error; /* UNDOCUMENTED! The MS rasterizer doesn't allow the following */ /* graphics state variables to be modified by the CVT program. */ exec->GS.dualVector.x = 0x4000; exec->GS.dualVector.y = 0; exec->GS.projVector.x = 0x4000; exec->GS.projVector.y = 0x0; exec->GS.freeVector.x = 0x4000; exec->GS.freeVector.y = 0x0; exec->GS.rp0 = 0; exec->GS.rp1 = 0; exec->GS.rp2 = 0; exec->GS.gep0 = 1; exec->GS.gep1 = 1; exec->GS.gep2 = 1; exec->GS.loop = 1; /* save as default graphics state */ size->GS = exec->GS; TT_Save_Context( exec, size ); return error; }
@@ -1212,10 +1212,14 @@ FT_Size_Metrics* metrics; - size->ttmetrics.valid = FALSE; - face = (TT_Face)size->root.face; + /* nothing to do for CFF2 */ + if ( face->isCFF2 ) + return FT_Err_Ok; + + size->ttmetrics.valid = FALSE; + metrics = &size->metrics; /* copy the result from base layer */
CWE-787
null
null
5,972
tt_slot_init( FT_GlyphSlot slot ) { return FT_GlyphLoader_CreateExtra( slot->internal->loader ); }
Overflow
0
tt_slot_init( FT_GlyphSlot slot ) { return FT_GlyphLoader_CreateExtra( slot->internal->loader ); }
@@ -1212,10 +1212,14 @@ FT_Size_Metrics* metrics; - size->ttmetrics.valid = FALSE; - face = (TT_Face)size->root.face; + /* nothing to do for CFF2 */ + if ( face->isCFF2 ) + return FT_Err_Ok; + + size->ttmetrics.valid = FALSE; + metrics = &size->metrics; /* copy the result from base layer */
CWE-787
null
null
5,973
tt_synth_sfnt_checksum( FT_Stream stream, FT_ULong length ) { FT_Error error; FT_UInt32 checksum = 0; FT_UInt i; if ( FT_FRAME_ENTER( length ) ) return 0; for ( ; length > 3; length -= 4 ) checksum += (FT_UInt32)FT_GET_ULONG(); for ( i = 3; length > 0; length--, i-- ) checksum += (FT_UInt32)FT_GET_BYTE() << ( i * 8 ); FT_FRAME_EXIT(); return checksum; }
Overflow
0
tt_synth_sfnt_checksum( FT_Stream stream, FT_ULong length ) { FT_Error error; FT_UInt32 checksum = 0; FT_UInt i; if ( FT_FRAME_ENTER( length ) ) return 0; for ( ; length > 3; length -= 4 ) checksum += (FT_UInt32)FT_GET_ULONG(); for ( i = 3; length > 0; length--, i-- ) checksum += (FT_UInt32)FT_GET_BYTE() << ( i * 8 ); FT_FRAME_EXIT(); return checksum; }
@@ -1212,10 +1212,14 @@ FT_Size_Metrics* metrics; - size->ttmetrics.valid = FALSE; - face = (TT_Face)size->root.face; + /* nothing to do for CFF2 */ + if ( face->isCFF2 ) + return FT_Err_Ok; + + size->ttmetrics.valid = FALSE; + metrics = &size->metrics; /* copy the result from base layer */
CWE-787
null
null
5,974
sfnt_stream_close( FT_Stream stream ) { FT_Memory memory = stream->memory; FT_FREE( stream->base ); stream->size = 0; stream->base = NULL; stream->close = NULL; }
null
0
sfnt_stream_close( FT_Stream stream ) { FT_Memory memory = stream->memory; FT_FREE( stream->base ); stream->size = 0; stream->base = NULL; stream->close = NULL; }
@@ -999,10 +999,6 @@ else face->variation_support |= TT_FACE_FLAG_VAR_FVAR; - /* we don't support Multiple Master CFFs yet */ - if ( !face->goto_table( face, TTAG_CFF, stream, 0 ) ) - num_instances = 0; - /* * As documented in the OpenType specification, an entry for the * default instance may be omitted in the named instance table. In @@ -1062,6 +1058,11 @@ FT_FREE( default_values ); FT_FREE( instance_values ); + /* we don't support Multiple Master CFFs yet */ + if ( face->goto_table( face, TTAG_glyf, stream, 0 ) && + !face->goto_table( face, TTAG_CFF, stream, 0 ) ) + num_instances = 0; + /* instance indices in `face_instance_index' start with index 1, */ /* thus `>' and not `>=' */ if ( instance_index > num_instances )
CWE-787
null
null
5,975
tt_name_ascii_from_other( TT_Name entry, FT_Memory memory ) { FT_String* string = NULL; FT_UInt len, code, n; FT_Byte* read = (FT_Byte*)entry->string; FT_Error error; len = (FT_UInt)entry->stringLength; if ( FT_NEW_ARRAY( string, len + 1 ) ) return NULL; for ( n = 0; n < len; n++ ) { code = *read++; if ( code == 0 ) break; if ( code < 32 || code > 127 ) code = '?'; string[n] = (char)code; } string[n] = 0; return string; }
null
0
tt_name_ascii_from_other( TT_Name entry, FT_Memory memory ) { FT_String* string = NULL; FT_UInt len, code, n; FT_Byte* read = (FT_Byte*)entry->string; FT_Error error; len = (FT_UInt)entry->stringLength; if ( FT_NEW_ARRAY( string, len + 1 ) ) return NULL; for ( n = 0; n < len; n++ ) { code = *read++; if ( code == 0 ) break; if ( code < 32 || code > 127 ) code = '?'; string[n] = (char)code; } string[n] = 0; return string; }
@@ -999,10 +999,6 @@ else face->variation_support |= TT_FACE_FLAG_VAR_FVAR; - /* we don't support Multiple Master CFFs yet */ - if ( !face->goto_table( face, TTAG_CFF, stream, 0 ) ) - num_instances = 0; - /* * As documented in the OpenType specification, an entry for the * default instance may be omitted in the named instance table. In @@ -1062,6 +1058,11 @@ FT_FREE( default_values ); FT_FREE( instance_values ); + /* we don't support Multiple Master CFFs yet */ + if ( face->goto_table( face, TTAG_glyf, stream, 0 ) && + !face->goto_table( face, TTAG_CFF, stream, 0 ) ) + num_instances = 0; + /* instance indices in `face_instance_index' start with index 1, */ /* thus `>' and not `>=' */ if ( instance_index > num_instances )
CWE-787
null
null
5,976
tt_name_ascii_from_utf16( TT_Name entry, FT_Memory memory ) { FT_String* string = NULL; FT_UInt len, code, n; FT_Byte* read = (FT_Byte*)entry->string; FT_Error error; len = (FT_UInt)entry->stringLength / 2; if ( FT_NEW_ARRAY( string, len + 1 ) ) return NULL; for ( n = 0; n < len; n++ ) { code = FT_NEXT_USHORT( read ); if ( code == 0 ) break; if ( code < 32 || code > 127 ) code = '?'; string[n] = (char)code; } string[n] = 0; return string; }
null
0
tt_name_ascii_from_utf16( TT_Name entry, FT_Memory memory ) { FT_String* string = NULL; FT_UInt len, code, n; FT_Byte* read = (FT_Byte*)entry->string; FT_Error error; len = (FT_UInt)entry->stringLength / 2; if ( FT_NEW_ARRAY( string, len + 1 ) ) return NULL; for ( n = 0; n < len; n++ ) { code = FT_NEXT_USHORT( read ); if ( code == 0 ) break; if ( code < 32 || code > 127 ) code = '?'; string[n] = (char)code; } string[n] = 0; return string; }
@@ -999,10 +999,6 @@ else face->variation_support |= TT_FACE_FLAG_VAR_FVAR; - /* we don't support Multiple Master CFFs yet */ - if ( !face->goto_table( face, TTAG_CFF, stream, 0 ) ) - num_instances = 0; - /* * As documented in the OpenType specification, an entry for the * default instance may be omitted in the named instance table. In @@ -1062,6 +1058,11 @@ FT_FREE( default_values ); FT_FREE( instance_values ); + /* we don't support Multiple Master CFFs yet */ + if ( face->goto_table( face, TTAG_glyf, stream, 0 ) && + !face->goto_table( face, TTAG_CFF, stream, 0 ) ) + num_instances = 0; + /* instance indices in `face_instance_index' start with index 1, */ /* thus `>' and not `>=' */ if ( instance_index > num_instances )
CWE-787
null
null
5,977
woff_open_font( FT_Stream stream, TT_Face face ) { FT_Memory memory = stream->memory; FT_Error error = FT_Err_Ok; WOFF_HeaderRec woff; WOFF_Table tables = NULL; WOFF_Table* indices = NULL; FT_ULong woff_offset; FT_Byte* sfnt = NULL; FT_Stream sfnt_stream = NULL; FT_Byte* sfnt_header; FT_ULong sfnt_offset; FT_Int nn; FT_ULong old_tag = 0; static const FT_Frame_Field woff_header_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE WOFF_HeaderRec FT_FRAME_START( 44 ), FT_FRAME_ULONG ( signature ), FT_FRAME_ULONG ( flavor ), FT_FRAME_ULONG ( length ), FT_FRAME_USHORT( num_tables ), FT_FRAME_USHORT( reserved ), FT_FRAME_ULONG ( totalSfntSize ), FT_FRAME_USHORT( majorVersion ), FT_FRAME_USHORT( minorVersion ), FT_FRAME_ULONG ( metaOffset ), FT_FRAME_ULONG ( metaLength ), FT_FRAME_ULONG ( metaOrigLength ), FT_FRAME_ULONG ( privOffset ), FT_FRAME_ULONG ( privLength ), FT_FRAME_END }; FT_ASSERT( stream == face->root.stream ); FT_ASSERT( FT_STREAM_POS() == 0 ); if ( FT_STREAM_READ_FIELDS( woff_header_fields, &woff ) ) return error; /* Make sure we don't recurse back here or hit TTC code. */ if ( woff.flavor == TTAG_wOFF || woff.flavor == TTAG_ttcf ) return FT_THROW( Invalid_Table ); /* Miscellaneous checks. */ if ( woff.length != stream->size || woff.num_tables == 0 || 44 + woff.num_tables * 20UL >= woff.length || 12 + woff.num_tables * 16UL >= woff.totalSfntSize || ( woff.totalSfntSize & 3 ) != 0 || ( woff.metaOffset == 0 && ( woff.metaLength != 0 || woff.metaOrigLength != 0 ) ) || ( woff.metaLength != 0 && woff.metaOrigLength == 0 ) || ( woff.privOffset == 0 && woff.privLength != 0 ) ) { FT_ERROR(( "woff_font_open: invalid WOFF header\n" )); return FT_THROW( Invalid_Table ); } /* Don't trust `totalSfntSize' before thorough checks. */ if ( FT_ALLOC( sfnt, 12 + woff.num_tables * 16UL ) || FT_NEW( sfnt_stream ) ) goto Exit; sfnt_header = sfnt; /* Write sfnt header. */ { FT_UInt searchRange, entrySelector, rangeShift, x; x = woff.num_tables; entrySelector = 0; while ( x ) { x >>= 1; entrySelector += 1; } entrySelector--; searchRange = ( 1 << entrySelector ) * 16; rangeShift = woff.num_tables * 16 - searchRange; WRITE_ULONG ( sfnt_header, woff.flavor ); WRITE_USHORT( sfnt_header, woff.num_tables ); WRITE_USHORT( sfnt_header, searchRange ); WRITE_USHORT( sfnt_header, entrySelector ); WRITE_USHORT( sfnt_header, rangeShift ); } /* While the entries in the sfnt header must be sorted by the */ /* tag value, the tables themselves are not. We thus have to */ /* sort them by offset and check that they don't overlap. */ if ( FT_NEW_ARRAY( tables, woff.num_tables ) || FT_NEW_ARRAY( indices, woff.num_tables ) ) goto Exit; FT_TRACE2(( "\n" " tag offset compLen origLen checksum\n" " -------------------------------------------\n" )); if ( FT_FRAME_ENTER( 20L * woff.num_tables ) ) goto Exit; for ( nn = 0; nn < woff.num_tables; nn++ ) { WOFF_Table table = tables + nn; table->Tag = FT_GET_TAG4(); table->Offset = FT_GET_ULONG(); table->CompLength = FT_GET_ULONG(); table->OrigLength = FT_GET_ULONG(); table->CheckSum = FT_GET_ULONG(); FT_TRACE2(( " %c%c%c%c %08lx %08lx %08lx %08lx\n", (FT_Char)( table->Tag >> 24 ), (FT_Char)( table->Tag >> 16 ), (FT_Char)( table->Tag >> 8 ), (FT_Char)( table->Tag ), table->Offset, table->CompLength, table->OrigLength, table->CheckSum )); if ( table->Tag <= old_tag ) { FT_FRAME_EXIT(); FT_ERROR(( "woff_font_open: table tags are not sorted\n" )); error = FT_THROW( Invalid_Table ); goto Exit; } old_tag = table->Tag; indices[nn] = table; } FT_FRAME_EXIT(); /* Sort by offset. */ ft_qsort( indices, woff.num_tables, sizeof ( WOFF_Table ), compare_offsets ); /* Check offsets and lengths. */ woff_offset = 44 + woff.num_tables * 20L; sfnt_offset = 12 + woff.num_tables * 16L; for ( nn = 0; nn < woff.num_tables; nn++ ) { WOFF_Table table = indices[nn]; if ( table->Offset != woff_offset || table->CompLength > woff.length || table->Offset > woff.length - table->CompLength || table->OrigLength > woff.totalSfntSize || sfnt_offset > woff.totalSfntSize - table->OrigLength || table->CompLength > table->OrigLength ) { FT_ERROR(( "woff_font_open: invalid table offsets\n" )); error = FT_THROW( Invalid_Table ); goto Exit; } table->OrigOffset = sfnt_offset; /* The offsets must be multiples of 4. */ woff_offset += ( table->CompLength + 3 ) & ~3U; sfnt_offset += ( table->OrigLength + 3 ) & ~3U; } /* * Final checks! * * We don't decode and check the metadata block. * We don't check table checksums either. * But other than those, I think we implement all * `MUST' checks from the spec. */ if ( woff.metaOffset ) { if ( woff.metaOffset != woff_offset || woff.metaOffset + woff.metaLength > woff.length ) { FT_ERROR(( "woff_font_open:" " invalid `metadata' offset or length\n" )); error = FT_THROW( Invalid_Table ); goto Exit; } /* We have padding only ... */ woff_offset += woff.metaLength; } if ( woff.privOffset ) { /* ... if it isn't the last block. */ woff_offset = ( woff_offset + 3 ) & ~3U; if ( woff.privOffset != woff_offset || woff.privOffset + woff.privLength > woff.length ) { FT_ERROR(( "woff_font_open: invalid `private' offset or length\n" )); error = FT_THROW( Invalid_Table ); goto Exit; } /* No padding for the last block. */ woff_offset += woff.privLength; } if ( sfnt_offset != woff.totalSfntSize || woff_offset != woff.length ) { FT_ERROR(( "woff_font_open: invalid `sfnt' table structure\n" )); error = FT_THROW( Invalid_Table ); goto Exit; } /* Now use `totalSfntSize'. */ if ( FT_REALLOC( sfnt, 12 + woff.num_tables * 16UL, woff.totalSfntSize ) ) goto Exit; sfnt_header = sfnt + 12; /* Write the tables. */ for ( nn = 0; nn < woff.num_tables; nn++ ) { WOFF_Table table = tables + nn; /* Write SFNT table entry. */ WRITE_ULONG( sfnt_header, table->Tag ); WRITE_ULONG( sfnt_header, table->CheckSum ); WRITE_ULONG( sfnt_header, table->OrigOffset ); WRITE_ULONG( sfnt_header, table->OrigLength ); /* Write table data. */ if ( FT_STREAM_SEEK( table->Offset ) || FT_FRAME_ENTER( table->CompLength ) ) goto Exit; if ( table->CompLength == table->OrigLength ) { /* Uncompressed data; just copy. */ ft_memcpy( sfnt + table->OrigOffset, stream->cursor, table->OrigLength ); } else { #ifdef FT_CONFIG_OPTION_USE_ZLIB /* Uncompress with zlib. */ FT_ULong output_len = table->OrigLength; error = FT_Gzip_Uncompress( memory, sfnt + table->OrigOffset, &output_len, stream->cursor, table->CompLength ); if ( error ) goto Exit; if ( output_len != table->OrigLength ) { FT_ERROR(( "woff_font_open: compressed table length mismatch\n" )); error = FT_THROW( Invalid_Table ); goto Exit; } #else /* !FT_CONFIG_OPTION_USE_ZLIB */ error = FT_THROW( Unimplemented_Feature ); goto Exit; #endif /* !FT_CONFIG_OPTION_USE_ZLIB */ } FT_FRAME_EXIT(); /* We don't check whether the padding bytes in the WOFF file are */ /* actually '\0'. For the output, however, we do set them properly. */ sfnt_offset = table->OrigOffset + table->OrigLength; while ( sfnt_offset & 3 ) { sfnt[sfnt_offset] = '\0'; sfnt_offset++; } } /* Ok! Finally ready. Swap out stream and return. */ FT_Stream_OpenMemory( sfnt_stream, sfnt, woff.totalSfntSize ); sfnt_stream->memory = stream->memory; sfnt_stream->close = sfnt_stream_close; FT_Stream_Free( face->root.stream, ( face->root.face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) != 0 ); face->root.stream = sfnt_stream; face->root.face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM; Exit: FT_FREE( tables ); FT_FREE( indices ); if ( error ) { FT_FREE( sfnt ); FT_Stream_Close( sfnt_stream ); FT_FREE( sfnt_stream ); } return error; }
null
0
woff_open_font( FT_Stream stream, TT_Face face ) { FT_Memory memory = stream->memory; FT_Error error = FT_Err_Ok; WOFF_HeaderRec woff; WOFF_Table tables = NULL; WOFF_Table* indices = NULL; FT_ULong woff_offset; FT_Byte* sfnt = NULL; FT_Stream sfnt_stream = NULL; FT_Byte* sfnt_header; FT_ULong sfnt_offset; FT_Int nn; FT_ULong old_tag = 0; static const FT_Frame_Field woff_header_fields[] = { #undef FT_STRUCTURE #define FT_STRUCTURE WOFF_HeaderRec FT_FRAME_START( 44 ), FT_FRAME_ULONG ( signature ), FT_FRAME_ULONG ( flavor ), FT_FRAME_ULONG ( length ), FT_FRAME_USHORT( num_tables ), FT_FRAME_USHORT( reserved ), FT_FRAME_ULONG ( totalSfntSize ), FT_FRAME_USHORT( majorVersion ), FT_FRAME_USHORT( minorVersion ), FT_FRAME_ULONG ( metaOffset ), FT_FRAME_ULONG ( metaLength ), FT_FRAME_ULONG ( metaOrigLength ), FT_FRAME_ULONG ( privOffset ), FT_FRAME_ULONG ( privLength ), FT_FRAME_END }; FT_ASSERT( stream == face->root.stream ); FT_ASSERT( FT_STREAM_POS() == 0 ); if ( FT_STREAM_READ_FIELDS( woff_header_fields, &woff ) ) return error; /* Make sure we don't recurse back here or hit TTC code. */ if ( woff.flavor == TTAG_wOFF || woff.flavor == TTAG_ttcf ) return FT_THROW( Invalid_Table ); /* Miscellaneous checks. */ if ( woff.length != stream->size || woff.num_tables == 0 || 44 + woff.num_tables * 20UL >= woff.length || 12 + woff.num_tables * 16UL >= woff.totalSfntSize || ( woff.totalSfntSize & 3 ) != 0 || ( woff.metaOffset == 0 && ( woff.metaLength != 0 || woff.metaOrigLength != 0 ) ) || ( woff.metaLength != 0 && woff.metaOrigLength == 0 ) || ( woff.privOffset == 0 && woff.privLength != 0 ) ) { FT_ERROR(( "woff_font_open: invalid WOFF header\n" )); return FT_THROW( Invalid_Table ); } /* Don't trust `totalSfntSize' before thorough checks. */ if ( FT_ALLOC( sfnt, 12 + woff.num_tables * 16UL ) || FT_NEW( sfnt_stream ) ) goto Exit; sfnt_header = sfnt; /* Write sfnt header. */ { FT_UInt searchRange, entrySelector, rangeShift, x; x = woff.num_tables; entrySelector = 0; while ( x ) { x >>= 1; entrySelector += 1; } entrySelector--; searchRange = ( 1 << entrySelector ) * 16; rangeShift = woff.num_tables * 16 - searchRange; WRITE_ULONG ( sfnt_header, woff.flavor ); WRITE_USHORT( sfnt_header, woff.num_tables ); WRITE_USHORT( sfnt_header, searchRange ); WRITE_USHORT( sfnt_header, entrySelector ); WRITE_USHORT( sfnt_header, rangeShift ); } /* While the entries in the sfnt header must be sorted by the */ /* tag value, the tables themselves are not. We thus have to */ /* sort them by offset and check that they don't overlap. */ if ( FT_NEW_ARRAY( tables, woff.num_tables ) || FT_NEW_ARRAY( indices, woff.num_tables ) ) goto Exit; FT_TRACE2(( "\n" " tag offset compLen origLen checksum\n" " -------------------------------------------\n" )); if ( FT_FRAME_ENTER( 20L * woff.num_tables ) ) goto Exit; for ( nn = 0; nn < woff.num_tables; nn++ ) { WOFF_Table table = tables + nn; table->Tag = FT_GET_TAG4(); table->Offset = FT_GET_ULONG(); table->CompLength = FT_GET_ULONG(); table->OrigLength = FT_GET_ULONG(); table->CheckSum = FT_GET_ULONG(); FT_TRACE2(( " %c%c%c%c %08lx %08lx %08lx %08lx\n", (FT_Char)( table->Tag >> 24 ), (FT_Char)( table->Tag >> 16 ), (FT_Char)( table->Tag >> 8 ), (FT_Char)( table->Tag ), table->Offset, table->CompLength, table->OrigLength, table->CheckSum )); if ( table->Tag <= old_tag ) { FT_FRAME_EXIT(); FT_ERROR(( "woff_font_open: table tags are not sorted\n" )); error = FT_THROW( Invalid_Table ); goto Exit; } old_tag = table->Tag; indices[nn] = table; } FT_FRAME_EXIT(); /* Sort by offset. */ ft_qsort( indices, woff.num_tables, sizeof ( WOFF_Table ), compare_offsets ); /* Check offsets and lengths. */ woff_offset = 44 + woff.num_tables * 20L; sfnt_offset = 12 + woff.num_tables * 16L; for ( nn = 0; nn < woff.num_tables; nn++ ) { WOFF_Table table = indices[nn]; if ( table->Offset != woff_offset || table->CompLength > woff.length || table->Offset > woff.length - table->CompLength || table->OrigLength > woff.totalSfntSize || sfnt_offset > woff.totalSfntSize - table->OrigLength || table->CompLength > table->OrigLength ) { FT_ERROR(( "woff_font_open: invalid table offsets\n" )); error = FT_THROW( Invalid_Table ); goto Exit; } table->OrigOffset = sfnt_offset; /* The offsets must be multiples of 4. */ woff_offset += ( table->CompLength + 3 ) & ~3U; sfnt_offset += ( table->OrigLength + 3 ) & ~3U; } /* * Final checks! * * We don't decode and check the metadata block. * We don't check table checksums either. * But other than those, I think we implement all * `MUST' checks from the spec. */ if ( woff.metaOffset ) { if ( woff.metaOffset != woff_offset || woff.metaOffset + woff.metaLength > woff.length ) { FT_ERROR(( "woff_font_open:" " invalid `metadata' offset or length\n" )); error = FT_THROW( Invalid_Table ); goto Exit; } /* We have padding only ... */ woff_offset += woff.metaLength; } if ( woff.privOffset ) { /* ... if it isn't the last block. */ woff_offset = ( woff_offset + 3 ) & ~3U; if ( woff.privOffset != woff_offset || woff.privOffset + woff.privLength > woff.length ) { FT_ERROR(( "woff_font_open: invalid `private' offset or length\n" )); error = FT_THROW( Invalid_Table ); goto Exit; } /* No padding for the last block. */ woff_offset += woff.privLength; } if ( sfnt_offset != woff.totalSfntSize || woff_offset != woff.length ) { FT_ERROR(( "woff_font_open: invalid `sfnt' table structure\n" )); error = FT_THROW( Invalid_Table ); goto Exit; } /* Now use `totalSfntSize'. */ if ( FT_REALLOC( sfnt, 12 + woff.num_tables * 16UL, woff.totalSfntSize ) ) goto Exit; sfnt_header = sfnt + 12; /* Write the tables. */ for ( nn = 0; nn < woff.num_tables; nn++ ) { WOFF_Table table = tables + nn; /* Write SFNT table entry. */ WRITE_ULONG( sfnt_header, table->Tag ); WRITE_ULONG( sfnt_header, table->CheckSum ); WRITE_ULONG( sfnt_header, table->OrigOffset ); WRITE_ULONG( sfnt_header, table->OrigLength ); /* Write table data. */ if ( FT_STREAM_SEEK( table->Offset ) || FT_FRAME_ENTER( table->CompLength ) ) goto Exit; if ( table->CompLength == table->OrigLength ) { /* Uncompressed data; just copy. */ ft_memcpy( sfnt + table->OrigOffset, stream->cursor, table->OrigLength ); } else { #ifdef FT_CONFIG_OPTION_USE_ZLIB /* Uncompress with zlib. */ FT_ULong output_len = table->OrigLength; error = FT_Gzip_Uncompress( memory, sfnt + table->OrigOffset, &output_len, stream->cursor, table->CompLength ); if ( error ) goto Exit; if ( output_len != table->OrigLength ) { FT_ERROR(( "woff_font_open: compressed table length mismatch\n" )); error = FT_THROW( Invalid_Table ); goto Exit; } #else /* !FT_CONFIG_OPTION_USE_ZLIB */ error = FT_THROW( Unimplemented_Feature ); goto Exit; #endif /* !FT_CONFIG_OPTION_USE_ZLIB */ } FT_FRAME_EXIT(); /* We don't check whether the padding bytes in the WOFF file are */ /* actually '\0'. For the output, however, we do set them properly. */ sfnt_offset = table->OrigOffset + table->OrigLength; while ( sfnt_offset & 3 ) { sfnt[sfnt_offset] = '\0'; sfnt_offset++; } } /* Ok! Finally ready. Swap out stream and return. */ FT_Stream_OpenMemory( sfnt_stream, sfnt, woff.totalSfntSize ); sfnt_stream->memory = stream->memory; sfnt_stream->close = sfnt_stream_close; FT_Stream_Free( face->root.stream, ( face->root.face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) != 0 ); face->root.stream = sfnt_stream; face->root.face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM; Exit: FT_FREE( tables ); FT_FREE( indices ); if ( error ) { FT_FREE( sfnt ); FT_Stream_Close( sfnt_stream ); FT_FREE( sfnt_stream ); } return error; }
@@ -999,10 +999,6 @@ else face->variation_support |= TT_FACE_FLAG_VAR_FVAR; - /* we don't support Multiple Master CFFs yet */ - if ( !face->goto_table( face, TTAG_CFF, stream, 0 ) ) - num_instances = 0; - /* * As documented in the OpenType specification, an entry for the * default instance may be omitted in the named instance table. In @@ -1062,6 +1058,11 @@ FT_FREE( default_values ); FT_FREE( instance_values ); + /* we don't support Multiple Master CFFs yet */ + if ( face->goto_table( face, TTAG_glyf, stream, 0 ) && + !face->goto_table( face, TTAG_CFF, stream, 0 ) ) + num_instances = 0; + /* instance indices in `face_instance_index' start with index 1, */ /* thus `>' and not `>=' */ if ( instance_index > num_instances )
CWE-787
null
null
5,978
sfnt_load_face( FT_Stream stream, TT_Face face, FT_Int face_instance_index, FT_Int num_params, FT_Parameter* params ) { FT_Error error; #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES FT_Error psnames_error; #endif FT_Bool has_outline; FT_Bool is_apple_sbit; FT_Bool is_apple_sbix; FT_Bool ignore_typographic_family = FALSE; FT_Bool ignore_typographic_subfamily = FALSE; SFNT_Service sfnt = (SFNT_Service)face->sfnt; FT_UNUSED( face_instance_index ); /* Check parameters */ { FT_Int i; for ( i = 0; i < num_params; i++ ) { if ( params[i].tag == FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY ) ignore_typographic_family = TRUE; else if ( params[i].tag == FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY ) ignore_typographic_subfamily = TRUE; } } /* Load tables */ /* We now support two SFNT-based bitmapped font formats. They */ /* are recognized easily as they do not include a `glyf' */ /* table. */ /* */ /* The first format comes from Apple, and uses a table named */ /* `bhed' instead of `head' to store the font header (using */ /* the same format). It also doesn't include horizontal and */ /* vertical metrics tables (i.e. `hhea' and `vhea' tables are */ /* missing). */ /* */ /* The other format comes from Microsoft, and is used with */ /* WinCE/PocketPC. It looks like a standard TTF, except that */ /* it doesn't contain outlines. */ /* */ FT_TRACE2(( "sfnt_load_face: %08p\n\n", face )); /* do we have outlines in there? */ #ifdef FT_CONFIG_OPTION_INCREMENTAL has_outline = FT_BOOL( face->root.internal->incremental_interface || tt_face_lookup_table( face, TTAG_glyf ) || tt_face_lookup_table( face, TTAG_CFF ) || tt_face_lookup_table( face, TTAG_CFF2 ) ); #else has_outline = FT_BOOL( tt_face_lookup_table( face, TTAG_glyf ) || tt_face_lookup_table( face, TTAG_CFF ) || tt_face_lookup_table( face, TTAG_CFF2 ) ); #endif is_apple_sbit = 0; is_apple_sbix = !face->goto_table( face, TTAG_sbix, stream, 0 ); /* Apple 'sbix' color bitmaps are rendered scaled and then the 'glyf' * outline rendered on top. We don't support that yet, so just ignore * the 'glyf' outline and advertise it as a bitmap-only font. */ if ( is_apple_sbix ) has_outline = FALSE; /* if this font doesn't contain outlines, we try to load */ /* a `bhed' table */ if ( !has_outline && sfnt->load_bhed ) { LOAD_( bhed ); is_apple_sbit = FT_BOOL( !error ); } /* load the font header (`head' table) if this isn't an Apple */ /* sbit font file */ if ( !is_apple_sbit || is_apple_sbix ) { LOAD_( head ); if ( error ) goto Exit; } if ( face->header.Units_Per_EM == 0 ) { error = FT_THROW( Invalid_Table ); goto Exit; } /* the following tables are often not present in embedded TrueType */ /* fonts within PDF documents, so don't check for them. */ LOAD_( maxp ); LOAD_( cmap ); /* the following tables are optional in PCL fonts -- */ /* don't check for errors */ LOAD_( name ); LOAD_( post ); #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES psnames_error = error; #endif /* do not load the metrics headers and tables if this is an Apple */ /* sbit font file */ if ( !is_apple_sbit ) { /* load the `hhea' and `hmtx' tables */ LOADM_( hhea, 0 ); if ( !error ) { LOADM_( hmtx, 0 ); if ( FT_ERR_EQ( error, Table_Missing ) ) { error = FT_THROW( Hmtx_Table_Missing ); #ifdef FT_CONFIG_OPTION_INCREMENTAL /* If this is an incrementally loaded font and there are */ /* overriding metrics, tolerate a missing `hmtx' table. */ if ( face->root.internal->incremental_interface && face->root.internal->incremental_interface->funcs-> get_glyph_metrics ) { face->horizontal.number_Of_HMetrics = 0; error = FT_Err_Ok; } #endif } } else if ( FT_ERR_EQ( error, Table_Missing ) ) { /* No `hhea' table necessary for SFNT Mac fonts. */ if ( face->format_tag == TTAG_true ) { FT_TRACE2(( "This is an SFNT Mac font.\n" )); has_outline = 0; error = FT_Err_Ok; } else { error = FT_THROW( Horiz_Header_Missing ); #ifdef FT_CONFIG_OPTION_INCREMENTAL /* If this is an incrementally loaded font and there are */ /* overriding metrics, tolerate a missing `hhea' table. */ if ( face->root.internal->incremental_interface && face->root.internal->incremental_interface->funcs-> get_glyph_metrics ) { face->horizontal.number_Of_HMetrics = 0; error = FT_Err_Ok; } #endif } } if ( error ) goto Exit; /* try to load the `vhea' and `vmtx' tables */ LOADM_( hhea, 1 ); if ( !error ) { LOADM_( hmtx, 1 ); if ( !error ) face->vertical_info = 1; } if ( error && FT_ERR_NEQ( error, Table_Missing ) ) goto Exit; LOAD_( os2 ); if ( error ) { /* we treat the table as missing if there are any errors */ face->os2.version = 0xFFFFU; } } /* the optional tables */ /* embedded bitmap support */ if ( sfnt->load_eblc ) LOAD_( eblc ); /* consider the pclt, kerning, and gasp tables as optional */ LOAD_( pclt ); LOAD_( gasp ); LOAD_( kern ); face->root.num_glyphs = face->max_profile.numGlyphs; /* Bit 8 of the `fsSelection' field in the `OS/2' table denotes */ /* a WWS-only font face. `WWS' stands for `weight', width', and */ /* `slope', a term used by Microsoft's Windows Presentation */ /* Foundation (WPF). This flag has been introduced in version */ /* 1.5 of the OpenType specification (May 2008). */ face->root.family_name = NULL; face->root.style_name = NULL; if ( face->os2.version != 0xFFFFU && face->os2.fsSelection & 256 ) { if ( !ignore_typographic_family ) GET_NAME( TYPOGRAPHIC_FAMILY, &face->root.family_name ); if ( !face->root.family_name ) GET_NAME( FONT_FAMILY, &face->root.family_name ); if ( !ignore_typographic_subfamily ) GET_NAME( TYPOGRAPHIC_SUBFAMILY, &face->root.style_name ); if ( !face->root.style_name ) GET_NAME( FONT_SUBFAMILY, &face->root.style_name ); } else { GET_NAME( WWS_FAMILY, &face->root.family_name ); if ( !face->root.family_name && !ignore_typographic_family ) GET_NAME( TYPOGRAPHIC_FAMILY, &face->root.family_name ); if ( !face->root.family_name ) GET_NAME( FONT_FAMILY, &face->root.family_name ); GET_NAME( WWS_SUBFAMILY, &face->root.style_name ); if ( !face->root.style_name && !ignore_typographic_subfamily ) GET_NAME( TYPOGRAPHIC_SUBFAMILY, &face->root.style_name ); if ( !face->root.style_name ) GET_NAME( FONT_SUBFAMILY, &face->root.style_name ); } /* now set up root fields */ { FT_Face root = &face->root; FT_Long flags = root->face_flags; /*********************************************************************/ /* */ /* Compute face flags. */ /* */ if ( face->sbit_table_type == TT_SBIT_TABLE_TYPE_CBLC || face->sbit_table_type == TT_SBIT_TABLE_TYPE_SBIX ) flags |= FT_FACE_FLAG_COLOR; /* color glyphs */ if ( has_outline == TRUE ) flags |= FT_FACE_FLAG_SCALABLE; /* scalable outlines */ /* The sfnt driver only supports bitmap fonts natively, thus we */ /* don't set FT_FACE_FLAG_HINTER. */ flags |= FT_FACE_FLAG_SFNT | /* SFNT file format */ FT_FACE_FLAG_HORIZONTAL; /* horizontal data */ #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES if ( !psnames_error && face->postscript.FormatType != 0x00030000L ) flags |= FT_FACE_FLAG_GLYPH_NAMES; #endif /* fixed width font? */ if ( face->postscript.isFixedPitch ) flags |= FT_FACE_FLAG_FIXED_WIDTH; /* vertical information? */ if ( face->vertical_info ) flags |= FT_FACE_FLAG_VERTICAL; /* kerning available ? */ if ( TT_FACE_HAS_KERNING( face ) ) flags |= FT_FACE_FLAG_KERNING; #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT /* Don't bother to load the tables unless somebody asks for them. */ /* No need to do work which will (probably) not be used. */ if ( face->variation_support & TT_FACE_FLAG_VAR_FVAR ) { if ( tt_face_lookup_table( face, TTAG_glyf ) != 0 && tt_face_lookup_table( face, TTAG_gvar ) != 0 ) flags |= FT_FACE_FLAG_MULTIPLE_MASTERS; if ( tt_face_lookup_table( face, TTAG_CFF2 ) != 0 ) flags |= FT_FACE_FLAG_MULTIPLE_MASTERS; } #endif root->face_flags = flags; /*********************************************************************/ /* */ /* Compute style flags. */ /* */ flags = 0; if ( has_outline == TRUE && face->os2.version != 0xFFFFU ) { /* We have an OS/2 table; use the `fsSelection' field. Bit 9 */ /* indicates an oblique font face. This flag has been */ /* introduced in version 1.5 of the OpenType specification. */ if ( face->os2.fsSelection & 512 ) /* bit 9 */ flags |= FT_STYLE_FLAG_ITALIC; else if ( face->os2.fsSelection & 1 ) /* bit 0 */ flags |= FT_STYLE_FLAG_ITALIC; if ( face->os2.fsSelection & 32 ) /* bit 5 */ flags |= FT_STYLE_FLAG_BOLD; } else { /* this is an old Mac font, use the header field */ if ( face->header.Mac_Style & 1 ) flags |= FT_STYLE_FLAG_BOLD; if ( face->header.Mac_Style & 2 ) flags |= FT_STYLE_FLAG_ITALIC; } root->style_flags |= flags; /*********************************************************************/ /* */ /* Polish the charmaps. */ /* */ /* Try to set the charmap encoding according to the platform & */ /* encoding ID of each charmap. */ /* */ tt_face_build_cmaps( face ); /* ignore errors */ /* set the encoding fields */ { FT_Int m; for ( m = 0; m < root->num_charmaps; m++ ) { FT_CharMap charmap = root->charmaps[m]; charmap->encoding = sfnt_find_encoding( charmap->platform_id, charmap->encoding_id ); #if 0 if ( !root->charmap && charmap->encoding == FT_ENCODING_UNICODE ) { /* set 'root->charmap' to the first Unicode encoding we find */ root->charmap = charmap; } #endif } } #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS /* * Now allocate the root array of FT_Bitmap_Size records and * populate them. Unfortunately, it isn't possible to indicate bit * depths in the FT_Bitmap_Size record. This is a design error. */ { FT_UInt count; count = face->sbit_num_strikes; if ( count > 0 ) { FT_Memory memory = face->root.stream->memory; FT_UShort em_size = face->header.Units_Per_EM; FT_Short avgwidth = face->os2.xAvgCharWidth; FT_Size_Metrics metrics; FT_UInt* sbit_strike_map = NULL; FT_UInt strike_idx, bsize_idx; if ( em_size == 0 || face->os2.version == 0xFFFFU ) { avgwidth = 1; em_size = 1; } /* to avoid invalid strike data in the `available_sizes' field */ /* of `FT_Face', we map `available_sizes' indices to strike */ /* indices */ if ( FT_NEW_ARRAY( root->available_sizes, count ) || FT_NEW_ARRAY( sbit_strike_map, count ) ) goto Exit; bsize_idx = 0; for ( strike_idx = 0; strike_idx < count; strike_idx++ ) { FT_Bitmap_Size* bsize = root->available_sizes + bsize_idx; error = sfnt->load_strike_metrics( face, strike_idx, &metrics ); if ( error ) continue; bsize->height = (FT_Short)( metrics.height >> 6 ); bsize->width = (FT_Short)( ( avgwidth * metrics.x_ppem + em_size / 2 ) / em_size ); bsize->x_ppem = metrics.x_ppem << 6; bsize->y_ppem = metrics.y_ppem << 6; /* assume 72dpi */ bsize->size = metrics.y_ppem << 6; /* only use strikes with valid PPEM values */ if ( bsize->x_ppem && bsize->y_ppem ) sbit_strike_map[bsize_idx++] = strike_idx; } /* reduce array size to the actually used elements */ (void)FT_RENEW_ARRAY( sbit_strike_map, count, bsize_idx ); /* from now on, all strike indices are mapped */ /* using `sbit_strike_map' */ if ( bsize_idx ) { face->sbit_strike_map = sbit_strike_map; root->face_flags |= FT_FACE_FLAG_FIXED_SIZES; root->num_fixed_sizes = (FT_Int)bsize_idx; } } } #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ /* a font with no bitmaps and no outlines is scalable; */ /* it has only empty glyphs then */ if ( !FT_HAS_FIXED_SIZES( root ) && !FT_IS_SCALABLE( root ) ) root->face_flags |= FT_FACE_FLAG_SCALABLE; /*********************************************************************/ /* */ /* Set up metrics. */ /* */ if ( FT_IS_SCALABLE( root ) ) { /* XXX What about if outline header is missing */ /* (e.g. sfnt wrapped bitmap)? */ root->bbox.xMin = face->header.xMin; root->bbox.yMin = face->header.yMin; root->bbox.xMax = face->header.xMax; root->bbox.yMax = face->header.yMax; root->units_per_EM = face->header.Units_Per_EM; /* XXX: Computing the ascender/descender/height is very different */ /* from what the specification tells you. Apparently, we */ /* must be careful because */ /* */ /* - not all fonts have an OS/2 table; in this case, we take */ /* the values in the horizontal header. However, these */ /* values very often are not reliable. */ /* */ /* - otherwise, the correct typographic values are in the */ /* sTypoAscender, sTypoDescender & sTypoLineGap fields. */ /* */ /* However, certain fonts have these fields set to 0. */ /* Rather, they have usWinAscent & usWinDescent correctly */ /* set (but with different values). */ /* */ /* As an example, Arial Narrow is implemented through four */ /* files ARIALN.TTF, ARIALNI.TTF, ARIALNB.TTF & ARIALNBI.TTF */ /* */ /* Strangely, all fonts have the same values in their */ /* sTypoXXX fields, except ARIALNB which sets them to 0. */ /* */ /* On the other hand, they all have different */ /* usWinAscent/Descent values -- as a conclusion, the OS/2 */ /* table cannot be used to compute the text height reliably! */ /* */ /* The ascender and descender are taken from the `hhea' table. */ /* If zero, they are taken from the `OS/2' table. */ root->ascender = face->horizontal.Ascender; root->descender = face->horizontal.Descender; root->height = root->ascender - root->descender + face->horizontal.Line_Gap; if ( !( root->ascender || root->descender ) ) { if ( face->os2.version != 0xFFFFU ) { if ( face->os2.sTypoAscender || face->os2.sTypoDescender ) { root->ascender = face->os2.sTypoAscender; root->descender = face->os2.sTypoDescender; root->height = root->ascender - root->descender + face->os2.sTypoLineGap; } else { root->ascender = (FT_Short)face->os2.usWinAscent; root->descender = -(FT_Short)face->os2.usWinDescent; root->height = root->ascender - root->descender; } } } root->max_advance_width = (FT_Short)face->horizontal.advance_Width_Max; root->max_advance_height = (FT_Short)( face->vertical_info ? face->vertical.advance_Height_Max : root->height ); /* See http://www.microsoft.com/OpenType/OTSpec/post.htm -- */ /* Adjust underline position from top edge to centre of */ /* stroke to convert TrueType meaning to FreeType meaning. */ root->underline_position = face->postscript.underlinePosition - face->postscript.underlineThickness / 2; root->underline_thickness = face->postscript.underlineThickness; } } Exit: FT_TRACE2(( "sfnt_load_face: done\n" )); return error; }
Overflow
0
sfnt_load_face( FT_Stream stream, TT_Face face, FT_Int face_instance_index, FT_Int num_params, FT_Parameter* params ) { FT_Error error; #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES FT_Error psnames_error; #endif FT_Bool has_outline; FT_Bool is_apple_sbit; FT_Bool is_apple_sbix; FT_Bool ignore_typographic_family = FALSE; FT_Bool ignore_typographic_subfamily = FALSE; SFNT_Service sfnt = (SFNT_Service)face->sfnt; FT_UNUSED( face_instance_index ); /* Check parameters */ { FT_Int i; for ( i = 0; i < num_params; i++ ) { if ( params[i].tag == FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_FAMILY ) ignore_typographic_family = TRUE; else if ( params[i].tag == FT_PARAM_TAG_IGNORE_TYPOGRAPHIC_SUBFAMILY ) ignore_typographic_subfamily = TRUE; } } /* Load tables */ /* We now support two SFNT-based bitmapped font formats. They */ /* are recognized easily as they do not include a `glyf' */ /* table. */ /* */ /* The first format comes from Apple, and uses a table named */ /* `bhed' instead of `head' to store the font header (using */ /* the same format). It also doesn't include horizontal and */ /* vertical metrics tables (i.e. `hhea' and `vhea' tables are */ /* missing). */ /* */ /* The other format comes from Microsoft, and is used with */ /* WinCE/PocketPC. It looks like a standard TTF, except that */ /* it doesn't contain outlines. */ /* */ FT_TRACE2(( "sfnt_load_face: %08p\n\n", face )); /* do we have outlines in there? */ #ifdef FT_CONFIG_OPTION_INCREMENTAL has_outline = FT_BOOL( face->root.internal->incremental_interface || tt_face_lookup_table( face, TTAG_glyf ) || tt_face_lookup_table( face, TTAG_CFF ) || tt_face_lookup_table( face, TTAG_CFF2 ) ); #else has_outline = FT_BOOL( tt_face_lookup_table( face, TTAG_glyf ) || tt_face_lookup_table( face, TTAG_CFF ) || tt_face_lookup_table( face, TTAG_CFF2 ) ); #endif is_apple_sbit = 0; is_apple_sbix = !face->goto_table( face, TTAG_sbix, stream, 0 ); /* Apple 'sbix' color bitmaps are rendered scaled and then the 'glyf' * outline rendered on top. We don't support that yet, so just ignore * the 'glyf' outline and advertise it as a bitmap-only font. */ if ( is_apple_sbix ) has_outline = FALSE; /* if this font doesn't contain outlines, we try to load */ /* a `bhed' table */ if ( !has_outline && sfnt->load_bhed ) { LOAD_( bhed ); is_apple_sbit = FT_BOOL( !error ); } /* load the font header (`head' table) if this isn't an Apple */ /* sbit font file */ if ( !is_apple_sbit || is_apple_sbix ) { LOAD_( head ); if ( error ) goto Exit; } if ( face->header.Units_Per_EM == 0 ) { error = FT_THROW( Invalid_Table ); goto Exit; } /* the following tables are often not present in embedded TrueType */ /* fonts within PDF documents, so don't check for them. */ LOAD_( maxp ); LOAD_( cmap ); /* the following tables are optional in PCL fonts -- */ /* don't check for errors */ LOAD_( name ); LOAD_( post ); #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES psnames_error = error; #endif /* do not load the metrics headers and tables if this is an Apple */ /* sbit font file */ if ( !is_apple_sbit ) { /* load the `hhea' and `hmtx' tables */ LOADM_( hhea, 0 ); if ( !error ) { LOADM_( hmtx, 0 ); if ( FT_ERR_EQ( error, Table_Missing ) ) { error = FT_THROW( Hmtx_Table_Missing ); #ifdef FT_CONFIG_OPTION_INCREMENTAL /* If this is an incrementally loaded font and there are */ /* overriding metrics, tolerate a missing `hmtx' table. */ if ( face->root.internal->incremental_interface && face->root.internal->incremental_interface->funcs-> get_glyph_metrics ) { face->horizontal.number_Of_HMetrics = 0; error = FT_Err_Ok; } #endif } } else if ( FT_ERR_EQ( error, Table_Missing ) ) { /* No `hhea' table necessary for SFNT Mac fonts. */ if ( face->format_tag == TTAG_true ) { FT_TRACE2(( "This is an SFNT Mac font.\n" )); has_outline = 0; error = FT_Err_Ok; } else { error = FT_THROW( Horiz_Header_Missing ); #ifdef FT_CONFIG_OPTION_INCREMENTAL /* If this is an incrementally loaded font and there are */ /* overriding metrics, tolerate a missing `hhea' table. */ if ( face->root.internal->incremental_interface && face->root.internal->incremental_interface->funcs-> get_glyph_metrics ) { face->horizontal.number_Of_HMetrics = 0; error = FT_Err_Ok; } #endif } } if ( error ) goto Exit; /* try to load the `vhea' and `vmtx' tables */ LOADM_( hhea, 1 ); if ( !error ) { LOADM_( hmtx, 1 ); if ( !error ) face->vertical_info = 1; } if ( error && FT_ERR_NEQ( error, Table_Missing ) ) goto Exit; LOAD_( os2 ); if ( error ) { /* we treat the table as missing if there are any errors */ face->os2.version = 0xFFFFU; } } /* the optional tables */ /* embedded bitmap support */ if ( sfnt->load_eblc ) LOAD_( eblc ); /* consider the pclt, kerning, and gasp tables as optional */ LOAD_( pclt ); LOAD_( gasp ); LOAD_( kern ); face->root.num_glyphs = face->max_profile.numGlyphs; /* Bit 8 of the `fsSelection' field in the `OS/2' table denotes */ /* a WWS-only font face. `WWS' stands for `weight', width', and */ /* `slope', a term used by Microsoft's Windows Presentation */ /* Foundation (WPF). This flag has been introduced in version */ /* 1.5 of the OpenType specification (May 2008). */ face->root.family_name = NULL; face->root.style_name = NULL; if ( face->os2.version != 0xFFFFU && face->os2.fsSelection & 256 ) { if ( !ignore_typographic_family ) GET_NAME( TYPOGRAPHIC_FAMILY, &face->root.family_name ); if ( !face->root.family_name ) GET_NAME( FONT_FAMILY, &face->root.family_name ); if ( !ignore_typographic_subfamily ) GET_NAME( TYPOGRAPHIC_SUBFAMILY, &face->root.style_name ); if ( !face->root.style_name ) GET_NAME( FONT_SUBFAMILY, &face->root.style_name ); } else { GET_NAME( WWS_FAMILY, &face->root.family_name ); if ( !face->root.family_name && !ignore_typographic_family ) GET_NAME( TYPOGRAPHIC_FAMILY, &face->root.family_name ); if ( !face->root.family_name ) GET_NAME( FONT_FAMILY, &face->root.family_name ); GET_NAME( WWS_SUBFAMILY, &face->root.style_name ); if ( !face->root.style_name && !ignore_typographic_subfamily ) GET_NAME( TYPOGRAPHIC_SUBFAMILY, &face->root.style_name ); if ( !face->root.style_name ) GET_NAME( FONT_SUBFAMILY, &face->root.style_name ); } /* now set up root fields */ { FT_Face root = &face->root; FT_Long flags = root->face_flags; /*********************************************************************/ /* */ /* Compute face flags. */ /* */ if ( face->sbit_table_type == TT_SBIT_TABLE_TYPE_CBLC || face->sbit_table_type == TT_SBIT_TABLE_TYPE_SBIX ) flags |= FT_FACE_FLAG_COLOR; /* color glyphs */ if ( has_outline == TRUE ) flags |= FT_FACE_FLAG_SCALABLE; /* scalable outlines */ /* The sfnt driver only supports bitmap fonts natively, thus we */ /* don't set FT_FACE_FLAG_HINTER. */ flags |= FT_FACE_FLAG_SFNT | /* SFNT file format */ FT_FACE_FLAG_HORIZONTAL; /* horizontal data */ #ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES if ( !psnames_error && face->postscript.FormatType != 0x00030000L ) flags |= FT_FACE_FLAG_GLYPH_NAMES; #endif /* fixed width font? */ if ( face->postscript.isFixedPitch ) flags |= FT_FACE_FLAG_FIXED_WIDTH; /* vertical information? */ if ( face->vertical_info ) flags |= FT_FACE_FLAG_VERTICAL; /* kerning available ? */ if ( TT_FACE_HAS_KERNING( face ) ) flags |= FT_FACE_FLAG_KERNING; #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT /* Don't bother to load the tables unless somebody asks for them. */ /* No need to do work which will (probably) not be used. */ if ( face->variation_support & TT_FACE_FLAG_VAR_FVAR ) { if ( tt_face_lookup_table( face, TTAG_glyf ) != 0 && tt_face_lookup_table( face, TTAG_gvar ) != 0 ) flags |= FT_FACE_FLAG_MULTIPLE_MASTERS; if ( tt_face_lookup_table( face, TTAG_CFF2 ) != 0 ) flags |= FT_FACE_FLAG_MULTIPLE_MASTERS; } #endif root->face_flags = flags; /*********************************************************************/ /* */ /* Compute style flags. */ /* */ flags = 0; if ( has_outline == TRUE && face->os2.version != 0xFFFFU ) { /* We have an OS/2 table; use the `fsSelection' field. Bit 9 */ /* indicates an oblique font face. This flag has been */ /* introduced in version 1.5 of the OpenType specification. */ if ( face->os2.fsSelection & 512 ) /* bit 9 */ flags |= FT_STYLE_FLAG_ITALIC; else if ( face->os2.fsSelection & 1 ) /* bit 0 */ flags |= FT_STYLE_FLAG_ITALIC; if ( face->os2.fsSelection & 32 ) /* bit 5 */ flags |= FT_STYLE_FLAG_BOLD; } else { /* this is an old Mac font, use the header field */ if ( face->header.Mac_Style & 1 ) flags |= FT_STYLE_FLAG_BOLD; if ( face->header.Mac_Style & 2 ) flags |= FT_STYLE_FLAG_ITALIC; } root->style_flags |= flags; /*********************************************************************/ /* */ /* Polish the charmaps. */ /* */ /* Try to set the charmap encoding according to the platform & */ /* encoding ID of each charmap. */ /* */ tt_face_build_cmaps( face ); /* ignore errors */ /* set the encoding fields */ { FT_Int m; for ( m = 0; m < root->num_charmaps; m++ ) { FT_CharMap charmap = root->charmaps[m]; charmap->encoding = sfnt_find_encoding( charmap->platform_id, charmap->encoding_id ); #if 0 if ( !root->charmap && charmap->encoding == FT_ENCODING_UNICODE ) { /* set 'root->charmap' to the first Unicode encoding we find */ root->charmap = charmap; } #endif } } #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS /* * Now allocate the root array of FT_Bitmap_Size records and * populate them. Unfortunately, it isn't possible to indicate bit * depths in the FT_Bitmap_Size record. This is a design error. */ { FT_UInt count; count = face->sbit_num_strikes; if ( count > 0 ) { FT_Memory memory = face->root.stream->memory; FT_UShort em_size = face->header.Units_Per_EM; FT_Short avgwidth = face->os2.xAvgCharWidth; FT_Size_Metrics metrics; FT_UInt* sbit_strike_map = NULL; FT_UInt strike_idx, bsize_idx; if ( em_size == 0 || face->os2.version == 0xFFFFU ) { avgwidth = 1; em_size = 1; } /* to avoid invalid strike data in the `available_sizes' field */ /* of `FT_Face', we map `available_sizes' indices to strike */ /* indices */ if ( FT_NEW_ARRAY( root->available_sizes, count ) || FT_NEW_ARRAY( sbit_strike_map, count ) ) goto Exit; bsize_idx = 0; for ( strike_idx = 0; strike_idx < count; strike_idx++ ) { FT_Bitmap_Size* bsize = root->available_sizes + bsize_idx; error = sfnt->load_strike_metrics( face, strike_idx, &metrics ); if ( error ) continue; bsize->height = (FT_Short)( metrics.height >> 6 ); bsize->width = (FT_Short)( ( avgwidth * metrics.x_ppem + em_size / 2 ) / em_size ); bsize->x_ppem = metrics.x_ppem << 6; bsize->y_ppem = metrics.y_ppem << 6; /* assume 72dpi */ bsize->size = metrics.y_ppem << 6; /* only use strikes with valid PPEM values */ if ( bsize->x_ppem && bsize->y_ppem ) sbit_strike_map[bsize_idx++] = strike_idx; } /* reduce array size to the actually used elements */ (void)FT_RENEW_ARRAY( sbit_strike_map, count, bsize_idx ); /* from now on, all strike indices are mapped */ /* using `sbit_strike_map' */ if ( bsize_idx ) { face->sbit_strike_map = sbit_strike_map; root->face_flags |= FT_FACE_FLAG_FIXED_SIZES; root->num_fixed_sizes = (FT_Int)bsize_idx; } } } #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ /* a font with no bitmaps and no outlines is scalable; */ /* it has only empty glyphs then */ if ( !FT_HAS_FIXED_SIZES( root ) && !FT_IS_SCALABLE( root ) ) root->face_flags |= FT_FACE_FLAG_SCALABLE; /*********************************************************************/ /* */ /* Set up metrics. */ /* */ if ( FT_IS_SCALABLE( root ) ) { /* XXX What about if outline header is missing */ /* (e.g. sfnt wrapped bitmap)? */ root->bbox.xMin = face->header.xMin; root->bbox.yMin = face->header.yMin; root->bbox.xMax = face->header.xMax; root->bbox.yMax = face->header.yMax; root->units_per_EM = face->header.Units_Per_EM; /* XXX: Computing the ascender/descender/height is very different */ /* from what the specification tells you. Apparently, we */ /* must be careful because */ /* */ /* - not all fonts have an OS/2 table; in this case, we take */ /* the values in the horizontal header. However, these */ /* values very often are not reliable. */ /* */ /* - otherwise, the correct typographic values are in the */ /* sTypoAscender, sTypoDescender & sTypoLineGap fields. */ /* */ /* However, certain fonts have these fields set to 0. */ /* Rather, they have usWinAscent & usWinDescent correctly */ /* set (but with different values). */ /* */ /* As an example, Arial Narrow is implemented through four */ /* files ARIALN.TTF, ARIALNI.TTF, ARIALNB.TTF & ARIALNBI.TTF */ /* */ /* Strangely, all fonts have the same values in their */ /* sTypoXXX fields, except ARIALNB which sets them to 0. */ /* */ /* On the other hand, they all have different */ /* usWinAscent/Descent values -- as a conclusion, the OS/2 */ /* table cannot be used to compute the text height reliably! */ /* */ /* The ascender and descender are taken from the `hhea' table. */ /* If zero, they are taken from the `OS/2' table. */ root->ascender = face->horizontal.Ascender; root->descender = face->horizontal.Descender; root->height = root->ascender - root->descender + face->horizontal.Line_Gap; if ( !( root->ascender || root->descender ) ) { if ( face->os2.version != 0xFFFFU ) { if ( face->os2.sTypoAscender || face->os2.sTypoDescender ) { root->ascender = face->os2.sTypoAscender; root->descender = face->os2.sTypoDescender; root->height = root->ascender - root->descender + face->os2.sTypoLineGap; } else { root->ascender = (FT_Short)face->os2.usWinAscent; root->descender = -(FT_Short)face->os2.usWinDescent; root->height = root->ascender - root->descender; } } } root->max_advance_width = (FT_Short)face->horizontal.advance_Width_Max; root->max_advance_height = (FT_Short)( face->vertical_info ? face->vertical.advance_Height_Max : root->height ); /* See http://www.microsoft.com/OpenType/OTSpec/post.htm -- */ /* Adjust underline position from top edge to centre of */ /* stroke to convert TrueType meaning to FreeType meaning. */ root->underline_position = face->postscript.underlinePosition - face->postscript.underlineThickness / 2; root->underline_thickness = face->postscript.underlineThickness; } } Exit: FT_TRACE2(( "sfnt_load_face: done\n" )); return error; }
@@ -1058,8 +1058,10 @@ FT_FREE( default_values ); FT_FREE( instance_values ); - /* we don't support Multiple Master CFFs yet */ + /* we don't support Multiple Master CFFs yet; */ + /* note that `glyf' or `CFF2' have precedence */ if ( face->goto_table( face, TTAG_glyf, stream, 0 ) && + face->goto_table( face, TTAG_CFF2, stream, 0 ) && !face->goto_table( face, TTAG_CFF, stream, 0 ) ) num_instances = 0;
CWE-787
null
null
5,979
void doMergeFormDict(Dict *srcFormDict, Dict *mergeFormDict, int numOffset) { Object srcFields, mergeFields; srcFormDict->lookup("Fields", &srcFields); mergeFormDict->lookup("Fields", &mergeFields); if (srcFields.isArray() && mergeFields.isArray()) { for (int i = 0; i < mergeFields.arrayGetLength(); i++) { Object value; Object *newValue = new Object(); mergeFields.arrayGetNF(i, &value); newValue->initRef(value.getRef().num + numOffset, value.getRef().gen); srcFields.arrayAdd(newValue); value.free(); delete newValue; } } srcFields.free(); mergeFields.free(); }
null
0
void doMergeFormDict(Dict *srcFormDict, Dict *mergeFormDict, int numOffset) { Object srcFields, mergeFields; srcFormDict->lookup("Fields", &srcFields); mergeFormDict->lookup("Fields", &mergeFields); if (srcFields.isArray() && mergeFields.isArray()) { for (int i = 0; i < mergeFields.arrayGetLength(); i++) { Object value; Object *newValue = new Object(); mergeFields.arrayGetNF(i, &value); newValue->initRef(value.getRef().num + numOffset, value.getRef().gen); srcFields.arrayAdd(newValue); value.free(); delete newValue; } } srcFields.free(); mergeFields.free(); }
@@ -7,7 +7,7 @@ // Copyright (C) 2011-2015, 2017 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2012 Arseny Solokha <asolokha@gmx.com> // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> -// Copyright (C) 2012, 2014 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2012, 2014, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2013 Hib Eris <hib@hiberis.nl> // Copyright (C) 2015 Arthur Stavisky <vovodroid@gmail.com> @@ -268,15 +268,15 @@ int main (int argc, char *argv[]) catDict->lookup("OutputIntents", &intents); catDict->lookupNF("AcroForm", &afObj); Ref *refPage = docs[0]->getCatalog()->getPageRef(1); - if (!afObj.isNull()) { + if (!afObj.isNull() && refPage) { docs[0]->markAcroForm(&afObj, yRef, countRef, 0, refPage->num, refPage->num); } catDict->lookupNF("OCProperties", &ocObj); - if (!ocObj.isNull() && ocObj.isDict()) { + if (!ocObj.isNull() && ocObj.isDict() && refPage) { docs[0]->markPageObjects(ocObj.getDict(), yRef, countRef, 0, refPage->num, refPage->num); } catDict->lookup("Names", &names); - if (!names.isNull() && names.isDict()) { + if (!names.isNull() && names.isDict() && refPage) { docs[0]->markPageObjects(names.getDict(), yRef, countRef, 0, refPage->num, refPage->num); } if (intents.isArray() && intents.arrayGetLength() > 0) { @@ -353,6 +353,10 @@ int main (int argc, char *argv[]) for (i = 0; i < (int) docs.size(); i++) { for (j = 1; j <= docs[i]->getNumPages(); j++) { + if (!docs[i]->getCatalog()->getPage(j)) { + continue; + } + PDFRectangle *cropBox = NULL; if (docs[i]->getCatalog()->getPage(j)->isCropped()) cropBox = docs[i]->getCatalog()->getPage(j)->getCropBox();
CWE-476
null
null
5,980
void doMergeNameDict(PDFDoc *doc, XRef *srcXRef, XRef *countRef, int oldRefNum, int newRefNum, Dict *srcNameDict, Dict *mergeNameDict, int numOffset) { for (int i = 0; i < mergeNameDict->getLength(); i++) { const char *key = mergeNameDict->getKey(i); Object mergeNameTree; Object srcNameTree; mergeNameDict->lookup(key, &mergeNameTree); srcNameDict->lookup(key, &srcNameTree); if (srcNameTree.isDict() && mergeNameTree.isDict()) { doMergeNameTree(doc, srcXRef, countRef, oldRefNum, newRefNum, srcNameTree.getDict(), mergeNameTree.getDict(), numOffset); } else if (srcNameTree.isNull() && mergeNameTree.isDict()) { Object *newNameTree = new Object(); newNameTree->initDict(srcXRef); doMergeNameTree(doc, srcXRef, countRef, oldRefNum, newRefNum, newNameTree->getDict(), mergeNameTree.getDict(), numOffset); srcNameDict->add(copyString(key), newNameTree); } srcNameTree.free(); mergeNameTree.free(); } }
null
0
void doMergeNameDict(PDFDoc *doc, XRef *srcXRef, XRef *countRef, int oldRefNum, int newRefNum, Dict *srcNameDict, Dict *mergeNameDict, int numOffset) { for (int i = 0; i < mergeNameDict->getLength(); i++) { const char *key = mergeNameDict->getKey(i); Object mergeNameTree; Object srcNameTree; mergeNameDict->lookup(key, &mergeNameTree); srcNameDict->lookup(key, &srcNameTree); if (srcNameTree.isDict() && mergeNameTree.isDict()) { doMergeNameTree(doc, srcXRef, countRef, oldRefNum, newRefNum, srcNameTree.getDict(), mergeNameTree.getDict(), numOffset); } else if (srcNameTree.isNull() && mergeNameTree.isDict()) { Object *newNameTree = new Object(); newNameTree->initDict(srcXRef); doMergeNameTree(doc, srcXRef, countRef, oldRefNum, newRefNum, newNameTree->getDict(), mergeNameTree.getDict(), numOffset); srcNameDict->add(copyString(key), newNameTree); } srcNameTree.free(); mergeNameTree.free(); } }
@@ -7,7 +7,7 @@ // Copyright (C) 2011-2015, 2017 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2012 Arseny Solokha <asolokha@gmx.com> // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> -// Copyright (C) 2012, 2014 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2012, 2014, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2013 Hib Eris <hib@hiberis.nl> // Copyright (C) 2015 Arthur Stavisky <vovodroid@gmail.com> @@ -268,15 +268,15 @@ int main (int argc, char *argv[]) catDict->lookup("OutputIntents", &intents); catDict->lookupNF("AcroForm", &afObj); Ref *refPage = docs[0]->getCatalog()->getPageRef(1); - if (!afObj.isNull()) { + if (!afObj.isNull() && refPage) { docs[0]->markAcroForm(&afObj, yRef, countRef, 0, refPage->num, refPage->num); } catDict->lookupNF("OCProperties", &ocObj); - if (!ocObj.isNull() && ocObj.isDict()) { + if (!ocObj.isNull() && ocObj.isDict() && refPage) { docs[0]->markPageObjects(ocObj.getDict(), yRef, countRef, 0, refPage->num, refPage->num); } catDict->lookup("Names", &names); - if (!names.isNull() && names.isDict()) { + if (!names.isNull() && names.isDict() && refPage) { docs[0]->markPageObjects(names.getDict(), yRef, countRef, 0, refPage->num, refPage->num); } if (intents.isArray() && intents.arrayGetLength() > 0) { @@ -353,6 +353,10 @@ int main (int argc, char *argv[]) for (i = 0; i < (int) docs.size(); i++) { for (j = 1; j <= docs[i]->getNumPages(); j++) { + if (!docs[i]->getCatalog()->getPage(j)) { + continue; + } + PDFRectangle *cropBox = NULL; if (docs[i]->getCatalog()->getPage(j)->isCropped()) cropBox = docs[i]->getCatalog()->getPage(j)->getCropBox();
CWE-476
null
null
5,981
void doMergeNameTree(PDFDoc *doc, XRef *srcXRef, XRef *countRef, int oldRefNum, int newRefNum, Dict *srcNameTree, Dict *mergeNameTree, int numOffset) { Object mergeNameArray; Object srcNameArray; mergeNameTree->lookup("Names", &mergeNameArray); srcNameTree->lookup("Names", &srcNameArray); if (mergeNameArray.isArray() && srcNameArray.isArray()) { Object *newNameArray = new Object(); newNameArray->initArray(srcXRef); int j = 0; for (int i = 0; i < srcNameArray.arrayGetLength() - 1; i += 2) { Object key; Object value; srcNameArray.arrayGetNF(i, &key); srcNameArray.arrayGetNF(i + 1, &value); if (key.isString() && value.isRef()) { while (j < mergeNameArray.arrayGetLength() - 1) { Object mkey; Object mvalue; mergeNameArray.arrayGetNF(j, &mkey); mergeNameArray.arrayGetNF(j + 1, &mvalue); if (mkey.isString() && mvalue.isRef()) { if (mkey.getString()->cmp(key.getString()) < 0) { Object *newKey = new Object(); newKey->initString(new GooString(mkey.getString()->getCString())); newNameArray->arrayAdd(newKey); Object *newValue = new Object(); newValue->initRef(mvalue.getRef().num + numOffset, mvalue.getRef().gen); newNameArray->arrayAdd(newValue); delete newKey; delete newValue; j += 2; } else if (mkey.getString()->cmp(key.getString()) == 0) { j += 2; } else { mkey.free(); mvalue.free(); break; } } else { j += 2; } mkey.free(); mvalue.free(); } Object *newKey = new Object(); newKey->initString(new GooString(key.getString()->getCString())); newNameArray->arrayAdd(newKey); Object *newValue = new Object(); newValue->initRef(value.getRef().num, value.getRef().gen); newNameArray->arrayAdd(newValue); delete newKey; delete newValue; } key.free(); value.free(); } while (j < mergeNameArray.arrayGetLength() - 1) { Object mkey; Object mvalue; mergeNameArray.arrayGetNF(j, &mkey); mergeNameArray.arrayGetNF(j + 1, &mvalue); if (mkey.isString() && mvalue.isRef()) { Object *newKey = new Object(); newKey->initString(new GooString(mkey.getString()->getCString())); newNameArray->arrayAdd(newKey); Object *newValue = new Object(); newValue->initRef(mvalue.getRef().num + numOffset, mvalue.getRef().gen); newNameArray->arrayAdd(newValue); delete newKey; delete newValue; } j += 2; mkey.free(); mvalue.free(); } srcNameTree->set("Names", newNameArray); doc->markPageObjects(mergeNameTree, srcXRef, countRef, numOffset, oldRefNum, newRefNum); delete newNameArray; } else if (srcNameArray.isNull() && mergeNameArray.isArray()) { Object *newNameArray = new Object(); newNameArray->initArray(srcXRef); for (int i = 0; i < mergeNameArray.arrayGetLength() - 1; i += 2) { Object key; Object value; mergeNameArray.arrayGetNF(i, &key); mergeNameArray.arrayGetNF(i + 1, &value); if (key.isString() && value.isRef()) { Object *newKey = new Object(); newKey->initString(new GooString(key.getString()->getCString())); newNameArray->arrayAdd(newKey); Object *newValue = new Object(); newValue->initRef(value.getRef().num + numOffset, value.getRef().gen); newNameArray->arrayAdd(newValue); delete newKey; delete newValue; } key.free(); value.free(); } srcNameTree->add(copyString("Names"), newNameArray); doc->markPageObjects(mergeNameTree, srcXRef, countRef, numOffset, oldRefNum, newRefNum); } mergeNameArray.free(); srcNameArray.free(); }
null
0
void doMergeNameTree(PDFDoc *doc, XRef *srcXRef, XRef *countRef, int oldRefNum, int newRefNum, Dict *srcNameTree, Dict *mergeNameTree, int numOffset) { Object mergeNameArray; Object srcNameArray; mergeNameTree->lookup("Names", &mergeNameArray); srcNameTree->lookup("Names", &srcNameArray); if (mergeNameArray.isArray() && srcNameArray.isArray()) { Object *newNameArray = new Object(); newNameArray->initArray(srcXRef); int j = 0; for (int i = 0; i < srcNameArray.arrayGetLength() - 1; i += 2) { Object key; Object value; srcNameArray.arrayGetNF(i, &key); srcNameArray.arrayGetNF(i + 1, &value); if (key.isString() && value.isRef()) { while (j < mergeNameArray.arrayGetLength() - 1) { Object mkey; Object mvalue; mergeNameArray.arrayGetNF(j, &mkey); mergeNameArray.arrayGetNF(j + 1, &mvalue); if (mkey.isString() && mvalue.isRef()) { if (mkey.getString()->cmp(key.getString()) < 0) { Object *newKey = new Object(); newKey->initString(new GooString(mkey.getString()->getCString())); newNameArray->arrayAdd(newKey); Object *newValue = new Object(); newValue->initRef(mvalue.getRef().num + numOffset, mvalue.getRef().gen); newNameArray->arrayAdd(newValue); delete newKey; delete newValue; j += 2; } else if (mkey.getString()->cmp(key.getString()) == 0) { j += 2; } else { mkey.free(); mvalue.free(); break; } } else { j += 2; } mkey.free(); mvalue.free(); } Object *newKey = new Object(); newKey->initString(new GooString(key.getString()->getCString())); newNameArray->arrayAdd(newKey); Object *newValue = new Object(); newValue->initRef(value.getRef().num, value.getRef().gen); newNameArray->arrayAdd(newValue); delete newKey; delete newValue; } key.free(); value.free(); } while (j < mergeNameArray.arrayGetLength() - 1) { Object mkey; Object mvalue; mergeNameArray.arrayGetNF(j, &mkey); mergeNameArray.arrayGetNF(j + 1, &mvalue); if (mkey.isString() && mvalue.isRef()) { Object *newKey = new Object(); newKey->initString(new GooString(mkey.getString()->getCString())); newNameArray->arrayAdd(newKey); Object *newValue = new Object(); newValue->initRef(mvalue.getRef().num + numOffset, mvalue.getRef().gen); newNameArray->arrayAdd(newValue); delete newKey; delete newValue; } j += 2; mkey.free(); mvalue.free(); } srcNameTree->set("Names", newNameArray); doc->markPageObjects(mergeNameTree, srcXRef, countRef, numOffset, oldRefNum, newRefNum); delete newNameArray; } else if (srcNameArray.isNull() && mergeNameArray.isArray()) { Object *newNameArray = new Object(); newNameArray->initArray(srcXRef); for (int i = 0; i < mergeNameArray.arrayGetLength() - 1; i += 2) { Object key; Object value; mergeNameArray.arrayGetNF(i, &key); mergeNameArray.arrayGetNF(i + 1, &value); if (key.isString() && value.isRef()) { Object *newKey = new Object(); newKey->initString(new GooString(key.getString()->getCString())); newNameArray->arrayAdd(newKey); Object *newValue = new Object(); newValue->initRef(value.getRef().num + numOffset, value.getRef().gen); newNameArray->arrayAdd(newValue); delete newKey; delete newValue; } key.free(); value.free(); } srcNameTree->add(copyString("Names"), newNameArray); doc->markPageObjects(mergeNameTree, srcXRef, countRef, numOffset, oldRefNum, newRefNum); } mergeNameArray.free(); srcNameArray.free(); }
@@ -7,7 +7,7 @@ // Copyright (C) 2011-2015, 2017 Thomas Freitag <Thomas.Freitag@alfa.de> // Copyright (C) 2012 Arseny Solokha <asolokha@gmx.com> // Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it> -// Copyright (C) 2012, 2014 Albert Astals Cid <aacid@kde.org> +// Copyright (C) 2012, 2014, 2017 Albert Astals Cid <aacid@kde.org> // Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com> // Copyright (C) 2013 Hib Eris <hib@hiberis.nl> // Copyright (C) 2015 Arthur Stavisky <vovodroid@gmail.com> @@ -268,15 +268,15 @@ int main (int argc, char *argv[]) catDict->lookup("OutputIntents", &intents); catDict->lookupNF("AcroForm", &afObj); Ref *refPage = docs[0]->getCatalog()->getPageRef(1); - if (!afObj.isNull()) { + if (!afObj.isNull() && refPage) { docs[0]->markAcroForm(&afObj, yRef, countRef, 0, refPage->num, refPage->num); } catDict->lookupNF("OCProperties", &ocObj); - if (!ocObj.isNull() && ocObj.isDict()) { + if (!ocObj.isNull() && ocObj.isDict() && refPage) { docs[0]->markPageObjects(ocObj.getDict(), yRef, countRef, 0, refPage->num, refPage->num); } catDict->lookup("Names", &names); - if (!names.isNull() && names.isDict()) { + if (!names.isNull() && names.isDict() && refPage) { docs[0]->markPageObjects(names.getDict(), yRef, countRef, 0, refPage->num, refPage->num); } if (intents.isArray() && intents.arrayGetLength() > 0) { @@ -353,6 +353,10 @@ int main (int argc, char *argv[]) for (i = 0; i < (int) docs.size(); i++) { for (j = 1; j <= docs[i]->getNumPages(); j++) { + if (!docs[i]->getCatalog()->getPage(j)) { + continue; + } + PDFRectangle *cropBox = NULL; if (docs[i]->getCatalog()->getPage(j)->isCropped()) cropBox = docs[i]->getCatalog()->getPage(j)->getCropBox();
CWE-476
null
null
5,982
change_env (timezone_t tz) { if (setenv_TZ (tz->tz_is_set ? tz->abbrs : NULL) != 0) return false; tzset (); return true; }
Overflow
0
change_env (timezone_t tz) { if (setenv_TZ (tz->tz_is_set ? tz->abbrs : NULL) != 0) return false; tzset (); return true; }
@@ -27,6 +27,7 @@ #include <time.h> #include <errno.h> +#include <limits.h> #include <stdbool.h> #include <stddef.h> #include <stdlib.h> @@ -35,6 +36,10 @@ #include "flexmember.h" #include "time-internal.h" +#ifndef SIZE_MAX +# define SIZE_MAX ((size_t) -1) +#endif + #if !HAVE_TZSET static void tzset (void) { } #endif @@ -43,7 +48,7 @@ static void tzset (void) { } the largest "small" request for the GNU C library malloc. */ enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 }; -/* Minimum size of the ABBRS member of struct abbr. ABBRS is larger +/* Minimum size of the ABBRS member of struct tm_zone. ABBRS is larger only in the unlikely case where an abbreviation longer than this is used. */ enum { ABBR_SIZE_MIN = DEFAULT_MXFAST - offsetof (struct tm_zone, abbrs) }; @@ -150,7 +155,13 @@ save_abbr (timezone_t tz, struct tm *tm) if (! (*zone_copy || (zone_copy == tz->abbrs && tz->tz_is_set))) { size_t zone_size = strlen (zone) + 1; - if (zone_size < tz->abbrs + ABBR_SIZE_MIN - zone_copy) + size_t zone_used = zone_copy - tz->abbrs; + if (SIZE_MAX - zone_used < zone_size) + { + errno = ENOMEM; + return false; + } + if (zone_used + zone_size < ABBR_SIZE_MIN) extend_abbrs (zone_copy, zone, zone_size); else {
CWE-119
null
null
5,983
extend_abbrs (char *abbrs, char const *abbr, size_t abbr_size) { memcpy (abbrs, abbr, abbr_size); abbrs[abbr_size] = '\0'; }
Overflow
0
extend_abbrs (char *abbrs, char const *abbr, size_t abbr_size) { memcpy (abbrs, abbr, abbr_size); abbrs[abbr_size] = '\0'; }
@@ -27,6 +27,7 @@ #include <time.h> #include <errno.h> +#include <limits.h> #include <stdbool.h> #include <stddef.h> #include <stdlib.h> @@ -35,6 +36,10 @@ #include "flexmember.h" #include "time-internal.h" +#ifndef SIZE_MAX +# define SIZE_MAX ((size_t) -1) +#endif + #if !HAVE_TZSET static void tzset (void) { } #endif @@ -43,7 +48,7 @@ static void tzset (void) { } the largest "small" request for the GNU C library malloc. */ enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 }; -/* Minimum size of the ABBRS member of struct abbr. ABBRS is larger +/* Minimum size of the ABBRS member of struct tm_zone. ABBRS is larger only in the unlikely case where an abbreviation longer than this is used. */ enum { ABBR_SIZE_MIN = DEFAULT_MXFAST - offsetof (struct tm_zone, abbrs) }; @@ -150,7 +155,13 @@ save_abbr (timezone_t tz, struct tm *tm) if (! (*zone_copy || (zone_copy == tz->abbrs && tz->tz_is_set))) { size_t zone_size = strlen (zone) + 1; - if (zone_size < tz->abbrs + ABBR_SIZE_MIN - zone_copy) + size_t zone_used = zone_copy - tz->abbrs; + if (SIZE_MAX - zone_used < zone_size) + { + errno = ENOMEM; + return false; + } + if (zone_used + zone_size < ABBR_SIZE_MIN) extend_abbrs (zone_copy, zone, zone_size); else {
CWE-119
null
null
5,984
getenv_TZ (void) { return getenv ("TZ"); }
Overflow
0
getenv_TZ (void) { return getenv ("TZ"); }
@@ -27,6 +27,7 @@ #include <time.h> #include <errno.h> +#include <limits.h> #include <stdbool.h> #include <stddef.h> #include <stdlib.h> @@ -35,6 +36,10 @@ #include "flexmember.h" #include "time-internal.h" +#ifndef SIZE_MAX +# define SIZE_MAX ((size_t) -1) +#endif + #if !HAVE_TZSET static void tzset (void) { } #endif @@ -43,7 +48,7 @@ static void tzset (void) { } the largest "small" request for the GNU C library malloc. */ enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 }; -/* Minimum size of the ABBRS member of struct abbr. ABBRS is larger +/* Minimum size of the ABBRS member of struct tm_zone. ABBRS is larger only in the unlikely case where an abbreviation longer than this is used. */ enum { ABBR_SIZE_MIN = DEFAULT_MXFAST - offsetof (struct tm_zone, abbrs) }; @@ -150,7 +155,13 @@ save_abbr (timezone_t tz, struct tm *tm) if (! (*zone_copy || (zone_copy == tz->abbrs && tz->tz_is_set))) { size_t zone_size = strlen (zone) + 1; - if (zone_size < tz->abbrs + ABBR_SIZE_MIN - zone_copy) + size_t zone_used = zone_copy - tz->abbrs; + if (SIZE_MAX - zone_used < zone_size) + { + errno = ENOMEM; + return false; + } + if (zone_used + zone_size < ABBR_SIZE_MIN) extend_abbrs (zone_copy, zone, zone_size); else {
CWE-119
null
null
5,985
isdst_differ (int a, int b) { return !a != !b && 0 <= a && 0 <= b; }
Overflow
0
isdst_differ (int a, int b) { return !a != !b && 0 <= a && 0 <= b; }
@@ -27,6 +27,7 @@ #include <time.h> #include <errno.h> +#include <limits.h> #include <stdbool.h> #include <stddef.h> #include <stdlib.h> @@ -35,6 +36,10 @@ #include "flexmember.h" #include "time-internal.h" +#ifndef SIZE_MAX +# define SIZE_MAX ((size_t) -1) +#endif + #if !HAVE_TZSET static void tzset (void) { } #endif @@ -43,7 +48,7 @@ static void tzset (void) { } the largest "small" request for the GNU C library malloc. */ enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 }; -/* Minimum size of the ABBRS member of struct abbr. ABBRS is larger +/* Minimum size of the ABBRS member of struct tm_zone. ABBRS is larger only in the unlikely case where an abbreviation longer than this is used. */ enum { ABBR_SIZE_MIN = DEFAULT_MXFAST - offsetof (struct tm_zone, abbrs) }; @@ -150,7 +155,13 @@ save_abbr (timezone_t tz, struct tm *tm) if (! (*zone_copy || (zone_copy == tz->abbrs && tz->tz_is_set))) { size_t zone_size = strlen (zone) + 1; - if (zone_size < tz->abbrs + ABBR_SIZE_MIN - zone_copy) + size_t zone_used = zone_copy - tz->abbrs; + if (SIZE_MAX - zone_used < zone_size) + { + errno = ENOMEM; + return false; + } + if (zone_used + zone_size < ABBR_SIZE_MIN) extend_abbrs (zone_copy, zone, zone_size); else {
CWE-119
null
null
5,986
localtime_rz (timezone_t tz, time_t const *t, struct tm *tm) { if (!tz) return gmtime_r (t, tm); else { timezone_t old_tz = set_tz (tz); if (old_tz) { bool abbr_saved = localtime_r (t, tm) && save_abbr (tz, tm); if (revert_tz (old_tz) && abbr_saved) return tm; } return NULL; } }
Overflow
0
localtime_rz (timezone_t tz, time_t const *t, struct tm *tm) { if (!tz) return gmtime_r (t, tm); else { timezone_t old_tz = set_tz (tz); if (old_tz) { bool abbr_saved = localtime_r (t, tm) && save_abbr (tz, tm); if (revert_tz (old_tz) && abbr_saved) return tm; } return NULL; } }
@@ -27,6 +27,7 @@ #include <time.h> #include <errno.h> +#include <limits.h> #include <stdbool.h> #include <stddef.h> #include <stdlib.h> @@ -35,6 +36,10 @@ #include "flexmember.h" #include "time-internal.h" +#ifndef SIZE_MAX +# define SIZE_MAX ((size_t) -1) +#endif + #if !HAVE_TZSET static void tzset (void) { } #endif @@ -43,7 +48,7 @@ static void tzset (void) { } the largest "small" request for the GNU C library malloc. */ enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 }; -/* Minimum size of the ABBRS member of struct abbr. ABBRS is larger +/* Minimum size of the ABBRS member of struct tm_zone. ABBRS is larger only in the unlikely case where an abbreviation longer than this is used. */ enum { ABBR_SIZE_MIN = DEFAULT_MXFAST - offsetof (struct tm_zone, abbrs) }; @@ -150,7 +155,13 @@ save_abbr (timezone_t tz, struct tm *tm) if (! (*zone_copy || (zone_copy == tz->abbrs && tz->tz_is_set))) { size_t zone_size = strlen (zone) + 1; - if (zone_size < tz->abbrs + ABBR_SIZE_MIN - zone_copy) + size_t zone_used = zone_copy - tz->abbrs; + if (SIZE_MAX - zone_used < zone_size) + { + errno = ENOMEM; + return false; + } + if (zone_used + zone_size < ABBR_SIZE_MIN) extend_abbrs (zone_copy, zone, zone_size); else {
CWE-119
null
null
5,987
revert_tz (timezone_t tz) { if (tz == local_tz) return true; else { int saved_errno = errno; bool ok = change_env (tz); if (!ok) saved_errno = errno; tzfree (tz); errno = saved_errno; return ok; } }
Overflow
0
revert_tz (timezone_t tz) { if (tz == local_tz) return true; else { int saved_errno = errno; bool ok = change_env (tz); if (!ok) saved_errno = errno; tzfree (tz); errno = saved_errno; return ok; } }
@@ -27,6 +27,7 @@ #include <time.h> #include <errno.h> +#include <limits.h> #include <stdbool.h> #include <stddef.h> #include <stdlib.h> @@ -35,6 +36,10 @@ #include "flexmember.h" #include "time-internal.h" +#ifndef SIZE_MAX +# define SIZE_MAX ((size_t) -1) +#endif + #if !HAVE_TZSET static void tzset (void) { } #endif @@ -43,7 +48,7 @@ static void tzset (void) { } the largest "small" request for the GNU C library malloc. */ enum { DEFAULT_MXFAST = 64 * sizeof (size_t) / 4 }; -/* Minimum size of the ABBRS member of struct abbr. ABBRS is larger +/* Minimum size of the ABBRS member of struct tm_zone. ABBRS is larger only in the unlikely case where an abbreviation longer than this is used. */ enum { ABBR_SIZE_MIN = DEFAULT_MXFAST - offsetof (struct tm_zone, abbrs) }; @@ -150,7 +155,13 @@ save_abbr (timezone_t tz, struct tm *tm) if (! (*zone_copy || (zone_copy == tz->abbrs && tz->tz_is_set))) { size_t zone_size = strlen (zone) + 1; - if (zone_size < tz->abbrs + ABBR_SIZE_MIN - zone_copy) + size_t zone_used = zone_copy - tz->abbrs; + if (SIZE_MAX - zone_used < zone_size) + { + errno = ENOMEM; + return false; + } + if (zone_used + zone_size < ABBR_SIZE_MIN) extend_abbrs (zone_copy, zone, zone_size); else {
CWE-119
null
null
5,988
gmt_offset (time_t s) { long gmtoff; #if !HAVE_TM_GMTOFF struct tm tm_local = *localtime (&s); struct tm tm_gmt = *gmtime (&s); gmtoff = tm_diff (&tm_local, &tm_gmt); #else gmtoff = localtime (&s)->tm_gmtoff; #endif return gmtoff; }
Overflow
0
gmt_offset (time_t s) { long gmtoff; #if !HAVE_TM_GMTOFF struct tm tm_local = *localtime (&s); struct tm tm_gmt = *gmtime (&s); gmtoff = tm_diff (&tm_local, &tm_gmt); #else gmtoff = localtime (&s)->tm_gmtoff; #endif return gmtoff; }
@@ -432,5 +432,21 @@ main (int argc _GL_UNUSED, char **argv) ASSERT ( parse_datetime (&result, "TZ=\"\\\\\"", &now)); ASSERT ( parse_datetime (&result, "TZ=\"\\\"\"", &now)); + /* Outlandishly-long time zone abbreviations should not cause problems. */ + { + static char const bufprefix[] = "TZ=\""; + enum { tzname_len = 2000 }; + static char const bufsuffix[] = "0\" 1970-01-01 01:02:03.123456789"; + enum { bufsize = sizeof bufprefix - 1 + tzname_len + sizeof bufsuffix }; + char buf[bufsize]; + memcpy (buf, bufprefix, sizeof bufprefix - 1); + memset (buf + sizeof bufprefix - 1, 'X', tzname_len); + strcpy (buf + bufsize - sizeof bufsuffix, bufsuffix); + ASSERT (parse_datetime (&result, buf, &now)); + LOG (buf, now, result); + ASSERT (result.tv_sec == 1 * 60 * 60 + 2 * 60 + 3 + && result.tv_nsec == 123456789); + } + return 0; }
CWE-119
null
null
5,989
static inline int finish_nested_data(UNSERIALIZE_PARAMETER) { if (*((*p)++) == '}')
Exec Code
0
static inline int finish_nested_data(UNSERIALIZE_PARAMETER) { if (*((*p)++) == '}')
@@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 */ +/* Generated by re2c 0.13.7.5 on Thu Dec 11 19:26:19 2014 */ #line 1 "ext/standard/var_unserializer.re" /* +----------------------------------------------------------------------+ @@ -343,6 +343,9 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long } else { /* object properties should include no integers */ convert_to_string(key); + if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) { + var_push_dtor(var_hash, old_data); + } zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data, sizeof data, NULL); } @@ -480,7 +483,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) -#line 484 "ext/standard/var_unserializer.c" +#line 487 "ext/standard/var_unserializer.c" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -540,9 +543,9 @@ yy2: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy95; yy3: -#line 835 "ext/standard/var_unserializer.re" +#line 838 "ext/standard/var_unserializer.re" { return 0; } -#line 546 "ext/standard/var_unserializer.c" +#line 549 "ext/standard/var_unserializer.c" yy4: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy89; @@ -585,13 +588,13 @@ yy13: goto yy3; yy14: ++YYCURSOR; -#line 829 "ext/standard/var_unserializer.re" +#line 832 "ext/standard/var_unserializer.re" { /* this is the case where we have less data than planned */ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unexpected end of serialized data"); return 0; /* not sure if it should be 0 or 1 here? */ } -#line 595 "ext/standard/var_unserializer.c" +#line 598 "ext/standard/var_unserializer.c" yy16: yych = *++YYCURSOR; goto yy3; @@ -617,11 +620,12 @@ yy20: if (yybm[0+yych] & 128) { goto yy20; } - if (yych != ':') goto yy18; + if (yych <= '/') goto yy18; + if (yych >= ';') goto yy18; yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 683 "ext/standard/var_unserializer.re" +#line 686 "ext/standard/var_unserializer.re" { size_t len, len2, len3, maxlen; long elements; @@ -767,7 +771,7 @@ yy20: return object_common2(UNSERIALIZE_PASSTHRU, elements); } -#line 771 "ext/standard/var_unserializer.c" +#line 775 "ext/standard/var_unserializer.c" yy25: yych = *++YYCURSOR; if (yych <= ',') { @@ -792,7 +796,7 @@ yy27: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 675 "ext/standard/var_unserializer.re" +#line 678 "ext/standard/var_unserializer.re" { INIT_PZVAL(*rval); @@ -800,7 +804,7 @@ yy27: return object_common2(UNSERIALIZE_PASSTHRU, object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR)); } -#line 804 "ext/standard/var_unserializer.c" +#line 808 "ext/standard/var_unserializer.c" yy32: yych = *++YYCURSOR; if (yych == '+') goto yy33; @@ -821,7 +825,7 @@ yy34: yych = *++YYCURSOR; if (yych != '{') goto yy18; ++YYCURSOR; -#line 655 "ext/standard/var_unserializer.re" +#line 658 "ext/standard/var_unserializer.re" { long elements = parse_iv(start + 2); /* use iv() not uiv() in order to check data range */ @@ -841,7 +845,7 @@ yy34: return finish_nested_data(UNSERIALIZE_PASSTHRU); } -#line 845 "ext/standard/var_unserializer.c" +#line 849 "ext/standard/var_unserializer.c" yy39: yych = *++YYCURSOR; if (yych == '+') goto yy40; @@ -862,7 +866,7 @@ yy41: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 626 "ext/standard/var_unserializer.re" +#line 629 "ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; @@ -891,7 +895,7 @@ yy41: ZVAL_STRINGL(*rval, str, len, 0); return 1; } -#line 895 "ext/standard/var_unserializer.c" +#line 899 "ext/standard/var_unserializer.c" yy46: yych = *++YYCURSOR; if (yych == '+') goto yy47; @@ -912,7 +916,7 @@ yy48: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 598 "ext/standard/var_unserializer.re" +#line 601 "ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; @@ -940,7 +944,7 @@ yy48: ZVAL_STRINGL(*rval, str, len, 1); return 1; } -#line 944 "ext/standard/var_unserializer.c" +#line 948 "ext/standard/var_unserializer.c" yy53: yych = *++YYCURSOR; if (yych <= '/') { @@ -1028,7 +1032,7 @@ yy61: } yy63: ++YYCURSOR; -#line 588 "ext/standard/var_unserializer.re" +#line 591 "ext/standard/var_unserializer.re" { #if SIZEOF_LONG == 4 use_double: @@ -1038,7 +1042,7 @@ use_double: ZVAL_DOUBLE(*rval, zend_strtod((const char *)start + 2, NULL)); return 1; } -#line 1042 "ext/standard/var_unserializer.c" +#line 1046 "ext/standard/var_unserializer.c" yy65: yych = *++YYCURSOR; if (yych <= ',') { @@ -1097,7 +1101,7 @@ yy73: yych = *++YYCURSOR; if (yych != ';') goto yy18; ++YYCURSOR; -#line 573 "ext/standard/var_unserializer.re" +#line 576 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); @@ -1112,7 +1116,7 @@ yy73: return 1; } -#line 1116 "ext/standard/var_unserializer.c" +#line 1120 "ext/standard/var_unserializer.c" yy76: yych = *++YYCURSOR; if (yych == 'N') goto yy73; @@ -1139,7 +1143,7 @@ yy79: if (yych <= '9') goto yy79; if (yych != ';') goto yy18; ++YYCURSOR; -#line 546 "ext/standard/var_unserializer.re" +#line 549 "ext/standard/var_unserializer.re" { #if SIZEOF_LONG == 4 int digits = YYCURSOR - start - 3; @@ -1166,7 +1170,7 @@ yy79: ZVAL_LONG(*rval, parse_iv(start + 2)); return 1; } -#line 1170 "ext/standard/var_unserializer.c" +#line 1174 "ext/standard/var_unserializer.c" yy83: yych = *++YYCURSOR; if (yych <= '/') goto yy18; @@ -1174,24 +1178,24 @@ yy83: yych = *++YYCURSOR; if (yych != ';') goto yy18; ++YYCURSOR; -#line 539 "ext/standard/var_unserializer.re" +#line 542 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_BOOL(*rval, parse_iv(start + 2)); return 1; } -#line 1185 "ext/standard/var_unserializer.c" +#line 1189 "ext/standard/var_unserializer.c" yy87: ++YYCURSOR; -#line 532 "ext/standard/var_unserializer.re" +#line 535 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_NULL(*rval); return 1; } -#line 1195 "ext/standard/var_unserializer.c" +#line 1199 "ext/standard/var_unserializer.c" yy89: yych = *++YYCURSOR; if (yych <= ',') { @@ -1214,7 +1218,7 @@ yy91: if (yych <= '9') goto yy91; if (yych != ';') goto yy18; ++YYCURSOR; -#line 509 "ext/standard/var_unserializer.re" +#line 512 "ext/standard/var_unserializer.re" { long id; @@ -1237,7 +1241,7 @@ yy91: return 1; } -#line 1241 "ext/standard/var_unserializer.c" +#line 1245 "ext/standard/var_unserializer.c" yy95: yych = *++YYCURSOR; if (yych <= ',') { @@ -1260,7 +1264,7 @@ yy97: if (yych <= '9') goto yy97; if (yych != ';') goto yy18; ++YYCURSOR; -#line 488 "ext/standard/var_unserializer.re" +#line 491 "ext/standard/var_unserializer.re" { long id; @@ -1281,9 +1285,9 @@ yy97: return 1; } -#line 1285 "ext/standard/var_unserializer.c" +#line 1289 "ext/standard/var_unserializer.c" } -#line 837 "ext/standard/var_unserializer.re" +#line 840 "ext/standard/var_unserializer.re" return 0;
null
null
null
5,990
static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce) { long datalen; datalen = parse_iv2((*p) + 2, p); (*p) += 2; if (datalen < 0 || (max - (*p)) <= datalen) { zend_error(E_WARNING, "Insufficient data for unserializing - %ld required, %ld present", datalen, (long)(max - (*p))); return 0; } if (ce->unserialize == NULL) { zend_error(E_WARNING, "Class %s has no unserializer", ce->name); object_init_ex(*rval, ce); } else if (ce->unserialize(rval, ce, (const unsigned char*)*p, datalen, (zend_unserialize_data *)var_hash TSRMLS_CC) != SUCCESS) { return 0; } (*p) += datalen; return finish_nested_data(UNSERIALIZE_PASSTHRU); }
Exec Code
0
static inline int object_custom(UNSERIALIZE_PARAMETER, zend_class_entry *ce) { long datalen; datalen = parse_iv2((*p) + 2, p); (*p) += 2; if (datalen < 0 || (max - (*p)) <= datalen) { zend_error(E_WARNING, "Insufficient data for unserializing - %ld required, %ld present", datalen, (long)(max - (*p))); return 0; } if (ce->unserialize == NULL) { zend_error(E_WARNING, "Class %s has no unserializer", ce->name); object_init_ex(*rval, ce); } else if (ce->unserialize(rval, ce, (const unsigned char*)*p, datalen, (zend_unserialize_data *)var_hash TSRMLS_CC) != SUCCESS) { return 0; } (*p) += datalen; return finish_nested_data(UNSERIALIZE_PASSTHRU); }
@@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 */ +/* Generated by re2c 0.13.7.5 on Thu Dec 11 19:26:19 2014 */ #line 1 "ext/standard/var_unserializer.re" /* +----------------------------------------------------------------------+ @@ -343,6 +343,9 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long } else { /* object properties should include no integers */ convert_to_string(key); + if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) { + var_push_dtor(var_hash, old_data); + } zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data, sizeof data, NULL); } @@ -480,7 +483,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) -#line 484 "ext/standard/var_unserializer.c" +#line 487 "ext/standard/var_unserializer.c" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -540,9 +543,9 @@ yy2: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy95; yy3: -#line 835 "ext/standard/var_unserializer.re" +#line 838 "ext/standard/var_unserializer.re" { return 0; } -#line 546 "ext/standard/var_unserializer.c" +#line 549 "ext/standard/var_unserializer.c" yy4: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy89; @@ -585,13 +588,13 @@ yy13: goto yy3; yy14: ++YYCURSOR; -#line 829 "ext/standard/var_unserializer.re" +#line 832 "ext/standard/var_unserializer.re" { /* this is the case where we have less data than planned */ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unexpected end of serialized data"); return 0; /* not sure if it should be 0 or 1 here? */ } -#line 595 "ext/standard/var_unserializer.c" +#line 598 "ext/standard/var_unserializer.c" yy16: yych = *++YYCURSOR; goto yy3; @@ -617,11 +620,12 @@ yy20: if (yybm[0+yych] & 128) { goto yy20; } - if (yych != ':') goto yy18; + if (yych <= '/') goto yy18; + if (yych >= ';') goto yy18; yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 683 "ext/standard/var_unserializer.re" +#line 686 "ext/standard/var_unserializer.re" { size_t len, len2, len3, maxlen; long elements; @@ -767,7 +771,7 @@ yy20: return object_common2(UNSERIALIZE_PASSTHRU, elements); } -#line 771 "ext/standard/var_unserializer.c" +#line 775 "ext/standard/var_unserializer.c" yy25: yych = *++YYCURSOR; if (yych <= ',') { @@ -792,7 +796,7 @@ yy27: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 675 "ext/standard/var_unserializer.re" +#line 678 "ext/standard/var_unserializer.re" { INIT_PZVAL(*rval); @@ -800,7 +804,7 @@ yy27: return object_common2(UNSERIALIZE_PASSTHRU, object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR)); } -#line 804 "ext/standard/var_unserializer.c" +#line 808 "ext/standard/var_unserializer.c" yy32: yych = *++YYCURSOR; if (yych == '+') goto yy33; @@ -821,7 +825,7 @@ yy34: yych = *++YYCURSOR; if (yych != '{') goto yy18; ++YYCURSOR; -#line 655 "ext/standard/var_unserializer.re" +#line 658 "ext/standard/var_unserializer.re" { long elements = parse_iv(start + 2); /* use iv() not uiv() in order to check data range */ @@ -841,7 +845,7 @@ yy34: return finish_nested_data(UNSERIALIZE_PASSTHRU); } -#line 845 "ext/standard/var_unserializer.c" +#line 849 "ext/standard/var_unserializer.c" yy39: yych = *++YYCURSOR; if (yych == '+') goto yy40; @@ -862,7 +866,7 @@ yy41: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 626 "ext/standard/var_unserializer.re" +#line 629 "ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; @@ -891,7 +895,7 @@ yy41: ZVAL_STRINGL(*rval, str, len, 0); return 1; } -#line 895 "ext/standard/var_unserializer.c" +#line 899 "ext/standard/var_unserializer.c" yy46: yych = *++YYCURSOR; if (yych == '+') goto yy47; @@ -912,7 +916,7 @@ yy48: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 598 "ext/standard/var_unserializer.re" +#line 601 "ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; @@ -940,7 +944,7 @@ yy48: ZVAL_STRINGL(*rval, str, len, 1); return 1; } -#line 944 "ext/standard/var_unserializer.c" +#line 948 "ext/standard/var_unserializer.c" yy53: yych = *++YYCURSOR; if (yych <= '/') { @@ -1028,7 +1032,7 @@ yy61: } yy63: ++YYCURSOR; -#line 588 "ext/standard/var_unserializer.re" +#line 591 "ext/standard/var_unserializer.re" { #if SIZEOF_LONG == 4 use_double: @@ -1038,7 +1042,7 @@ use_double: ZVAL_DOUBLE(*rval, zend_strtod((const char *)start + 2, NULL)); return 1; } -#line 1042 "ext/standard/var_unserializer.c" +#line 1046 "ext/standard/var_unserializer.c" yy65: yych = *++YYCURSOR; if (yych <= ',') { @@ -1097,7 +1101,7 @@ yy73: yych = *++YYCURSOR; if (yych != ';') goto yy18; ++YYCURSOR; -#line 573 "ext/standard/var_unserializer.re" +#line 576 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); @@ -1112,7 +1116,7 @@ yy73: return 1; } -#line 1116 "ext/standard/var_unserializer.c" +#line 1120 "ext/standard/var_unserializer.c" yy76: yych = *++YYCURSOR; if (yych == 'N') goto yy73; @@ -1139,7 +1143,7 @@ yy79: if (yych <= '9') goto yy79; if (yych != ';') goto yy18; ++YYCURSOR; -#line 546 "ext/standard/var_unserializer.re" +#line 549 "ext/standard/var_unserializer.re" { #if SIZEOF_LONG == 4 int digits = YYCURSOR - start - 3; @@ -1166,7 +1170,7 @@ yy79: ZVAL_LONG(*rval, parse_iv(start + 2)); return 1; } -#line 1170 "ext/standard/var_unserializer.c" +#line 1174 "ext/standard/var_unserializer.c" yy83: yych = *++YYCURSOR; if (yych <= '/') goto yy18; @@ -1174,24 +1178,24 @@ yy83: yych = *++YYCURSOR; if (yych != ';') goto yy18; ++YYCURSOR; -#line 539 "ext/standard/var_unserializer.re" +#line 542 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_BOOL(*rval, parse_iv(start + 2)); return 1; } -#line 1185 "ext/standard/var_unserializer.c" +#line 1189 "ext/standard/var_unserializer.c" yy87: ++YYCURSOR; -#line 532 "ext/standard/var_unserializer.re" +#line 535 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_NULL(*rval); return 1; } -#line 1195 "ext/standard/var_unserializer.c" +#line 1199 "ext/standard/var_unserializer.c" yy89: yych = *++YYCURSOR; if (yych <= ',') { @@ -1214,7 +1218,7 @@ yy91: if (yych <= '9') goto yy91; if (yych != ';') goto yy18; ++YYCURSOR; -#line 509 "ext/standard/var_unserializer.re" +#line 512 "ext/standard/var_unserializer.re" { long id; @@ -1237,7 +1241,7 @@ yy91: return 1; } -#line 1241 "ext/standard/var_unserializer.c" +#line 1245 "ext/standard/var_unserializer.c" yy95: yych = *++YYCURSOR; if (yych <= ',') { @@ -1260,7 +1264,7 @@ yy97: if (yych <= '9') goto yy97; if (yych != ';') goto yy18; ++YYCURSOR; -#line 488 "ext/standard/var_unserializer.re" +#line 491 "ext/standard/var_unserializer.re" { long id; @@ -1281,9 +1285,9 @@ yy97: return 1; } -#line 1285 "ext/standard/var_unserializer.c" +#line 1289 "ext/standard/var_unserializer.c" } -#line 837 "ext/standard/var_unserializer.re" +#line 840 "ext/standard/var_unserializer.re" return 0;
null
null
null
5,991
static inline long parse_iv2(const unsigned char *p, const unsigned char **q) { char cursor; long result = 0; int neg = 0; switch (*p) { case '-': neg++; /* fall-through */ case '+': p++; } while (1) { cursor = (char)*p; if (cursor >= '0' && cursor <= '9') { result = result * 10 + (size_t)(cursor - (unsigned char)'0'); } else { break; } p++; } if (q) *q = p; if (neg) return -result; return result; }
Exec Code
0
static inline long parse_iv2(const unsigned char *p, const unsigned char **q) { char cursor; long result = 0; int neg = 0; switch (*p) { case '-': neg++; /* fall-through */ case '+': p++; } while (1) { cursor = (char)*p; if (cursor >= '0' && cursor <= '9') { result = result * 10 + (size_t)(cursor - (unsigned char)'0'); } else { break; } p++; } if (q) *q = p; if (neg) return -result; return result; }
@@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 */ +/* Generated by re2c 0.13.7.5 on Thu Dec 11 19:26:19 2014 */ #line 1 "ext/standard/var_unserializer.re" /* +----------------------------------------------------------------------+ @@ -343,6 +343,9 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long } else { /* object properties should include no integers */ convert_to_string(key); + if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) { + var_push_dtor(var_hash, old_data); + } zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data, sizeof data, NULL); } @@ -480,7 +483,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) -#line 484 "ext/standard/var_unserializer.c" +#line 487 "ext/standard/var_unserializer.c" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -540,9 +543,9 @@ yy2: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy95; yy3: -#line 835 "ext/standard/var_unserializer.re" +#line 838 "ext/standard/var_unserializer.re" { return 0; } -#line 546 "ext/standard/var_unserializer.c" +#line 549 "ext/standard/var_unserializer.c" yy4: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy89; @@ -585,13 +588,13 @@ yy13: goto yy3; yy14: ++YYCURSOR; -#line 829 "ext/standard/var_unserializer.re" +#line 832 "ext/standard/var_unserializer.re" { /* this is the case where we have less data than planned */ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unexpected end of serialized data"); return 0; /* not sure if it should be 0 or 1 here? */ } -#line 595 "ext/standard/var_unserializer.c" +#line 598 "ext/standard/var_unserializer.c" yy16: yych = *++YYCURSOR; goto yy3; @@ -617,11 +620,12 @@ yy20: if (yybm[0+yych] & 128) { goto yy20; } - if (yych != ':') goto yy18; + if (yych <= '/') goto yy18; + if (yych >= ';') goto yy18; yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 683 "ext/standard/var_unserializer.re" +#line 686 "ext/standard/var_unserializer.re" { size_t len, len2, len3, maxlen; long elements; @@ -767,7 +771,7 @@ yy20: return object_common2(UNSERIALIZE_PASSTHRU, elements); } -#line 771 "ext/standard/var_unserializer.c" +#line 775 "ext/standard/var_unserializer.c" yy25: yych = *++YYCURSOR; if (yych <= ',') { @@ -792,7 +796,7 @@ yy27: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 675 "ext/standard/var_unserializer.re" +#line 678 "ext/standard/var_unserializer.re" { INIT_PZVAL(*rval); @@ -800,7 +804,7 @@ yy27: return object_common2(UNSERIALIZE_PASSTHRU, object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR)); } -#line 804 "ext/standard/var_unserializer.c" +#line 808 "ext/standard/var_unserializer.c" yy32: yych = *++YYCURSOR; if (yych == '+') goto yy33; @@ -821,7 +825,7 @@ yy34: yych = *++YYCURSOR; if (yych != '{') goto yy18; ++YYCURSOR; -#line 655 "ext/standard/var_unserializer.re" +#line 658 "ext/standard/var_unserializer.re" { long elements = parse_iv(start + 2); /* use iv() not uiv() in order to check data range */ @@ -841,7 +845,7 @@ yy34: return finish_nested_data(UNSERIALIZE_PASSTHRU); } -#line 845 "ext/standard/var_unserializer.c" +#line 849 "ext/standard/var_unserializer.c" yy39: yych = *++YYCURSOR; if (yych == '+') goto yy40; @@ -862,7 +866,7 @@ yy41: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 626 "ext/standard/var_unserializer.re" +#line 629 "ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; @@ -891,7 +895,7 @@ yy41: ZVAL_STRINGL(*rval, str, len, 0); return 1; } -#line 895 "ext/standard/var_unserializer.c" +#line 899 "ext/standard/var_unserializer.c" yy46: yych = *++YYCURSOR; if (yych == '+') goto yy47; @@ -912,7 +916,7 @@ yy48: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 598 "ext/standard/var_unserializer.re" +#line 601 "ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; @@ -940,7 +944,7 @@ yy48: ZVAL_STRINGL(*rval, str, len, 1); return 1; } -#line 944 "ext/standard/var_unserializer.c" +#line 948 "ext/standard/var_unserializer.c" yy53: yych = *++YYCURSOR; if (yych <= '/') { @@ -1028,7 +1032,7 @@ yy61: } yy63: ++YYCURSOR; -#line 588 "ext/standard/var_unserializer.re" +#line 591 "ext/standard/var_unserializer.re" { #if SIZEOF_LONG == 4 use_double: @@ -1038,7 +1042,7 @@ use_double: ZVAL_DOUBLE(*rval, zend_strtod((const char *)start + 2, NULL)); return 1; } -#line 1042 "ext/standard/var_unserializer.c" +#line 1046 "ext/standard/var_unserializer.c" yy65: yych = *++YYCURSOR; if (yych <= ',') { @@ -1097,7 +1101,7 @@ yy73: yych = *++YYCURSOR; if (yych != ';') goto yy18; ++YYCURSOR; -#line 573 "ext/standard/var_unserializer.re" +#line 576 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); @@ -1112,7 +1116,7 @@ yy73: return 1; } -#line 1116 "ext/standard/var_unserializer.c" +#line 1120 "ext/standard/var_unserializer.c" yy76: yych = *++YYCURSOR; if (yych == 'N') goto yy73; @@ -1139,7 +1143,7 @@ yy79: if (yych <= '9') goto yy79; if (yych != ';') goto yy18; ++YYCURSOR; -#line 546 "ext/standard/var_unserializer.re" +#line 549 "ext/standard/var_unserializer.re" { #if SIZEOF_LONG == 4 int digits = YYCURSOR - start - 3; @@ -1166,7 +1170,7 @@ yy79: ZVAL_LONG(*rval, parse_iv(start + 2)); return 1; } -#line 1170 "ext/standard/var_unserializer.c" +#line 1174 "ext/standard/var_unserializer.c" yy83: yych = *++YYCURSOR; if (yych <= '/') goto yy18; @@ -1174,24 +1178,24 @@ yy83: yych = *++YYCURSOR; if (yych != ';') goto yy18; ++YYCURSOR; -#line 539 "ext/standard/var_unserializer.re" +#line 542 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_BOOL(*rval, parse_iv(start + 2)); return 1; } -#line 1185 "ext/standard/var_unserializer.c" +#line 1189 "ext/standard/var_unserializer.c" yy87: ++YYCURSOR; -#line 532 "ext/standard/var_unserializer.re" +#line 535 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_NULL(*rval); return 1; } -#line 1195 "ext/standard/var_unserializer.c" +#line 1199 "ext/standard/var_unserializer.c" yy89: yych = *++YYCURSOR; if (yych <= ',') { @@ -1214,7 +1218,7 @@ yy91: if (yych <= '9') goto yy91; if (yych != ';') goto yy18; ++YYCURSOR; -#line 509 "ext/standard/var_unserializer.re" +#line 512 "ext/standard/var_unserializer.re" { long id; @@ -1237,7 +1241,7 @@ yy91: return 1; } -#line 1241 "ext/standard/var_unserializer.c" +#line 1245 "ext/standard/var_unserializer.c" yy95: yych = *++YYCURSOR; if (yych <= ',') { @@ -1260,7 +1264,7 @@ yy97: if (yych <= '9') goto yy97; if (yych != ';') goto yy18; ++YYCURSOR; -#line 488 "ext/standard/var_unserializer.re" +#line 491 "ext/standard/var_unserializer.re" { long id; @@ -1281,9 +1285,9 @@ yy97: return 1; } -#line 1285 "ext/standard/var_unserializer.c" +#line 1289 "ext/standard/var_unserializer.c" } -#line 837 "ext/standard/var_unserializer.re" +#line 840 "ext/standard/var_unserializer.re" return 0;
null
null
null
5,992
static inline size_t parse_uiv(const unsigned char *p) { unsigned char cursor; size_t result = 0; if (*p == '+') { p++; } while (1) { cursor = *p; if (cursor >= '0' && cursor <= '9') { result = result * 10 + (size_t)(cursor - (unsigned char)'0'); } else { break; } p++; } return result; }
Exec Code
0
static inline size_t parse_uiv(const unsigned char *p) { unsigned char cursor; size_t result = 0; if (*p == '+') { p++; } while (1) { cursor = *p; if (cursor >= '0' && cursor <= '9') { result = result * 10 + (size_t)(cursor - (unsigned char)'0'); } else { break; } p++; } return result; }
@@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 */ +/* Generated by re2c 0.13.7.5 on Thu Dec 11 19:26:19 2014 */ #line 1 "ext/standard/var_unserializer.re" /* +----------------------------------------------------------------------+ @@ -343,6 +343,9 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long } else { /* object properties should include no integers */ convert_to_string(key); + if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) { + var_push_dtor(var_hash, old_data); + } zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data, sizeof data, NULL); } @@ -480,7 +483,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) -#line 484 "ext/standard/var_unserializer.c" +#line 487 "ext/standard/var_unserializer.c" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -540,9 +543,9 @@ yy2: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy95; yy3: -#line 835 "ext/standard/var_unserializer.re" +#line 838 "ext/standard/var_unserializer.re" { return 0; } -#line 546 "ext/standard/var_unserializer.c" +#line 549 "ext/standard/var_unserializer.c" yy4: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy89; @@ -585,13 +588,13 @@ yy13: goto yy3; yy14: ++YYCURSOR; -#line 829 "ext/standard/var_unserializer.re" +#line 832 "ext/standard/var_unserializer.re" { /* this is the case where we have less data than planned */ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unexpected end of serialized data"); return 0; /* not sure if it should be 0 or 1 here? */ } -#line 595 "ext/standard/var_unserializer.c" +#line 598 "ext/standard/var_unserializer.c" yy16: yych = *++YYCURSOR; goto yy3; @@ -617,11 +620,12 @@ yy20: if (yybm[0+yych] & 128) { goto yy20; } - if (yych != ':') goto yy18; + if (yych <= '/') goto yy18; + if (yych >= ';') goto yy18; yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 683 "ext/standard/var_unserializer.re" +#line 686 "ext/standard/var_unserializer.re" { size_t len, len2, len3, maxlen; long elements; @@ -767,7 +771,7 @@ yy20: return object_common2(UNSERIALIZE_PASSTHRU, elements); } -#line 771 "ext/standard/var_unserializer.c" +#line 775 "ext/standard/var_unserializer.c" yy25: yych = *++YYCURSOR; if (yych <= ',') { @@ -792,7 +796,7 @@ yy27: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 675 "ext/standard/var_unserializer.re" +#line 678 "ext/standard/var_unserializer.re" { INIT_PZVAL(*rval); @@ -800,7 +804,7 @@ yy27: return object_common2(UNSERIALIZE_PASSTHRU, object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR)); } -#line 804 "ext/standard/var_unserializer.c" +#line 808 "ext/standard/var_unserializer.c" yy32: yych = *++YYCURSOR; if (yych == '+') goto yy33; @@ -821,7 +825,7 @@ yy34: yych = *++YYCURSOR; if (yych != '{') goto yy18; ++YYCURSOR; -#line 655 "ext/standard/var_unserializer.re" +#line 658 "ext/standard/var_unserializer.re" { long elements = parse_iv(start + 2); /* use iv() not uiv() in order to check data range */ @@ -841,7 +845,7 @@ yy34: return finish_nested_data(UNSERIALIZE_PASSTHRU); } -#line 845 "ext/standard/var_unserializer.c" +#line 849 "ext/standard/var_unserializer.c" yy39: yych = *++YYCURSOR; if (yych == '+') goto yy40; @@ -862,7 +866,7 @@ yy41: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 626 "ext/standard/var_unserializer.re" +#line 629 "ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; @@ -891,7 +895,7 @@ yy41: ZVAL_STRINGL(*rval, str, len, 0); return 1; } -#line 895 "ext/standard/var_unserializer.c" +#line 899 "ext/standard/var_unserializer.c" yy46: yych = *++YYCURSOR; if (yych == '+') goto yy47; @@ -912,7 +916,7 @@ yy48: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 598 "ext/standard/var_unserializer.re" +#line 601 "ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; @@ -940,7 +944,7 @@ yy48: ZVAL_STRINGL(*rval, str, len, 1); return 1; } -#line 944 "ext/standard/var_unserializer.c" +#line 948 "ext/standard/var_unserializer.c" yy53: yych = *++YYCURSOR; if (yych <= '/') { @@ -1028,7 +1032,7 @@ yy61: } yy63: ++YYCURSOR; -#line 588 "ext/standard/var_unserializer.re" +#line 591 "ext/standard/var_unserializer.re" { #if SIZEOF_LONG == 4 use_double: @@ -1038,7 +1042,7 @@ use_double: ZVAL_DOUBLE(*rval, zend_strtod((const char *)start + 2, NULL)); return 1; } -#line 1042 "ext/standard/var_unserializer.c" +#line 1046 "ext/standard/var_unserializer.c" yy65: yych = *++YYCURSOR; if (yych <= ',') { @@ -1097,7 +1101,7 @@ yy73: yych = *++YYCURSOR; if (yych != ';') goto yy18; ++YYCURSOR; -#line 573 "ext/standard/var_unserializer.re" +#line 576 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); @@ -1112,7 +1116,7 @@ yy73: return 1; } -#line 1116 "ext/standard/var_unserializer.c" +#line 1120 "ext/standard/var_unserializer.c" yy76: yych = *++YYCURSOR; if (yych == 'N') goto yy73; @@ -1139,7 +1143,7 @@ yy79: if (yych <= '9') goto yy79; if (yych != ';') goto yy18; ++YYCURSOR; -#line 546 "ext/standard/var_unserializer.re" +#line 549 "ext/standard/var_unserializer.re" { #if SIZEOF_LONG == 4 int digits = YYCURSOR - start - 3; @@ -1166,7 +1170,7 @@ yy79: ZVAL_LONG(*rval, parse_iv(start + 2)); return 1; } -#line 1170 "ext/standard/var_unserializer.c" +#line 1174 "ext/standard/var_unserializer.c" yy83: yych = *++YYCURSOR; if (yych <= '/') goto yy18; @@ -1174,24 +1178,24 @@ yy83: yych = *++YYCURSOR; if (yych != ';') goto yy18; ++YYCURSOR; -#line 539 "ext/standard/var_unserializer.re" +#line 542 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_BOOL(*rval, parse_iv(start + 2)); return 1; } -#line 1185 "ext/standard/var_unserializer.c" +#line 1189 "ext/standard/var_unserializer.c" yy87: ++YYCURSOR; -#line 532 "ext/standard/var_unserializer.re" +#line 535 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_NULL(*rval); return 1; } -#line 1195 "ext/standard/var_unserializer.c" +#line 1199 "ext/standard/var_unserializer.c" yy89: yych = *++YYCURSOR; if (yych <= ',') { @@ -1214,7 +1218,7 @@ yy91: if (yych <= '9') goto yy91; if (yych != ';') goto yy18; ++YYCURSOR; -#line 509 "ext/standard/var_unserializer.re" +#line 512 "ext/standard/var_unserializer.re" { long id; @@ -1237,7 +1241,7 @@ yy91: return 1; } -#line 1241 "ext/standard/var_unserializer.c" +#line 1245 "ext/standard/var_unserializer.c" yy95: yych = *++YYCURSOR; if (yych <= ',') { @@ -1260,7 +1264,7 @@ yy97: if (yych <= '9') goto yy97; if (yych != ';') goto yy18; ++YYCURSOR; -#line 488 "ext/standard/var_unserializer.re" +#line 491 "ext/standard/var_unserializer.re" { long id; @@ -1281,9 +1285,9 @@ yy97: return 1; } -#line 1285 "ext/standard/var_unserializer.c" +#line 1289 "ext/standard/var_unserializer.c" } -#line 837 "ext/standard/var_unserializer.re" +#line 840 "ext/standard/var_unserializer.re" return 0;
null
null
null
5,993
static char *unserialize_str(const unsigned char **p, size_t *len, size_t maxlen) { size_t i, j; char *str = safe_emalloc(*len, 1, 1); unsigned char *end = *(unsigned char **)p+maxlen; if (end < *p) { efree(str); return NULL; } for (i = 0; i < *len; i++) { if (*p >= end) { efree(str); return NULL; } if (**p != '\\') { str[i] = (char)**p; } else { unsigned char ch = 0; for (j = 0; j < 2; j++) { (*p)++; if (**p >= '0' && **p <= '9') { ch = (ch << 4) + (**p -'0'); } else if (**p >= 'a' && **p <= 'f') { ch = (ch << 4) + (**p -'a'+10); } else if (**p >= 'A' && **p <= 'F') { ch = (ch << 4) + (**p -'A'+10); } else { efree(str); return NULL; } } str[i] = (char)ch; } (*p)++; } str[i] = 0; *len = i; return str; }
Exec Code
0
static char *unserialize_str(const unsigned char **p, size_t *len, size_t maxlen) { size_t i, j; char *str = safe_emalloc(*len, 1, 1); unsigned char *end = *(unsigned char **)p+maxlen; if (end < *p) { efree(str); return NULL; } for (i = 0; i < *len; i++) { if (*p >= end) { efree(str); return NULL; } if (**p != '\\') { str[i] = (char)**p; } else { unsigned char ch = 0; for (j = 0; j < 2; j++) { (*p)++; if (**p >= '0' && **p <= '9') { ch = (ch << 4) + (**p -'0'); } else if (**p >= 'a' && **p <= 'f') { ch = (ch << 4) + (**p -'a'+10); } else if (**p >= 'A' && **p <= 'F') { ch = (ch << 4) + (**p -'A'+10); } else { efree(str); return NULL; } } str[i] = (char)ch; } (*p)++; } str[i] = 0; *len = i; return str; }
@@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 */ +/* Generated by re2c 0.13.7.5 on Thu Dec 11 19:26:19 2014 */ #line 1 "ext/standard/var_unserializer.re" /* +----------------------------------------------------------------------+ @@ -343,6 +343,9 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long } else { /* object properties should include no integers */ convert_to_string(key); + if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) { + var_push_dtor(var_hash, old_data); + } zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data, sizeof data, NULL); } @@ -480,7 +483,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) -#line 484 "ext/standard/var_unserializer.c" +#line 487 "ext/standard/var_unserializer.c" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -540,9 +543,9 @@ yy2: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy95; yy3: -#line 835 "ext/standard/var_unserializer.re" +#line 838 "ext/standard/var_unserializer.re" { return 0; } -#line 546 "ext/standard/var_unserializer.c" +#line 549 "ext/standard/var_unserializer.c" yy4: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy89; @@ -585,13 +588,13 @@ yy13: goto yy3; yy14: ++YYCURSOR; -#line 829 "ext/standard/var_unserializer.re" +#line 832 "ext/standard/var_unserializer.re" { /* this is the case where we have less data than planned */ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unexpected end of serialized data"); return 0; /* not sure if it should be 0 or 1 here? */ } -#line 595 "ext/standard/var_unserializer.c" +#line 598 "ext/standard/var_unserializer.c" yy16: yych = *++YYCURSOR; goto yy3; @@ -617,11 +620,12 @@ yy20: if (yybm[0+yych] & 128) { goto yy20; } - if (yych != ':') goto yy18; + if (yych <= '/') goto yy18; + if (yych >= ';') goto yy18; yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 683 "ext/standard/var_unserializer.re" +#line 686 "ext/standard/var_unserializer.re" { size_t len, len2, len3, maxlen; long elements; @@ -767,7 +771,7 @@ yy20: return object_common2(UNSERIALIZE_PASSTHRU, elements); } -#line 771 "ext/standard/var_unserializer.c" +#line 775 "ext/standard/var_unserializer.c" yy25: yych = *++YYCURSOR; if (yych <= ',') { @@ -792,7 +796,7 @@ yy27: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 675 "ext/standard/var_unserializer.re" +#line 678 "ext/standard/var_unserializer.re" { INIT_PZVAL(*rval); @@ -800,7 +804,7 @@ yy27: return object_common2(UNSERIALIZE_PASSTHRU, object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR)); } -#line 804 "ext/standard/var_unserializer.c" +#line 808 "ext/standard/var_unserializer.c" yy32: yych = *++YYCURSOR; if (yych == '+') goto yy33; @@ -821,7 +825,7 @@ yy34: yych = *++YYCURSOR; if (yych != '{') goto yy18; ++YYCURSOR; -#line 655 "ext/standard/var_unserializer.re" +#line 658 "ext/standard/var_unserializer.re" { long elements = parse_iv(start + 2); /* use iv() not uiv() in order to check data range */ @@ -841,7 +845,7 @@ yy34: return finish_nested_data(UNSERIALIZE_PASSTHRU); } -#line 845 "ext/standard/var_unserializer.c" +#line 849 "ext/standard/var_unserializer.c" yy39: yych = *++YYCURSOR; if (yych == '+') goto yy40; @@ -862,7 +866,7 @@ yy41: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 626 "ext/standard/var_unserializer.re" +#line 629 "ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; @@ -891,7 +895,7 @@ yy41: ZVAL_STRINGL(*rval, str, len, 0); return 1; } -#line 895 "ext/standard/var_unserializer.c" +#line 899 "ext/standard/var_unserializer.c" yy46: yych = *++YYCURSOR; if (yych == '+') goto yy47; @@ -912,7 +916,7 @@ yy48: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 598 "ext/standard/var_unserializer.re" +#line 601 "ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; @@ -940,7 +944,7 @@ yy48: ZVAL_STRINGL(*rval, str, len, 1); return 1; } -#line 944 "ext/standard/var_unserializer.c" +#line 948 "ext/standard/var_unserializer.c" yy53: yych = *++YYCURSOR; if (yych <= '/') { @@ -1028,7 +1032,7 @@ yy61: } yy63: ++YYCURSOR; -#line 588 "ext/standard/var_unserializer.re" +#line 591 "ext/standard/var_unserializer.re" { #if SIZEOF_LONG == 4 use_double: @@ -1038,7 +1042,7 @@ use_double: ZVAL_DOUBLE(*rval, zend_strtod((const char *)start + 2, NULL)); return 1; } -#line 1042 "ext/standard/var_unserializer.c" +#line 1046 "ext/standard/var_unserializer.c" yy65: yych = *++YYCURSOR; if (yych <= ',') { @@ -1097,7 +1101,7 @@ yy73: yych = *++YYCURSOR; if (yych != ';') goto yy18; ++YYCURSOR; -#line 573 "ext/standard/var_unserializer.re" +#line 576 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); @@ -1112,7 +1116,7 @@ yy73: return 1; } -#line 1116 "ext/standard/var_unserializer.c" +#line 1120 "ext/standard/var_unserializer.c" yy76: yych = *++YYCURSOR; if (yych == 'N') goto yy73; @@ -1139,7 +1143,7 @@ yy79: if (yych <= '9') goto yy79; if (yych != ';') goto yy18; ++YYCURSOR; -#line 546 "ext/standard/var_unserializer.re" +#line 549 "ext/standard/var_unserializer.re" { #if SIZEOF_LONG == 4 int digits = YYCURSOR - start - 3; @@ -1166,7 +1170,7 @@ yy79: ZVAL_LONG(*rval, parse_iv(start + 2)); return 1; } -#line 1170 "ext/standard/var_unserializer.c" +#line 1174 "ext/standard/var_unserializer.c" yy83: yych = *++YYCURSOR; if (yych <= '/') goto yy18; @@ -1174,24 +1178,24 @@ yy83: yych = *++YYCURSOR; if (yych != ';') goto yy18; ++YYCURSOR; -#line 539 "ext/standard/var_unserializer.re" +#line 542 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_BOOL(*rval, parse_iv(start + 2)); return 1; } -#line 1185 "ext/standard/var_unserializer.c" +#line 1189 "ext/standard/var_unserializer.c" yy87: ++YYCURSOR; -#line 532 "ext/standard/var_unserializer.re" +#line 535 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_NULL(*rval); return 1; } -#line 1195 "ext/standard/var_unserializer.c" +#line 1199 "ext/standard/var_unserializer.c" yy89: yych = *++YYCURSOR; if (yych <= ',') { @@ -1214,7 +1218,7 @@ yy91: if (yych <= '9') goto yy91; if (yych != ';') goto yy18; ++YYCURSOR; -#line 509 "ext/standard/var_unserializer.re" +#line 512 "ext/standard/var_unserializer.re" { long id; @@ -1237,7 +1241,7 @@ yy91: return 1; } -#line 1241 "ext/standard/var_unserializer.c" +#line 1245 "ext/standard/var_unserializer.c" yy95: yych = *++YYCURSOR; if (yych <= ',') { @@ -1260,7 +1264,7 @@ yy97: if (yych <= '9') goto yy97; if (yych != ';') goto yy18; ++YYCURSOR; -#line 488 "ext/standard/var_unserializer.re" +#line 491 "ext/standard/var_unserializer.re" { long id; @@ -1281,9 +1285,9 @@ yy97: return 1; } -#line 1285 "ext/standard/var_unserializer.c" +#line 1289 "ext/standard/var_unserializer.c" } -#line 837 "ext/standard/var_unserializer.re" +#line 840 "ext/standard/var_unserializer.re" return 0;
null
null
null
5,994
PHPAPI void var_destroy(php_unserialize_data_t *var_hashx) { void *next; long i; var_entries *var_hash = (*var_hashx)->first; #if VAR_ENTRIES_DBG fprintf(stderr, "var_destroy(%ld)\n", var_hash?var_hash->used_slots:-1L); #endif while (var_hash) { next = var_hash->next; efree(var_hash); var_hash = next; } var_hash = (*var_hashx)->first_dtor; while (var_hash) { for (i = 0; i < var_hash->used_slots; i++) { zval_ptr_dtor(&var_hash->data[i]); } next = var_hash->next; efree(var_hash); var_hash = next; } }
Exec Code
0
PHPAPI void var_destroy(php_unserialize_data_t *var_hashx) { void *next; long i; var_entries *var_hash = (*var_hashx)->first; #if VAR_ENTRIES_DBG fprintf(stderr, "var_destroy(%ld)\n", var_hash?var_hash->used_slots:-1L); #endif while (var_hash) { next = var_hash->next; efree(var_hash); var_hash = next; } var_hash = (*var_hashx)->first_dtor; while (var_hash) { for (i = 0; i < var_hash->used_slots; i++) { zval_ptr_dtor(&var_hash->data[i]); } next = var_hash->next; efree(var_hash); var_hash = next; } }
@@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 */ +/* Generated by re2c 0.13.7.5 on Thu Dec 11 19:26:19 2014 */ #line 1 "ext/standard/var_unserializer.re" /* +----------------------------------------------------------------------+ @@ -343,6 +343,9 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long } else { /* object properties should include no integers */ convert_to_string(key); + if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) { + var_push_dtor(var_hash, old_data); + } zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data, sizeof data, NULL); } @@ -480,7 +483,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) -#line 484 "ext/standard/var_unserializer.c" +#line 487 "ext/standard/var_unserializer.c" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -540,9 +543,9 @@ yy2: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy95; yy3: -#line 835 "ext/standard/var_unserializer.re" +#line 838 "ext/standard/var_unserializer.re" { return 0; } -#line 546 "ext/standard/var_unserializer.c" +#line 549 "ext/standard/var_unserializer.c" yy4: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy89; @@ -585,13 +588,13 @@ yy13: goto yy3; yy14: ++YYCURSOR; -#line 829 "ext/standard/var_unserializer.re" +#line 832 "ext/standard/var_unserializer.re" { /* this is the case where we have less data than planned */ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unexpected end of serialized data"); return 0; /* not sure if it should be 0 or 1 here? */ } -#line 595 "ext/standard/var_unserializer.c" +#line 598 "ext/standard/var_unserializer.c" yy16: yych = *++YYCURSOR; goto yy3; @@ -617,11 +620,12 @@ yy20: if (yybm[0+yych] & 128) { goto yy20; } - if (yych != ':') goto yy18; + if (yych <= '/') goto yy18; + if (yych >= ';') goto yy18; yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 683 "ext/standard/var_unserializer.re" +#line 686 "ext/standard/var_unserializer.re" { size_t len, len2, len3, maxlen; long elements; @@ -767,7 +771,7 @@ yy20: return object_common2(UNSERIALIZE_PASSTHRU, elements); } -#line 771 "ext/standard/var_unserializer.c" +#line 775 "ext/standard/var_unserializer.c" yy25: yych = *++YYCURSOR; if (yych <= ',') { @@ -792,7 +796,7 @@ yy27: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 675 "ext/standard/var_unserializer.re" +#line 678 "ext/standard/var_unserializer.re" { INIT_PZVAL(*rval); @@ -800,7 +804,7 @@ yy27: return object_common2(UNSERIALIZE_PASSTHRU, object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR)); } -#line 804 "ext/standard/var_unserializer.c" +#line 808 "ext/standard/var_unserializer.c" yy32: yych = *++YYCURSOR; if (yych == '+') goto yy33; @@ -821,7 +825,7 @@ yy34: yych = *++YYCURSOR; if (yych != '{') goto yy18; ++YYCURSOR; -#line 655 "ext/standard/var_unserializer.re" +#line 658 "ext/standard/var_unserializer.re" { long elements = parse_iv(start + 2); /* use iv() not uiv() in order to check data range */ @@ -841,7 +845,7 @@ yy34: return finish_nested_data(UNSERIALIZE_PASSTHRU); } -#line 845 "ext/standard/var_unserializer.c" +#line 849 "ext/standard/var_unserializer.c" yy39: yych = *++YYCURSOR; if (yych == '+') goto yy40; @@ -862,7 +866,7 @@ yy41: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 626 "ext/standard/var_unserializer.re" +#line 629 "ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; @@ -891,7 +895,7 @@ yy41: ZVAL_STRINGL(*rval, str, len, 0); return 1; } -#line 895 "ext/standard/var_unserializer.c" +#line 899 "ext/standard/var_unserializer.c" yy46: yych = *++YYCURSOR; if (yych == '+') goto yy47; @@ -912,7 +916,7 @@ yy48: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 598 "ext/standard/var_unserializer.re" +#line 601 "ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; @@ -940,7 +944,7 @@ yy48: ZVAL_STRINGL(*rval, str, len, 1); return 1; } -#line 944 "ext/standard/var_unserializer.c" +#line 948 "ext/standard/var_unserializer.c" yy53: yych = *++YYCURSOR; if (yych <= '/') { @@ -1028,7 +1032,7 @@ yy61: } yy63: ++YYCURSOR; -#line 588 "ext/standard/var_unserializer.re" +#line 591 "ext/standard/var_unserializer.re" { #if SIZEOF_LONG == 4 use_double: @@ -1038,7 +1042,7 @@ use_double: ZVAL_DOUBLE(*rval, zend_strtod((const char *)start + 2, NULL)); return 1; } -#line 1042 "ext/standard/var_unserializer.c" +#line 1046 "ext/standard/var_unserializer.c" yy65: yych = *++YYCURSOR; if (yych <= ',') { @@ -1097,7 +1101,7 @@ yy73: yych = *++YYCURSOR; if (yych != ';') goto yy18; ++YYCURSOR; -#line 573 "ext/standard/var_unserializer.re" +#line 576 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); @@ -1112,7 +1116,7 @@ yy73: return 1; } -#line 1116 "ext/standard/var_unserializer.c" +#line 1120 "ext/standard/var_unserializer.c" yy76: yych = *++YYCURSOR; if (yych == 'N') goto yy73; @@ -1139,7 +1143,7 @@ yy79: if (yych <= '9') goto yy79; if (yych != ';') goto yy18; ++YYCURSOR; -#line 546 "ext/standard/var_unserializer.re" +#line 549 "ext/standard/var_unserializer.re" { #if SIZEOF_LONG == 4 int digits = YYCURSOR - start - 3; @@ -1166,7 +1170,7 @@ yy79: ZVAL_LONG(*rval, parse_iv(start + 2)); return 1; } -#line 1170 "ext/standard/var_unserializer.c" +#line 1174 "ext/standard/var_unserializer.c" yy83: yych = *++YYCURSOR; if (yych <= '/') goto yy18; @@ -1174,24 +1178,24 @@ yy83: yych = *++YYCURSOR; if (yych != ';') goto yy18; ++YYCURSOR; -#line 539 "ext/standard/var_unserializer.re" +#line 542 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_BOOL(*rval, parse_iv(start + 2)); return 1; } -#line 1185 "ext/standard/var_unserializer.c" +#line 1189 "ext/standard/var_unserializer.c" yy87: ++YYCURSOR; -#line 532 "ext/standard/var_unserializer.re" +#line 535 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_NULL(*rval); return 1; } -#line 1195 "ext/standard/var_unserializer.c" +#line 1199 "ext/standard/var_unserializer.c" yy89: yych = *++YYCURSOR; if (yych <= ',') { @@ -1214,7 +1218,7 @@ yy91: if (yych <= '9') goto yy91; if (yych != ';') goto yy18; ++YYCURSOR; -#line 509 "ext/standard/var_unserializer.re" +#line 512 "ext/standard/var_unserializer.re" { long id; @@ -1237,7 +1241,7 @@ yy91: return 1; } -#line 1241 "ext/standard/var_unserializer.c" +#line 1245 "ext/standard/var_unserializer.c" yy95: yych = *++YYCURSOR; if (yych <= ',') { @@ -1260,7 +1264,7 @@ yy97: if (yych <= '9') goto yy97; if (yych != ';') goto yy18; ++YYCURSOR; -#line 488 "ext/standard/var_unserializer.re" +#line 491 "ext/standard/var_unserializer.re" { long id; @@ -1281,9 +1285,9 @@ yy97: return 1; } -#line 1285 "ext/standard/var_unserializer.c" +#line 1289 "ext/standard/var_unserializer.c" } -#line 837 "ext/standard/var_unserializer.re" +#line 840 "ext/standard/var_unserializer.re" return 0;
null
null
null
5,995
static inline void var_push(php_unserialize_data_t *var_hashx, zval **rval) { var_entries *var_hash = (*var_hashx)->last; #if VAR_ENTRIES_DBG fprintf(stderr, "var_push(%ld): %d\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(rval)); #endif if (!var_hash || var_hash->used_slots == VAR_ENTRIES_MAX) { var_hash = emalloc(sizeof(var_entries)); var_hash->used_slots = 0; var_hash->next = 0; if (!(*var_hashx)->first) { (*var_hashx)->first = var_hash; } else { ((var_entries *) (*var_hashx)->last)->next = var_hash; } (*var_hashx)->last = var_hash; } var_hash->data[var_hash->used_slots++] = *rval; }
Exec Code
0
static inline void var_push(php_unserialize_data_t *var_hashx, zval **rval) { var_entries *var_hash = (*var_hashx)->last; #if VAR_ENTRIES_DBG fprintf(stderr, "var_push(%ld): %d\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(rval)); #endif if (!var_hash || var_hash->used_slots == VAR_ENTRIES_MAX) { var_hash = emalloc(sizeof(var_entries)); var_hash->used_slots = 0; var_hash->next = 0; if (!(*var_hashx)->first) { (*var_hashx)->first = var_hash; } else { ((var_entries *) (*var_hashx)->last)->next = var_hash; } (*var_hashx)->last = var_hash; } var_hash->data[var_hash->used_slots++] = *rval; }
@@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 */ +/* Generated by re2c 0.13.7.5 on Thu Dec 11 19:26:19 2014 */ #line 1 "ext/standard/var_unserializer.re" /* +----------------------------------------------------------------------+ @@ -343,6 +343,9 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long } else { /* object properties should include no integers */ convert_to_string(key); + if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) { + var_push_dtor(var_hash, old_data); + } zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data, sizeof data, NULL); } @@ -480,7 +483,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) -#line 484 "ext/standard/var_unserializer.c" +#line 487 "ext/standard/var_unserializer.c" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -540,9 +543,9 @@ yy2: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy95; yy3: -#line 835 "ext/standard/var_unserializer.re" +#line 838 "ext/standard/var_unserializer.re" { return 0; } -#line 546 "ext/standard/var_unserializer.c" +#line 549 "ext/standard/var_unserializer.c" yy4: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy89; @@ -585,13 +588,13 @@ yy13: goto yy3; yy14: ++YYCURSOR; -#line 829 "ext/standard/var_unserializer.re" +#line 832 "ext/standard/var_unserializer.re" { /* this is the case where we have less data than planned */ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unexpected end of serialized data"); return 0; /* not sure if it should be 0 or 1 here? */ } -#line 595 "ext/standard/var_unserializer.c" +#line 598 "ext/standard/var_unserializer.c" yy16: yych = *++YYCURSOR; goto yy3; @@ -617,11 +620,12 @@ yy20: if (yybm[0+yych] & 128) { goto yy20; } - if (yych != ':') goto yy18; + if (yych <= '/') goto yy18; + if (yych >= ';') goto yy18; yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 683 "ext/standard/var_unserializer.re" +#line 686 "ext/standard/var_unserializer.re" { size_t len, len2, len3, maxlen; long elements; @@ -767,7 +771,7 @@ yy20: return object_common2(UNSERIALIZE_PASSTHRU, elements); } -#line 771 "ext/standard/var_unserializer.c" +#line 775 "ext/standard/var_unserializer.c" yy25: yych = *++YYCURSOR; if (yych <= ',') { @@ -792,7 +796,7 @@ yy27: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 675 "ext/standard/var_unserializer.re" +#line 678 "ext/standard/var_unserializer.re" { INIT_PZVAL(*rval); @@ -800,7 +804,7 @@ yy27: return object_common2(UNSERIALIZE_PASSTHRU, object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR)); } -#line 804 "ext/standard/var_unserializer.c" +#line 808 "ext/standard/var_unserializer.c" yy32: yych = *++YYCURSOR; if (yych == '+') goto yy33; @@ -821,7 +825,7 @@ yy34: yych = *++YYCURSOR; if (yych != '{') goto yy18; ++YYCURSOR; -#line 655 "ext/standard/var_unserializer.re" +#line 658 "ext/standard/var_unserializer.re" { long elements = parse_iv(start + 2); /* use iv() not uiv() in order to check data range */ @@ -841,7 +845,7 @@ yy34: return finish_nested_data(UNSERIALIZE_PASSTHRU); } -#line 845 "ext/standard/var_unserializer.c" +#line 849 "ext/standard/var_unserializer.c" yy39: yych = *++YYCURSOR; if (yych == '+') goto yy40; @@ -862,7 +866,7 @@ yy41: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 626 "ext/standard/var_unserializer.re" +#line 629 "ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; @@ -891,7 +895,7 @@ yy41: ZVAL_STRINGL(*rval, str, len, 0); return 1; } -#line 895 "ext/standard/var_unserializer.c" +#line 899 "ext/standard/var_unserializer.c" yy46: yych = *++YYCURSOR; if (yych == '+') goto yy47; @@ -912,7 +916,7 @@ yy48: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 598 "ext/standard/var_unserializer.re" +#line 601 "ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; @@ -940,7 +944,7 @@ yy48: ZVAL_STRINGL(*rval, str, len, 1); return 1; } -#line 944 "ext/standard/var_unserializer.c" +#line 948 "ext/standard/var_unserializer.c" yy53: yych = *++YYCURSOR; if (yych <= '/') { @@ -1028,7 +1032,7 @@ yy61: } yy63: ++YYCURSOR; -#line 588 "ext/standard/var_unserializer.re" +#line 591 "ext/standard/var_unserializer.re" { #if SIZEOF_LONG == 4 use_double: @@ -1038,7 +1042,7 @@ use_double: ZVAL_DOUBLE(*rval, zend_strtod((const char *)start + 2, NULL)); return 1; } -#line 1042 "ext/standard/var_unserializer.c" +#line 1046 "ext/standard/var_unserializer.c" yy65: yych = *++YYCURSOR; if (yych <= ',') { @@ -1097,7 +1101,7 @@ yy73: yych = *++YYCURSOR; if (yych != ';') goto yy18; ++YYCURSOR; -#line 573 "ext/standard/var_unserializer.re" +#line 576 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); @@ -1112,7 +1116,7 @@ yy73: return 1; } -#line 1116 "ext/standard/var_unserializer.c" +#line 1120 "ext/standard/var_unserializer.c" yy76: yych = *++YYCURSOR; if (yych == 'N') goto yy73; @@ -1139,7 +1143,7 @@ yy79: if (yych <= '9') goto yy79; if (yych != ';') goto yy18; ++YYCURSOR; -#line 546 "ext/standard/var_unserializer.re" +#line 549 "ext/standard/var_unserializer.re" { #if SIZEOF_LONG == 4 int digits = YYCURSOR - start - 3; @@ -1166,7 +1170,7 @@ yy79: ZVAL_LONG(*rval, parse_iv(start + 2)); return 1; } -#line 1170 "ext/standard/var_unserializer.c" +#line 1174 "ext/standard/var_unserializer.c" yy83: yych = *++YYCURSOR; if (yych <= '/') goto yy18; @@ -1174,24 +1178,24 @@ yy83: yych = *++YYCURSOR; if (yych != ';') goto yy18; ++YYCURSOR; -#line 539 "ext/standard/var_unserializer.re" +#line 542 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_BOOL(*rval, parse_iv(start + 2)); return 1; } -#line 1185 "ext/standard/var_unserializer.c" +#line 1189 "ext/standard/var_unserializer.c" yy87: ++YYCURSOR; -#line 532 "ext/standard/var_unserializer.re" +#line 535 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_NULL(*rval); return 1; } -#line 1195 "ext/standard/var_unserializer.c" +#line 1199 "ext/standard/var_unserializer.c" yy89: yych = *++YYCURSOR; if (yych <= ',') { @@ -1214,7 +1218,7 @@ yy91: if (yych <= '9') goto yy91; if (yych != ';') goto yy18; ++YYCURSOR; -#line 509 "ext/standard/var_unserializer.re" +#line 512 "ext/standard/var_unserializer.re" { long id; @@ -1237,7 +1241,7 @@ yy91: return 1; } -#line 1241 "ext/standard/var_unserializer.c" +#line 1245 "ext/standard/var_unserializer.c" yy95: yych = *++YYCURSOR; if (yych <= ',') { @@ -1260,7 +1264,7 @@ yy97: if (yych <= '9') goto yy97; if (yych != ';') goto yy18; ++YYCURSOR; -#line 488 "ext/standard/var_unserializer.re" +#line 491 "ext/standard/var_unserializer.re" { long id; @@ -1281,9 +1285,9 @@ yy97: return 1; } -#line 1285 "ext/standard/var_unserializer.c" +#line 1289 "ext/standard/var_unserializer.c" } -#line 837 "ext/standard/var_unserializer.re" +#line 840 "ext/standard/var_unserializer.re" return 0;
null
null
null
5,996
PHPAPI void var_push_dtor_no_addref(php_unserialize_data_t *var_hashx, zval **rval) { var_entries *var_hash = (*var_hashx)->last_dtor; #if VAR_ENTRIES_DBG fprintf(stderr, "var_push_dtor_no_addref(%ld): %d (%d)\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(rval), Z_REFCOUNT_PP(rval)); #endif if (!var_hash || var_hash->used_slots == VAR_ENTRIES_MAX) { var_hash = emalloc(sizeof(var_entries)); var_hash->used_slots = 0; var_hash->next = 0; if (!(*var_hashx)->first_dtor) { (*var_hashx)->first_dtor = var_hash; } else { ((var_entries *) (*var_hashx)->last_dtor)->next = var_hash; } (*var_hashx)->last_dtor = var_hash; } var_hash->data[var_hash->used_slots++] = *rval; }
Exec Code
0
PHPAPI void var_push_dtor_no_addref(php_unserialize_data_t *var_hashx, zval **rval) { var_entries *var_hash = (*var_hashx)->last_dtor; #if VAR_ENTRIES_DBG fprintf(stderr, "var_push_dtor_no_addref(%ld): %d (%d)\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(rval), Z_REFCOUNT_PP(rval)); #endif if (!var_hash || var_hash->used_slots == VAR_ENTRIES_MAX) { var_hash = emalloc(sizeof(var_entries)); var_hash->used_slots = 0; var_hash->next = 0; if (!(*var_hashx)->first_dtor) { (*var_hashx)->first_dtor = var_hash; } else { ((var_entries *) (*var_hashx)->last_dtor)->next = var_hash; } (*var_hashx)->last_dtor = var_hash; } var_hash->data[var_hash->used_slots++] = *rval; }
@@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 */ +/* Generated by re2c 0.13.7.5 on Thu Dec 11 19:26:19 2014 */ #line 1 "ext/standard/var_unserializer.re" /* +----------------------------------------------------------------------+ @@ -343,6 +343,9 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long } else { /* object properties should include no integers */ convert_to_string(key); + if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) { + var_push_dtor(var_hash, old_data); + } zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data, sizeof data, NULL); } @@ -480,7 +483,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) -#line 484 "ext/standard/var_unserializer.c" +#line 487 "ext/standard/var_unserializer.c" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -540,9 +543,9 @@ yy2: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy95; yy3: -#line 835 "ext/standard/var_unserializer.re" +#line 838 "ext/standard/var_unserializer.re" { return 0; } -#line 546 "ext/standard/var_unserializer.c" +#line 549 "ext/standard/var_unserializer.c" yy4: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy89; @@ -585,13 +588,13 @@ yy13: goto yy3; yy14: ++YYCURSOR; -#line 829 "ext/standard/var_unserializer.re" +#line 832 "ext/standard/var_unserializer.re" { /* this is the case where we have less data than planned */ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unexpected end of serialized data"); return 0; /* not sure if it should be 0 or 1 here? */ } -#line 595 "ext/standard/var_unserializer.c" +#line 598 "ext/standard/var_unserializer.c" yy16: yych = *++YYCURSOR; goto yy3; @@ -617,11 +620,12 @@ yy20: if (yybm[0+yych] & 128) { goto yy20; } - if (yych != ':') goto yy18; + if (yych <= '/') goto yy18; + if (yych >= ';') goto yy18; yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 683 "ext/standard/var_unserializer.re" +#line 686 "ext/standard/var_unserializer.re" { size_t len, len2, len3, maxlen; long elements; @@ -767,7 +771,7 @@ yy20: return object_common2(UNSERIALIZE_PASSTHRU, elements); } -#line 771 "ext/standard/var_unserializer.c" +#line 775 "ext/standard/var_unserializer.c" yy25: yych = *++YYCURSOR; if (yych <= ',') { @@ -792,7 +796,7 @@ yy27: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 675 "ext/standard/var_unserializer.re" +#line 678 "ext/standard/var_unserializer.re" { INIT_PZVAL(*rval); @@ -800,7 +804,7 @@ yy27: return object_common2(UNSERIALIZE_PASSTHRU, object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR)); } -#line 804 "ext/standard/var_unserializer.c" +#line 808 "ext/standard/var_unserializer.c" yy32: yych = *++YYCURSOR; if (yych == '+') goto yy33; @@ -821,7 +825,7 @@ yy34: yych = *++YYCURSOR; if (yych != '{') goto yy18; ++YYCURSOR; -#line 655 "ext/standard/var_unserializer.re" +#line 658 "ext/standard/var_unserializer.re" { long elements = parse_iv(start + 2); /* use iv() not uiv() in order to check data range */ @@ -841,7 +845,7 @@ yy34: return finish_nested_data(UNSERIALIZE_PASSTHRU); } -#line 845 "ext/standard/var_unserializer.c" +#line 849 "ext/standard/var_unserializer.c" yy39: yych = *++YYCURSOR; if (yych == '+') goto yy40; @@ -862,7 +866,7 @@ yy41: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 626 "ext/standard/var_unserializer.re" +#line 629 "ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; @@ -891,7 +895,7 @@ yy41: ZVAL_STRINGL(*rval, str, len, 0); return 1; } -#line 895 "ext/standard/var_unserializer.c" +#line 899 "ext/standard/var_unserializer.c" yy46: yych = *++YYCURSOR; if (yych == '+') goto yy47; @@ -912,7 +916,7 @@ yy48: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 598 "ext/standard/var_unserializer.re" +#line 601 "ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; @@ -940,7 +944,7 @@ yy48: ZVAL_STRINGL(*rval, str, len, 1); return 1; } -#line 944 "ext/standard/var_unserializer.c" +#line 948 "ext/standard/var_unserializer.c" yy53: yych = *++YYCURSOR; if (yych <= '/') { @@ -1028,7 +1032,7 @@ yy61: } yy63: ++YYCURSOR; -#line 588 "ext/standard/var_unserializer.re" +#line 591 "ext/standard/var_unserializer.re" { #if SIZEOF_LONG == 4 use_double: @@ -1038,7 +1042,7 @@ use_double: ZVAL_DOUBLE(*rval, zend_strtod((const char *)start + 2, NULL)); return 1; } -#line 1042 "ext/standard/var_unserializer.c" +#line 1046 "ext/standard/var_unserializer.c" yy65: yych = *++YYCURSOR; if (yych <= ',') { @@ -1097,7 +1101,7 @@ yy73: yych = *++YYCURSOR; if (yych != ';') goto yy18; ++YYCURSOR; -#line 573 "ext/standard/var_unserializer.re" +#line 576 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); @@ -1112,7 +1116,7 @@ yy73: return 1; } -#line 1116 "ext/standard/var_unserializer.c" +#line 1120 "ext/standard/var_unserializer.c" yy76: yych = *++YYCURSOR; if (yych == 'N') goto yy73; @@ -1139,7 +1143,7 @@ yy79: if (yych <= '9') goto yy79; if (yych != ';') goto yy18; ++YYCURSOR; -#line 546 "ext/standard/var_unserializer.re" +#line 549 "ext/standard/var_unserializer.re" { #if SIZEOF_LONG == 4 int digits = YYCURSOR - start - 3; @@ -1166,7 +1170,7 @@ yy79: ZVAL_LONG(*rval, parse_iv(start + 2)); return 1; } -#line 1170 "ext/standard/var_unserializer.c" +#line 1174 "ext/standard/var_unserializer.c" yy83: yych = *++YYCURSOR; if (yych <= '/') goto yy18; @@ -1174,24 +1178,24 @@ yy83: yych = *++YYCURSOR; if (yych != ';') goto yy18; ++YYCURSOR; -#line 539 "ext/standard/var_unserializer.re" +#line 542 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_BOOL(*rval, parse_iv(start + 2)); return 1; } -#line 1185 "ext/standard/var_unserializer.c" +#line 1189 "ext/standard/var_unserializer.c" yy87: ++YYCURSOR; -#line 532 "ext/standard/var_unserializer.re" +#line 535 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_NULL(*rval); return 1; } -#line 1195 "ext/standard/var_unserializer.c" +#line 1199 "ext/standard/var_unserializer.c" yy89: yych = *++YYCURSOR; if (yych <= ',') { @@ -1214,7 +1218,7 @@ yy91: if (yych <= '9') goto yy91; if (yych != ';') goto yy18; ++YYCURSOR; -#line 509 "ext/standard/var_unserializer.re" +#line 512 "ext/standard/var_unserializer.re" { long id; @@ -1237,7 +1241,7 @@ yy91: return 1; } -#line 1241 "ext/standard/var_unserializer.c" +#line 1245 "ext/standard/var_unserializer.c" yy95: yych = *++YYCURSOR; if (yych <= ',') { @@ -1260,7 +1264,7 @@ yy97: if (yych <= '9') goto yy97; if (yych != ';') goto yy18; ++YYCURSOR; -#line 488 "ext/standard/var_unserializer.re" +#line 491 "ext/standard/var_unserializer.re" { long id; @@ -1281,9 +1285,9 @@ yy97: return 1; } -#line 1285 "ext/standard/var_unserializer.c" +#line 1289 "ext/standard/var_unserializer.c" } -#line 837 "ext/standard/var_unserializer.re" +#line 840 "ext/standard/var_unserializer.re" return 0;
null
null
null
5,997
PHPAPI void var_replace(php_unserialize_data_t *var_hashx, zval *ozval, zval **nzval) { long i; var_entries *var_hash = (*var_hashx)->first; #if VAR_ENTRIES_DBG fprintf(stderr, "var_replace(%ld): %d\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(nzval)); #endif while (var_hash) { for (i = 0; i < var_hash->used_slots; i++) { if (var_hash->data[i] == ozval) { var_hash->data[i] = *nzval; /* do not break here */ } } var_hash = var_hash->next; } }
Exec Code
0
PHPAPI void var_replace(php_unserialize_data_t *var_hashx, zval *ozval, zval **nzval) { long i; var_entries *var_hash = (*var_hashx)->first; #if VAR_ENTRIES_DBG fprintf(stderr, "var_replace(%ld): %d\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(nzval)); #endif while (var_hash) { for (i = 0; i < var_hash->used_slots; i++) { if (var_hash->data[i] == ozval) { var_hash->data[i] = *nzval; /* do not break here */ } } var_hash = var_hash->next; } }
@@ -1,4 +1,4 @@ -/* Generated by re2c 0.13.5 */ +/* Generated by re2c 0.13.7.5 on Thu Dec 11 19:26:19 2014 */ #line 1 "ext/standard/var_unserializer.re" /* +----------------------------------------------------------------------+ @@ -343,6 +343,9 @@ static inline int process_nested_data(UNSERIALIZE_PARAMETER, HashTable *ht, long } else { /* object properties should include no integers */ convert_to_string(key); + if (zend_symtable_find(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, (void **)&old_data)==SUCCESS) { + var_push_dtor(var_hash, old_data); + } zend_hash_update(ht, Z_STRVAL_P(key), Z_STRLEN_P(key) + 1, &data, sizeof data, NULL); } @@ -480,7 +483,7 @@ PHPAPI int php_var_unserialize(UNSERIALIZE_PARAMETER) -#line 484 "ext/standard/var_unserializer.c" +#line 487 "ext/standard/var_unserializer.c" { YYCTYPE yych; static const unsigned char yybm[] = { @@ -540,9 +543,9 @@ yy2: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy95; yy3: -#line 835 "ext/standard/var_unserializer.re" +#line 838 "ext/standard/var_unserializer.re" { return 0; } -#line 546 "ext/standard/var_unserializer.c" +#line 549 "ext/standard/var_unserializer.c" yy4: yych = *(YYMARKER = ++YYCURSOR); if (yych == ':') goto yy89; @@ -585,13 +588,13 @@ yy13: goto yy3; yy14: ++YYCURSOR; -#line 829 "ext/standard/var_unserializer.re" +#line 832 "ext/standard/var_unserializer.re" { /* this is the case where we have less data than planned */ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unexpected end of serialized data"); return 0; /* not sure if it should be 0 or 1 here? */ } -#line 595 "ext/standard/var_unserializer.c" +#line 598 "ext/standard/var_unserializer.c" yy16: yych = *++YYCURSOR; goto yy3; @@ -617,11 +620,12 @@ yy20: if (yybm[0+yych] & 128) { goto yy20; } - if (yych != ':') goto yy18; + if (yych <= '/') goto yy18; + if (yych >= ';') goto yy18; yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 683 "ext/standard/var_unserializer.re" +#line 686 "ext/standard/var_unserializer.re" { size_t len, len2, len3, maxlen; long elements; @@ -767,7 +771,7 @@ yy20: return object_common2(UNSERIALIZE_PASSTHRU, elements); } -#line 771 "ext/standard/var_unserializer.c" +#line 775 "ext/standard/var_unserializer.c" yy25: yych = *++YYCURSOR; if (yych <= ',') { @@ -792,7 +796,7 @@ yy27: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 675 "ext/standard/var_unserializer.re" +#line 678 "ext/standard/var_unserializer.re" { INIT_PZVAL(*rval); @@ -800,7 +804,7 @@ yy27: return object_common2(UNSERIALIZE_PASSTHRU, object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR)); } -#line 804 "ext/standard/var_unserializer.c" +#line 808 "ext/standard/var_unserializer.c" yy32: yych = *++YYCURSOR; if (yych == '+') goto yy33; @@ -821,7 +825,7 @@ yy34: yych = *++YYCURSOR; if (yych != '{') goto yy18; ++YYCURSOR; -#line 655 "ext/standard/var_unserializer.re" +#line 658 "ext/standard/var_unserializer.re" { long elements = parse_iv(start + 2); /* use iv() not uiv() in order to check data range */ @@ -841,7 +845,7 @@ yy34: return finish_nested_data(UNSERIALIZE_PASSTHRU); } -#line 845 "ext/standard/var_unserializer.c" +#line 849 "ext/standard/var_unserializer.c" yy39: yych = *++YYCURSOR; if (yych == '+') goto yy40; @@ -862,7 +866,7 @@ yy41: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 626 "ext/standard/var_unserializer.re" +#line 629 "ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; @@ -891,7 +895,7 @@ yy41: ZVAL_STRINGL(*rval, str, len, 0); return 1; } -#line 895 "ext/standard/var_unserializer.c" +#line 899 "ext/standard/var_unserializer.c" yy46: yych = *++YYCURSOR; if (yych == '+') goto yy47; @@ -912,7 +916,7 @@ yy48: yych = *++YYCURSOR; if (yych != '"') goto yy18; ++YYCURSOR; -#line 598 "ext/standard/var_unserializer.re" +#line 601 "ext/standard/var_unserializer.re" { size_t len, maxlen; char *str; @@ -940,7 +944,7 @@ yy48: ZVAL_STRINGL(*rval, str, len, 1); return 1; } -#line 944 "ext/standard/var_unserializer.c" +#line 948 "ext/standard/var_unserializer.c" yy53: yych = *++YYCURSOR; if (yych <= '/') { @@ -1028,7 +1032,7 @@ yy61: } yy63: ++YYCURSOR; -#line 588 "ext/standard/var_unserializer.re" +#line 591 "ext/standard/var_unserializer.re" { #if SIZEOF_LONG == 4 use_double: @@ -1038,7 +1042,7 @@ use_double: ZVAL_DOUBLE(*rval, zend_strtod((const char *)start + 2, NULL)); return 1; } -#line 1042 "ext/standard/var_unserializer.c" +#line 1046 "ext/standard/var_unserializer.c" yy65: yych = *++YYCURSOR; if (yych <= ',') { @@ -1097,7 +1101,7 @@ yy73: yych = *++YYCURSOR; if (yych != ';') goto yy18; ++YYCURSOR; -#line 573 "ext/standard/var_unserializer.re" +#line 576 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); @@ -1112,7 +1116,7 @@ yy73: return 1; } -#line 1116 "ext/standard/var_unserializer.c" +#line 1120 "ext/standard/var_unserializer.c" yy76: yych = *++YYCURSOR; if (yych == 'N') goto yy73; @@ -1139,7 +1143,7 @@ yy79: if (yych <= '9') goto yy79; if (yych != ';') goto yy18; ++YYCURSOR; -#line 546 "ext/standard/var_unserializer.re" +#line 549 "ext/standard/var_unserializer.re" { #if SIZEOF_LONG == 4 int digits = YYCURSOR - start - 3; @@ -1166,7 +1170,7 @@ yy79: ZVAL_LONG(*rval, parse_iv(start + 2)); return 1; } -#line 1170 "ext/standard/var_unserializer.c" +#line 1174 "ext/standard/var_unserializer.c" yy83: yych = *++YYCURSOR; if (yych <= '/') goto yy18; @@ -1174,24 +1178,24 @@ yy83: yych = *++YYCURSOR; if (yych != ';') goto yy18; ++YYCURSOR; -#line 539 "ext/standard/var_unserializer.re" +#line 542 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_BOOL(*rval, parse_iv(start + 2)); return 1; } -#line 1185 "ext/standard/var_unserializer.c" +#line 1189 "ext/standard/var_unserializer.c" yy87: ++YYCURSOR; -#line 532 "ext/standard/var_unserializer.re" +#line 535 "ext/standard/var_unserializer.re" { *p = YYCURSOR; INIT_PZVAL(*rval); ZVAL_NULL(*rval); return 1; } -#line 1195 "ext/standard/var_unserializer.c" +#line 1199 "ext/standard/var_unserializer.c" yy89: yych = *++YYCURSOR; if (yych <= ',') { @@ -1214,7 +1218,7 @@ yy91: if (yych <= '9') goto yy91; if (yych != ';') goto yy18; ++YYCURSOR; -#line 509 "ext/standard/var_unserializer.re" +#line 512 "ext/standard/var_unserializer.re" { long id; @@ -1237,7 +1241,7 @@ yy91: return 1; } -#line 1241 "ext/standard/var_unserializer.c" +#line 1245 "ext/standard/var_unserializer.c" yy95: yych = *++YYCURSOR; if (yych <= ',') { @@ -1260,7 +1264,7 @@ yy97: if (yych <= '9') goto yy97; if (yych != ';') goto yy18; ++YYCURSOR; -#line 488 "ext/standard/var_unserializer.re" +#line 491 "ext/standard/var_unserializer.re" { long id; @@ -1281,9 +1285,9 @@ yy97: return 1; } -#line 1285 "ext/standard/var_unserializer.c" +#line 1289 "ext/standard/var_unserializer.c" } -#line 837 "ext/standard/var_unserializer.re" +#line 840 "ext/standard/var_unserializer.re" return 0;
null
null
null
5,998
static bool blit_region_is_unsafe(struct CirrusVGAState *s, int32_t pitch, int32_t addr) { if (pitch < 0) { int64_t min = addr + ((int64_t)s->cirrus_blt_height-1) * pitch; int32_t max = addr + s->cirrus_blt_width; if (min < 0 || max >= s->vga.vram_size) { return true; } } else { int64_t max = addr + ((int64_t)s->cirrus_blt_height-1) * pitch + s->cirrus_blt_width; if (max >= s->vga.vram_size) { return true; } } return false; }
Exec Code Overflow
0
static bool blit_region_is_unsafe(struct CirrusVGAState *s, int32_t pitch, int32_t addr) { if (pitch < 0) { int64_t min = addr + ((int64_t)s->cirrus_blt_height-1) * pitch; int32_t max = addr + s->cirrus_blt_width; if (min < 0 || max >= s->vga.vram_size) { return true; } } else { int64_t max = addr + ((int64_t)s->cirrus_blt_height-1) * pitch + s->cirrus_blt_width; if (max >= s->vga.vram_size) { return true; } } return false; }
@@ -293,6 +293,10 @@ static bool blit_is_unsafe(struct CirrusVGAState *s) assert(s->cirrus_blt_width > 0); assert(s->cirrus_blt_height > 0); + if (s->cirrus_blt_width > CIRRUS_BLTBUFSIZE) { + return true; + } + if (blit_region_is_unsafe(s, s->cirrus_blt_dstpitch, s->cirrus_blt_dstaddr & s->cirrus_addr_mask)) { return true;
CWE-119
null
null
5,999
static int cirrus_bitblt_common_patterncopy(CirrusVGAState * s, const uint8_t * src) { uint8_t *dst; dst = s->vga.vram_ptr + (s->cirrus_blt_dstaddr & s->cirrus_addr_mask); if (blit_is_unsafe(s)) return 0; (*s->cirrus_rop) (s, dst, src, s->cirrus_blt_dstpitch, 0, s->cirrus_blt_width, s->cirrus_blt_height); cirrus_invalidate_region(s, s->cirrus_blt_dstaddr, s->cirrus_blt_dstpitch, s->cirrus_blt_width, s->cirrus_blt_height); return 1; }
Exec Code Overflow
0
static int cirrus_bitblt_common_patterncopy(CirrusVGAState * s, const uint8_t * src) { uint8_t *dst; dst = s->vga.vram_ptr + (s->cirrus_blt_dstaddr & s->cirrus_addr_mask); if (blit_is_unsafe(s)) return 0; (*s->cirrus_rop) (s, dst, src, s->cirrus_blt_dstpitch, 0, s->cirrus_blt_width, s->cirrus_blt_height); cirrus_invalidate_region(s, s->cirrus_blt_dstaddr, s->cirrus_blt_dstpitch, s->cirrus_blt_width, s->cirrus_blt_height); return 1; }
@@ -293,6 +293,10 @@ static bool blit_is_unsafe(struct CirrusVGAState *s) assert(s->cirrus_blt_width > 0); assert(s->cirrus_blt_height > 0); + if (s->cirrus_blt_width > CIRRUS_BLTBUFSIZE) { + return true; + } + if (blit_region_is_unsafe(s, s->cirrus_blt_dstpitch, s->cirrus_blt_dstaddr & s->cirrus_addr_mask)) { return true;
CWE-119
null
null