idx
int64
func_before
string
Vulnerability Classification
string
vul
int64
func_after
string
patch
string
CWE ID
string
lines_before
string
lines_after
string
13,800
MainURLRequestContextGetter( BrowserContextIOData* context, content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors) : context_(context), request_interceptors_(std::move(request_interceptors)) { std::swap(protocol_handlers_, *protocol_handlers); }
null
0
MainURLRequestContextGetter( BrowserContextIOData* context, content::ProtocolHandlerMap* protocol_handlers, content::URLRequestInterceptorScopedVector request_interceptors) : context_(context), request_interceptors_(std::move(request_interceptors)) { std::swap(protocol_handlers_, *protocol_handlers); }
@@ -558,24 +558,16 @@ class OTRBrowserContextImpl : public BrowserContext { public: OTRBrowserContextImpl(BrowserContextImpl* original, BrowserContextIODataImpl* original_io_data); - - base::WeakPtr<OTRBrowserContextImpl> GetWeakPtr() { - return weak_ptr_factory_.GetWeakPtr(); - } + ~OTRBrowserContextImpl() override; private: - ~OTRBrowserContextImpl() override; + BrowserContext* GetOffTheRecordContext() override { return this; } - scoped_refptr<BrowserContext> GetOffTheRecordContext() override { - return make_scoped_refptr(this); - } - BrowserContext* GetOriginalContext() const override; + BrowserContext* GetOriginalContext() override; bool HasOffTheRecordContext() const override { return true; } - scoped_refptr<BrowserContextImpl> original_context_; - - base::WeakPtrFactory<OTRBrowserContextImpl> weak_ptr_factory_; + BrowserContextImpl* original_context_; }; class BrowserContextImpl : public BrowserContext { @@ -583,50 +575,49 @@ class BrowserContextImpl : public BrowserContext { BrowserContextImpl(const BrowserContext::Params& params); private: + friend class BrowserContext; + ~BrowserContextImpl() override; - scoped_refptr<BrowserContext> GetOffTheRecordContext() override; + BrowserContext* GetOffTheRecordContext() override; - BrowserContext* GetOriginalContext() const override { - return const_cast<BrowserContextImpl*>(this); - } + BrowserContext* GetOriginalContext() override { return this; } bool HasOffTheRecordContext() const override { return otr_context_ != nullptr; } - base::WeakPtr<OTRBrowserContextImpl> otr_context_; + std::unique_ptr<OTRBrowserContextImpl> otr_context_; }; -OTRBrowserContextImpl::~OTRBrowserContextImpl() {} - -BrowserContext* OTRBrowserContextImpl::GetOriginalContext() const { - return original_context_.get(); +BrowserContext* OTRBrowserContextImpl::GetOriginalContext() { + return original_context_; } +OTRBrowserContextImpl::~OTRBrowserContextImpl() {} + OTRBrowserContextImpl::OTRBrowserContextImpl( BrowserContextImpl* original, BrowserContextIODataImpl* original_io_data) : BrowserContext(new OTRBrowserContextIODataImpl(original_io_data)), - original_context_(original), - weak_ptr_factory_(this) { + original_context_(original) { BrowserContextDependencyManager::GetInstance() ->CreateBrowserContextServices(this); } -BrowserContextImpl::~BrowserContextImpl() { - CHECK(!otr_context_); -} - -scoped_refptr<BrowserContext> BrowserContextImpl::GetOffTheRecordContext() { +BrowserContext* BrowserContextImpl::GetOffTheRecordContext() { if (!otr_context_) { - OTRBrowserContextImpl* context = new OTRBrowserContextImpl( - this, - static_cast<BrowserContextIODataImpl *>(io_data())); - otr_context_ = context->GetWeakPtr(); + otr_context_ = + base::MakeUnique<OTRBrowserContextImpl>( + this, + static_cast<BrowserContextIODataImpl*>(io_data())); } - return make_scoped_refptr(otr_context_.get()); + return otr_context_.get(); +} + +BrowserContextImpl::~BrowserContextImpl() { + CHECK(!otr_context_); } BrowserContextImpl::BrowserContextImpl(const BrowserContext::Params& params) @@ -643,8 +634,9 @@ BrowserContextImpl::BrowserContextImpl(const BrowserContext::Params& params) ->CreateBrowserContextServices(this); } -void BrowserContextTraits::Destruct(const BrowserContext* x) { - BrowserContextDestroyer::DestroyContext(const_cast<BrowserContext*>(x)); +void BrowserContext::Deleter::operator()(BrowserContext* context) { + CHECK(!context->IsOffTheRecord()); + BrowserContextDestroyer::DestroyContext(base::WrapUnique(context)); } std::unique_ptr<content::ZoomLevelDelegate> @@ -744,8 +736,8 @@ void BrowserContext::RemoveObserver(BrowserContextObserver* observer) { observers_.RemoveObserver(observer); } -BrowserContext::BrowserContext(BrowserContextIOData* io_data) : - io_data_(io_data) { +BrowserContext::BrowserContext(BrowserContextIOData* io_data) + : io_data_(io_data) { CHECK(BrowserProcessMain::GetInstance()->IsRunning()) << "The main browser process components must be started before " << "creating a context"; @@ -786,9 +778,8 @@ BrowserContext::~BrowserContext() { } // static -scoped_refptr<BrowserContext> BrowserContext::Create(const Params& params) { - scoped_refptr<BrowserContext> context = new BrowserContextImpl(params); - return context; +BrowserContext::UniquePtr BrowserContext::Create(const Params& params) { + return BrowserContext::UniquePtr(new BrowserContextImpl(params)); } // static @@ -800,7 +791,10 @@ void BrowserContext::ForEach(const BrowserContextCallback& callback) { // static void BrowserContext::AssertNoContextsExist() { - CHECK_EQ(g_all_contexts.Get().size(), static_cast<size_t>(0)); + CHECK_EQ(g_all_contexts.Get().size(), static_cast<size_t>(0)) + << "BrowserContexts still exist at shutdown! This is normally the result " + << "of an application leak, but it's possible that there might be an " + << "Oxide bug too"; } BrowserContextID BrowserContext::GetID() const { @@ -820,6 +814,14 @@ void BrowserContext::SetDelegate(BrowserContextDelegate* delegate) { data.delegate = delegate; } +// static +void BrowserContext::DestroyOffTheRecordContextForContext( + BrowserContext* context) { + CHECK(!context->IsOffTheRecord() && context->HasOffTheRecordContext()); + BrowserContextDestroyer::DestroyContext( + std::move(static_cast<BrowserContextImpl*>(context)->otr_context_)); +} + bool BrowserContext::IsOffTheRecord() const { DCHECK(CalledOnValidThread()); return io_data()->IsOffTheRecord(); @@ -829,7 +831,7 @@ bool BrowserContext::IsSameContext(BrowserContext* other) const { DCHECK(CalledOnValidThread()); return other->GetOriginalContext() == this || (other->HasOffTheRecordContext() && - other->GetOffTheRecordContext().get() == this); + other->GetOffTheRecordContext() == this); } base::FilePath BrowserContext::GetPath() const {
CWE-20
null
null
13,801
OTRBrowserContextIODataImpl(BrowserContextIODataImpl* original) : original_io_data_(original) {}
null
0
OTRBrowserContextIODataImpl(BrowserContextIODataImpl* original) : original_io_data_(original) {}
@@ -558,24 +558,16 @@ class OTRBrowserContextImpl : public BrowserContext { public: OTRBrowserContextImpl(BrowserContextImpl* original, BrowserContextIODataImpl* original_io_data); - - base::WeakPtr<OTRBrowserContextImpl> GetWeakPtr() { - return weak_ptr_factory_.GetWeakPtr(); - } + ~OTRBrowserContextImpl() override; private: - ~OTRBrowserContextImpl() override; + BrowserContext* GetOffTheRecordContext() override { return this; } - scoped_refptr<BrowserContext> GetOffTheRecordContext() override { - return make_scoped_refptr(this); - } - BrowserContext* GetOriginalContext() const override; + BrowserContext* GetOriginalContext() override; bool HasOffTheRecordContext() const override { return true; } - scoped_refptr<BrowserContextImpl> original_context_; - - base::WeakPtrFactory<OTRBrowserContextImpl> weak_ptr_factory_; + BrowserContextImpl* original_context_; }; class BrowserContextImpl : public BrowserContext { @@ -583,50 +575,49 @@ class BrowserContextImpl : public BrowserContext { BrowserContextImpl(const BrowserContext::Params& params); private: + friend class BrowserContext; + ~BrowserContextImpl() override; - scoped_refptr<BrowserContext> GetOffTheRecordContext() override; + BrowserContext* GetOffTheRecordContext() override; - BrowserContext* GetOriginalContext() const override { - return const_cast<BrowserContextImpl*>(this); - } + BrowserContext* GetOriginalContext() override { return this; } bool HasOffTheRecordContext() const override { return otr_context_ != nullptr; } - base::WeakPtr<OTRBrowserContextImpl> otr_context_; + std::unique_ptr<OTRBrowserContextImpl> otr_context_; }; -OTRBrowserContextImpl::~OTRBrowserContextImpl() {} - -BrowserContext* OTRBrowserContextImpl::GetOriginalContext() const { - return original_context_.get(); +BrowserContext* OTRBrowserContextImpl::GetOriginalContext() { + return original_context_; } +OTRBrowserContextImpl::~OTRBrowserContextImpl() {} + OTRBrowserContextImpl::OTRBrowserContextImpl( BrowserContextImpl* original, BrowserContextIODataImpl* original_io_data) : BrowserContext(new OTRBrowserContextIODataImpl(original_io_data)), - original_context_(original), - weak_ptr_factory_(this) { + original_context_(original) { BrowserContextDependencyManager::GetInstance() ->CreateBrowserContextServices(this); } -BrowserContextImpl::~BrowserContextImpl() { - CHECK(!otr_context_); -} - -scoped_refptr<BrowserContext> BrowserContextImpl::GetOffTheRecordContext() { +BrowserContext* BrowserContextImpl::GetOffTheRecordContext() { if (!otr_context_) { - OTRBrowserContextImpl* context = new OTRBrowserContextImpl( - this, - static_cast<BrowserContextIODataImpl *>(io_data())); - otr_context_ = context->GetWeakPtr(); + otr_context_ = + base::MakeUnique<OTRBrowserContextImpl>( + this, + static_cast<BrowserContextIODataImpl*>(io_data())); } - return make_scoped_refptr(otr_context_.get()); + return otr_context_.get(); +} + +BrowserContextImpl::~BrowserContextImpl() { + CHECK(!otr_context_); } BrowserContextImpl::BrowserContextImpl(const BrowserContext::Params& params) @@ -643,8 +634,9 @@ BrowserContextImpl::BrowserContextImpl(const BrowserContext::Params& params) ->CreateBrowserContextServices(this); } -void BrowserContextTraits::Destruct(const BrowserContext* x) { - BrowserContextDestroyer::DestroyContext(const_cast<BrowserContext*>(x)); +void BrowserContext::Deleter::operator()(BrowserContext* context) { + CHECK(!context->IsOffTheRecord()); + BrowserContextDestroyer::DestroyContext(base::WrapUnique(context)); } std::unique_ptr<content::ZoomLevelDelegate> @@ -744,8 +736,8 @@ void BrowserContext::RemoveObserver(BrowserContextObserver* observer) { observers_.RemoveObserver(observer); } -BrowserContext::BrowserContext(BrowserContextIOData* io_data) : - io_data_(io_data) { +BrowserContext::BrowserContext(BrowserContextIOData* io_data) + : io_data_(io_data) { CHECK(BrowserProcessMain::GetInstance()->IsRunning()) << "The main browser process components must be started before " << "creating a context"; @@ -786,9 +778,8 @@ BrowserContext::~BrowserContext() { } // static -scoped_refptr<BrowserContext> BrowserContext::Create(const Params& params) { - scoped_refptr<BrowserContext> context = new BrowserContextImpl(params); - return context; +BrowserContext::UniquePtr BrowserContext::Create(const Params& params) { + return BrowserContext::UniquePtr(new BrowserContextImpl(params)); } // static @@ -800,7 +791,10 @@ void BrowserContext::ForEach(const BrowserContextCallback& callback) { // static void BrowserContext::AssertNoContextsExist() { - CHECK_EQ(g_all_contexts.Get().size(), static_cast<size_t>(0)); + CHECK_EQ(g_all_contexts.Get().size(), static_cast<size_t>(0)) + << "BrowserContexts still exist at shutdown! This is normally the result " + << "of an application leak, but it's possible that there might be an " + << "Oxide bug too"; } BrowserContextID BrowserContext::GetID() const { @@ -820,6 +814,14 @@ void BrowserContext::SetDelegate(BrowserContextDelegate* delegate) { data.delegate = delegate; } +// static +void BrowserContext::DestroyOffTheRecordContextForContext( + BrowserContext* context) { + CHECK(!context->IsOffTheRecord() && context->HasOffTheRecordContext()); + BrowserContextDestroyer::DestroyContext( + std::move(static_cast<BrowserContextImpl*>(context)->otr_context_)); +} + bool BrowserContext::IsOffTheRecord() const { DCHECK(CalledOnValidThread()); return io_data()->IsOffTheRecord(); @@ -829,7 +831,7 @@ bool BrowserContext::IsSameContext(BrowserContext* other) const { DCHECK(CalledOnValidThread()); return other->GetOriginalContext() == this || (other->HasOffTheRecordContext() && - other->GetOffTheRecordContext().get() == this); + other->GetOffTheRecordContext() == this); } base::FilePath BrowserContext::GetPath() const {
CWE-20
null
null
13,802
BrowserContextIOData::~BrowserContextIOData() { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); }
null
0
BrowserContextIOData::~BrowserContextIOData() { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); }
@@ -558,24 +558,16 @@ class OTRBrowserContextImpl : public BrowserContext { public: OTRBrowserContextImpl(BrowserContextImpl* original, BrowserContextIODataImpl* original_io_data); - - base::WeakPtr<OTRBrowserContextImpl> GetWeakPtr() { - return weak_ptr_factory_.GetWeakPtr(); - } + ~OTRBrowserContextImpl() override; private: - ~OTRBrowserContextImpl() override; + BrowserContext* GetOffTheRecordContext() override { return this; } - scoped_refptr<BrowserContext> GetOffTheRecordContext() override { - return make_scoped_refptr(this); - } - BrowserContext* GetOriginalContext() const override; + BrowserContext* GetOriginalContext() override; bool HasOffTheRecordContext() const override { return true; } - scoped_refptr<BrowserContextImpl> original_context_; - - base::WeakPtrFactory<OTRBrowserContextImpl> weak_ptr_factory_; + BrowserContextImpl* original_context_; }; class BrowserContextImpl : public BrowserContext { @@ -583,50 +575,49 @@ class BrowserContextImpl : public BrowserContext { BrowserContextImpl(const BrowserContext::Params& params); private: + friend class BrowserContext; + ~BrowserContextImpl() override; - scoped_refptr<BrowserContext> GetOffTheRecordContext() override; + BrowserContext* GetOffTheRecordContext() override; - BrowserContext* GetOriginalContext() const override { - return const_cast<BrowserContextImpl*>(this); - } + BrowserContext* GetOriginalContext() override { return this; } bool HasOffTheRecordContext() const override { return otr_context_ != nullptr; } - base::WeakPtr<OTRBrowserContextImpl> otr_context_; + std::unique_ptr<OTRBrowserContextImpl> otr_context_; }; -OTRBrowserContextImpl::~OTRBrowserContextImpl() {} - -BrowserContext* OTRBrowserContextImpl::GetOriginalContext() const { - return original_context_.get(); +BrowserContext* OTRBrowserContextImpl::GetOriginalContext() { + return original_context_; } +OTRBrowserContextImpl::~OTRBrowserContextImpl() {} + OTRBrowserContextImpl::OTRBrowserContextImpl( BrowserContextImpl* original, BrowserContextIODataImpl* original_io_data) : BrowserContext(new OTRBrowserContextIODataImpl(original_io_data)), - original_context_(original), - weak_ptr_factory_(this) { + original_context_(original) { BrowserContextDependencyManager::GetInstance() ->CreateBrowserContextServices(this); } -BrowserContextImpl::~BrowserContextImpl() { - CHECK(!otr_context_); -} - -scoped_refptr<BrowserContext> BrowserContextImpl::GetOffTheRecordContext() { +BrowserContext* BrowserContextImpl::GetOffTheRecordContext() { if (!otr_context_) { - OTRBrowserContextImpl* context = new OTRBrowserContextImpl( - this, - static_cast<BrowserContextIODataImpl *>(io_data())); - otr_context_ = context->GetWeakPtr(); + otr_context_ = + base::MakeUnique<OTRBrowserContextImpl>( + this, + static_cast<BrowserContextIODataImpl*>(io_data())); } - return make_scoped_refptr(otr_context_.get()); + return otr_context_.get(); +} + +BrowserContextImpl::~BrowserContextImpl() { + CHECK(!otr_context_); } BrowserContextImpl::BrowserContextImpl(const BrowserContext::Params& params) @@ -643,8 +634,9 @@ BrowserContextImpl::BrowserContextImpl(const BrowserContext::Params& params) ->CreateBrowserContextServices(this); } -void BrowserContextTraits::Destruct(const BrowserContext* x) { - BrowserContextDestroyer::DestroyContext(const_cast<BrowserContext*>(x)); +void BrowserContext::Deleter::operator()(BrowserContext* context) { + CHECK(!context->IsOffTheRecord()); + BrowserContextDestroyer::DestroyContext(base::WrapUnique(context)); } std::unique_ptr<content::ZoomLevelDelegate> @@ -744,8 +736,8 @@ void BrowserContext::RemoveObserver(BrowserContextObserver* observer) { observers_.RemoveObserver(observer); } -BrowserContext::BrowserContext(BrowserContextIOData* io_data) : - io_data_(io_data) { +BrowserContext::BrowserContext(BrowserContextIOData* io_data) + : io_data_(io_data) { CHECK(BrowserProcessMain::GetInstance()->IsRunning()) << "The main browser process components must be started before " << "creating a context"; @@ -786,9 +778,8 @@ BrowserContext::~BrowserContext() { } // static -scoped_refptr<BrowserContext> BrowserContext::Create(const Params& params) { - scoped_refptr<BrowserContext> context = new BrowserContextImpl(params); - return context; +BrowserContext::UniquePtr BrowserContext::Create(const Params& params) { + return BrowserContext::UniquePtr(new BrowserContextImpl(params)); } // static @@ -800,7 +791,10 @@ void BrowserContext::ForEach(const BrowserContextCallback& callback) { // static void BrowserContext::AssertNoContextsExist() { - CHECK_EQ(g_all_contexts.Get().size(), static_cast<size_t>(0)); + CHECK_EQ(g_all_contexts.Get().size(), static_cast<size_t>(0)) + << "BrowserContexts still exist at shutdown! This is normally the result " + << "of an application leak, but it's possible that there might be an " + << "Oxide bug too"; } BrowserContextID BrowserContext::GetID() const { @@ -820,6 +814,14 @@ void BrowserContext::SetDelegate(BrowserContextDelegate* delegate) { data.delegate = delegate; } +// static +void BrowserContext::DestroyOffTheRecordContextForContext( + BrowserContext* context) { + CHECK(!context->IsOffTheRecord() && context->HasOffTheRecordContext()); + BrowserContextDestroyer::DestroyContext( + std::move(static_cast<BrowserContextImpl*>(context)->otr_context_)); +} + bool BrowserContext::IsOffTheRecord() const { DCHECK(CalledOnValidThread()); return io_data()->IsOffTheRecord(); @@ -829,7 +831,7 @@ bool BrowserContext::IsSameContext(BrowserContext* other) const { DCHECK(CalledOnValidThread()); return other->GetOriginalContext() == this || (other->HasOffTheRecordContext() && - other->GetOffTheRecordContext().get() == this); + other->GetOffTheRecordContext() == this); } base::FilePath BrowserContext::GetPath() const {
CWE-20
null
null
13,803
BrowserMainParts::BrowserMainParts() {}
null
0
BrowserMainParts::BrowserMainParts() {}
@@ -49,6 +49,7 @@ #include "shared/gpu/oxide_gl_context_dependent.h" #include "oxide_browser_context.h" +#include "oxide_browser_context_destroyer.h" #include "oxide_browser_platform_integration.h" #include "oxide_browser_process_main.h" #include "oxide_geolocation_delegate.h" @@ -57,6 +58,7 @@ #include "oxide_lifecycle_observer.h" #include "oxide_message_pump.h" #include "oxide_render_process_initializer.h" +#include "oxide_web_contents_unloader.h" #include "oxide_web_contents_view.h" #include "screen.h" @@ -341,15 +343,15 @@ bool BrowserMainParts::MainMessageLoopRun(int* result_code) { } void BrowserMainParts::PostMainMessageLoopRun() { + WebContentsUnloader::GetInstance()->Shutdown(); + + BrowserContextDestroyer::Shutdown(); + BrowserContext::AssertNoContextsExist(); + CompositorUtils::GetInstance()->Shutdown(); } void BrowserMainParts::PostDestroyThreads() { - if (BrowserProcessMain::GetInstance()->GetProcessModel() == - PROCESS_MODEL_SINGLE_PROCESS) { - BrowserContext::AssertNoContextsExist(); - } - device_client_.reset(); display::Screen::SetScreenInstance(nullptr);
CWE-20
null
null
13,804
bool CanUseSharedGLContext() { #if defined(ENABLE_HYBRIS) if (!HybrisUtils::GetInstance()->IsUsingAndroidEGL()) { return true; } if (content::GpuDataManagerImpl::GetInstance()->IsDriverBugWorkaroundActive( gpu::USE_VIRTUALIZED_GL_CONTEXTS)) { return false; } #endif return true; }
null
0
bool CanUseSharedGLContext() { #if defined(ENABLE_HYBRIS) if (!HybrisUtils::GetInstance()->IsUsingAndroidEGL()) { return true; } if (content::GpuDataManagerImpl::GetInstance()->IsDriverBugWorkaroundActive( gpu::USE_VIRTUALIZED_GL_CONTEXTS)) { return false; } #endif return true; }
@@ -49,6 +49,7 @@ #include "shared/gpu/oxide_gl_context_dependent.h" #include "oxide_browser_context.h" +#include "oxide_browser_context_destroyer.h" #include "oxide_browser_platform_integration.h" #include "oxide_browser_process_main.h" #include "oxide_geolocation_delegate.h" @@ -57,6 +58,7 @@ #include "oxide_lifecycle_observer.h" #include "oxide_message_pump.h" #include "oxide_render_process_initializer.h" +#include "oxide_web_contents_unloader.h" #include "oxide_web_contents_view.h" #include "screen.h" @@ -341,15 +343,15 @@ bool BrowserMainParts::MainMessageLoopRun(int* result_code) { } void BrowserMainParts::PostMainMessageLoopRun() { + WebContentsUnloader::GetInstance()->Shutdown(); + + BrowserContextDestroyer::Shutdown(); + BrowserContext::AssertNoContextsExist(); + CompositorUtils::GetInstance()->Shutdown(); } void BrowserMainParts::PostDestroyThreads() { - if (BrowserProcessMain::GetInstance()->GetProcessModel() == - PROCESS_MODEL_SINGLE_PROCESS) { - BrowserContext::AssertNoContextsExist(); - } - device_client_.reset(); display::Screen::SetScreenInstance(nullptr);
CWE-20
null
null
13,805
ui::Clipboard* CreateClipboard() { return BrowserPlatformIntegration::GetInstance()->CreateClipboard(); }
null
0
ui::Clipboard* CreateClipboard() { return BrowserPlatformIntegration::GetInstance()->CreateClipboard(); }
@@ -49,6 +49,7 @@ #include "shared/gpu/oxide_gl_context_dependent.h" #include "oxide_browser_context.h" +#include "oxide_browser_context_destroyer.h" #include "oxide_browser_platform_integration.h" #include "oxide_browser_process_main.h" #include "oxide_geolocation_delegate.h" @@ -57,6 +58,7 @@ #include "oxide_lifecycle_observer.h" #include "oxide_message_pump.h" #include "oxide_render_process_initializer.h" +#include "oxide_web_contents_unloader.h" #include "oxide_web_contents_view.h" #include "screen.h" @@ -341,15 +343,15 @@ bool BrowserMainParts::MainMessageLoopRun(int* result_code) { } void BrowserMainParts::PostMainMessageLoopRun() { + WebContentsUnloader::GetInstance()->Shutdown(); + + BrowserContextDestroyer::Shutdown(); + BrowserContext::AssertNoContextsExist(); + CompositorUtils::GetInstance()->Shutdown(); } void BrowserMainParts::PostDestroyThreads() { - if (BrowserProcessMain::GetInstance()->GetProcessModel() == - PROCESS_MODEL_SINGLE_PROCESS) { - BrowserContext::AssertNoContextsExist(); - } - device_client_.reset(); display::Screen::SetScreenInstance(nullptr);
CWE-20
null
null
13,806
std::unique_ptr<base::MessagePump> CreateUIMessagePump() { return BrowserPlatformIntegration::GetInstance()->CreateUIMessagePump(); }
null
0
std::unique_ptr<base::MessagePump> CreateUIMessagePump() { return BrowserPlatformIntegration::GetInstance()->CreateUIMessagePump(); }
@@ -49,6 +49,7 @@ #include "shared/gpu/oxide_gl_context_dependent.h" #include "oxide_browser_context.h" +#include "oxide_browser_context_destroyer.h" #include "oxide_browser_platform_integration.h" #include "oxide_browser_process_main.h" #include "oxide_geolocation_delegate.h" @@ -57,6 +58,7 @@ #include "oxide_lifecycle_observer.h" #include "oxide_message_pump.h" #include "oxide_render_process_initializer.h" +#include "oxide_web_contents_unloader.h" #include "oxide_web_contents_view.h" #include "screen.h" @@ -341,15 +343,15 @@ bool BrowserMainParts::MainMessageLoopRun(int* result_code) { } void BrowserMainParts::PostMainMessageLoopRun() { + WebContentsUnloader::GetInstance()->Shutdown(); + + BrowserContextDestroyer::Shutdown(); + BrowserContext::AssertNoContextsExist(); + CompositorUtils::GetInstance()->Shutdown(); } void BrowserMainParts::PostDestroyThreads() { - if (BrowserProcessMain::GetInstance()->GetProcessModel() == - PROCESS_MODEL_SINGLE_PROCESS) { - BrowserContext::AssertNoContextsExist(); - } - device_client_.reset(); display::Screen::SetScreenInstance(nullptr);
CWE-20
null
null
13,807
OverrideVideoCaptureDeviceFactory( std::unique_ptr<media::VideoCaptureDeviceFactory> platform_factory) { return base::WrapUnique( new VideoCaptureDeviceFactoryLinux(std::move(platform_factory))); }
null
0
OverrideVideoCaptureDeviceFactory( std::unique_ptr<media::VideoCaptureDeviceFactory> platform_factory) { return base::WrapUnique( new VideoCaptureDeviceFactoryLinux(std::move(platform_factory))); }
@@ -49,6 +49,7 @@ #include "shared/gpu/oxide_gl_context_dependent.h" #include "oxide_browser_context.h" +#include "oxide_browser_context_destroyer.h" #include "oxide_browser_platform_integration.h" #include "oxide_browser_process_main.h" #include "oxide_geolocation_delegate.h" @@ -57,6 +58,7 @@ #include "oxide_lifecycle_observer.h" #include "oxide_message_pump.h" #include "oxide_render_process_initializer.h" +#include "oxide_web_contents_unloader.h" #include "oxide_web_contents_view.h" #include "screen.h" @@ -341,15 +343,15 @@ bool BrowserMainParts::MainMessageLoopRun(int* result_code) { } void BrowserMainParts::PostMainMessageLoopRun() { + WebContentsUnloader::GetInstance()->Shutdown(); + + BrowserContextDestroyer::Shutdown(); + BrowserContext::AssertNoContextsExist(); + CompositorUtils::GetInstance()->Shutdown(); } void BrowserMainParts::PostDestroyThreads() { - if (BrowserProcessMain::GetInstance()->GetProcessModel() == - PROCESS_MODEL_SINGLE_PROCESS) { - BrowserContext::AssertNoContextsExist(); - } - device_client_.reset(); display::Screen::SetScreenInstance(nullptr);
CWE-20
null
null
13,808
int BrowserMainParts::PreCreateThreads() { gfx::InitializeOxideNativeDisplay( BrowserPlatformIntegration::GetInstance()->GetNativeDisplay()); { ScopedBindGLESAPI gles_binder; gl::init::InitializeGLOneOff(); } device_client_.reset(new DeviceClient()); primary_screen_.reset(new display::Screen()); ::display::Screen::SetScreenInstance(primary_screen_.get()); io_thread_.reset(new IOThread()); return 0; }
null
0
int BrowserMainParts::PreCreateThreads() { gfx::InitializeOxideNativeDisplay( BrowserPlatformIntegration::GetInstance()->GetNativeDisplay()); { ScopedBindGLESAPI gles_binder; gl::init::InitializeGLOneOff(); } device_client_.reset(new DeviceClient()); primary_screen_.reset(new display::Screen()); ::display::Screen::SetScreenInstance(primary_screen_.get()); io_thread_.reset(new IOThread()); return 0; }
@@ -49,6 +49,7 @@ #include "shared/gpu/oxide_gl_context_dependent.h" #include "oxide_browser_context.h" +#include "oxide_browser_context_destroyer.h" #include "oxide_browser_platform_integration.h" #include "oxide_browser_process_main.h" #include "oxide_geolocation_delegate.h" @@ -57,6 +58,7 @@ #include "oxide_lifecycle_observer.h" #include "oxide_message_pump.h" #include "oxide_render_process_initializer.h" +#include "oxide_web_contents_unloader.h" #include "oxide_web_contents_view.h" #include "screen.h" @@ -341,15 +343,15 @@ bool BrowserMainParts::MainMessageLoopRun(int* result_code) { } void BrowserMainParts::PostMainMessageLoopRun() { + WebContentsUnloader::GetInstance()->Shutdown(); + + BrowserContextDestroyer::Shutdown(); + BrowserContext::AssertNoContextsExist(); + CompositorUtils::GetInstance()->Shutdown(); } void BrowserMainParts::PostDestroyThreads() { - if (BrowserProcessMain::GetInstance()->GetProcessModel() == - PROCESS_MODEL_SINGLE_PROCESS) { - BrowserContext::AssertNoContextsExist(); - } - device_client_.reset(); display::Screen::SetScreenInstance(nullptr);
CWE-20
null
null
13,809
void BrowserMainParts::PreEarlyInitialization() { content::SetWebContentsViewOxideFactory(WebContentsView::Create); #if defined(OS_LINUX) media::SetVideoCaptureDeviceFactoryOverrideDelegate( OverrideVideoCaptureDeviceFactory); #endif ui::SetClipboardOxideFactory(CreateClipboard); #if defined(OS_LINUX) gpu_info_collector_.reset(CreateGpuInfoCollectorLinux()); gpu::SetGpuInfoCollectorOxideLinux(gpu_info_collector_.get()); #endif base::MessageLoop::InitMessagePumpForUIFactory(CreateUIMessagePump); main_message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI)); base::MessageLoop::InitMessagePumpForUIFactory(nullptr); }
null
0
void BrowserMainParts::PreEarlyInitialization() { content::SetWebContentsViewOxideFactory(WebContentsView::Create); #if defined(OS_LINUX) media::SetVideoCaptureDeviceFactoryOverrideDelegate( OverrideVideoCaptureDeviceFactory); #endif ui::SetClipboardOxideFactory(CreateClipboard); #if defined(OS_LINUX) gpu_info_collector_.reset(CreateGpuInfoCollectorLinux()); gpu::SetGpuInfoCollectorOxideLinux(gpu_info_collector_.get()); #endif base::MessageLoop::InitMessagePumpForUIFactory(CreateUIMessagePump); main_message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_UI)); base::MessageLoop::InitMessagePumpForUIFactory(nullptr); }
@@ -49,6 +49,7 @@ #include "shared/gpu/oxide_gl_context_dependent.h" #include "oxide_browser_context.h" +#include "oxide_browser_context_destroyer.h" #include "oxide_browser_platform_integration.h" #include "oxide_browser_process_main.h" #include "oxide_geolocation_delegate.h" @@ -57,6 +58,7 @@ #include "oxide_lifecycle_observer.h" #include "oxide_message_pump.h" #include "oxide_render_process_initializer.h" +#include "oxide_web_contents_unloader.h" #include "oxide_web_contents_view.h" #include "screen.h" @@ -341,15 +343,15 @@ bool BrowserMainParts::MainMessageLoopRun(int* result_code) { } void BrowserMainParts::PostMainMessageLoopRun() { + WebContentsUnloader::GetInstance()->Shutdown(); + + BrowserContextDestroyer::Shutdown(); + BrowserContext::AssertNoContextsExist(); + CompositorUtils::GetInstance()->Shutdown(); } void BrowserMainParts::PostDestroyThreads() { - if (BrowserProcessMain::GetInstance()->GetProcessModel() == - PROCESS_MODEL_SINGLE_PROCESS) { - BrowserContext::AssertNoContextsExist(); - } - device_client_.reset(); display::Screen::SetScreenInstance(nullptr);
CWE-20
null
null
13,810
BrowserMainParts::~BrowserMainParts() {}
null
0
BrowserMainParts::~BrowserMainParts() {}
@@ -49,6 +49,7 @@ #include "shared/gpu/oxide_gl_context_dependent.h" #include "oxide_browser_context.h" +#include "oxide_browser_context_destroyer.h" #include "oxide_browser_platform_integration.h" #include "oxide_browser_process_main.h" #include "oxide_geolocation_delegate.h" @@ -57,6 +58,7 @@ #include "oxide_lifecycle_observer.h" #include "oxide_message_pump.h" #include "oxide_render_process_initializer.h" +#include "oxide_web_contents_unloader.h" #include "oxide_web_contents_view.h" #include "screen.h" @@ -341,15 +343,15 @@ bool BrowserMainParts::MainMessageLoopRun(int* result_code) { } void BrowserMainParts::PostMainMessageLoopRun() { + WebContentsUnloader::GetInstance()->Shutdown(); + + BrowserContextDestroyer::Shutdown(); + BrowserContext::AssertNoContextsExist(); + CompositorUtils::GetInstance()->Shutdown(); } void BrowserMainParts::PostDestroyThreads() { - if (BrowserProcessMain::GetInstance()->GetProcessModel() == - PROCESS_MODEL_SINGLE_PROCESS) { - BrowserContext::AssertNoContextsExist(); - } - device_client_.reset(); display::Screen::SetScreenInstance(nullptr);
CWE-20
null
null
13,811
ScopedBindGLESAPI::~ScopedBindGLESAPI() { if (!has_egl_) { return; } DCHECK(egl_lib_.is_valid()); DCHECK_NE(orig_api_, static_cast<EGLenum>(EGL_NONE)); _eglBindAPI eglBindAPI = reinterpret_cast<_eglBindAPI>( egl_lib_.GetFunctionPointer("eglBindAPI")); DCHECK(eglBindAPI); eglBindAPI(orig_api_); }
null
0
ScopedBindGLESAPI::~ScopedBindGLESAPI() { if (!has_egl_) { return; } DCHECK(egl_lib_.is_valid()); DCHECK_NE(orig_api_, static_cast<EGLenum>(EGL_NONE)); _eglBindAPI eglBindAPI = reinterpret_cast<_eglBindAPI>( egl_lib_.GetFunctionPointer("eglBindAPI")); DCHECK(eglBindAPI); eglBindAPI(orig_api_); }
@@ -49,6 +49,7 @@ #include "shared/gpu/oxide_gl_context_dependent.h" #include "oxide_browser_context.h" +#include "oxide_browser_context_destroyer.h" #include "oxide_browser_platform_integration.h" #include "oxide_browser_process_main.h" #include "oxide_geolocation_delegate.h" @@ -57,6 +58,7 @@ #include "oxide_lifecycle_observer.h" #include "oxide_message_pump.h" #include "oxide_render_process_initializer.h" +#include "oxide_web_contents_unloader.h" #include "oxide_web_contents_view.h" #include "screen.h" @@ -341,15 +343,15 @@ bool BrowserMainParts::MainMessageLoopRun(int* result_code) { } void BrowserMainParts::PostMainMessageLoopRun() { + WebContentsUnloader::GetInstance()->Shutdown(); + + BrowserContextDestroyer::Shutdown(); + BrowserContext::AssertNoContextsExist(); + CompositorUtils::GetInstance()->Shutdown(); } void BrowserMainParts::PostDestroyThreads() { - if (BrowserProcessMain::GetInstance()->GetProcessModel() == - PROCESS_MODEL_SINGLE_PROCESS) { - BrowserContext::AssertNoContextsExist(); - } - device_client_.reset(); display::Screen::SetScreenInstance(nullptr);
CWE-20
null
null
13,812
std::string GetEnvironmentOption(base::StringPiece option, base::Environment* env) { std::string name("OXIDE_"); name += option.data(); std::string result; env->GetVar(name, &result); return result; }
null
0
std::string GetEnvironmentOption(base::StringPiece option, base::Environment* env) { std::string name("OXIDE_"); name += option.data(); std::string result; env->GetVar(name, &result); return result; }
@@ -72,10 +72,8 @@ #include "shared/common/oxide_content_client.h" #include "shared/common/oxide_form_factor.h" -#include "oxide_browser_context.h" #include "oxide_form_factor_detection.h" #include "oxide_message_pump.h" -#include "oxide_web_contents_unloader.h" namespace content { @@ -581,14 +579,6 @@ void BrowserProcessMainImpl::Shutdown() { MessagePump::Get()->Stop(); - WebContentsUnloader::GetInstance()->Shutdown(); - - if (process_model_ != PROCESS_MODEL_SINGLE_PROCESS) { - // In single process mode, we do this check after destroying - // threads, as we hold the single BrowserContext alive until then - BrowserContext::AssertNoContextsExist(); - } - browser_main_runner_->Shutdown(); browser_main_runner_.reset();
CWE-20
null
null
13,813
const char* GetFormFactorHintCommandLine(FormFactor form_factor) { switch (form_factor) { case FORM_FACTOR_DESKTOP: return switches::kFormFactorDesktop; case FORM_FACTOR_TABLET: return switches::kFormFactorTablet; case FORM_FACTOR_PHONE: return switches::kFormFactorPhone; } NOTREACHED(); return nullptr; }
null
0
const char* GetFormFactorHintCommandLine(FormFactor form_factor) { switch (form_factor) { case FORM_FACTOR_DESKTOP: return switches::kFormFactorDesktop; case FORM_FACTOR_TABLET: return switches::kFormFactorTablet; case FORM_FACTOR_PHONE: return switches::kFormFactorPhone; } NOTREACHED(); return nullptr; }
@@ -72,10 +72,8 @@ #include "shared/common/oxide_content_client.h" #include "shared/common/oxide_form_factor.h" -#include "oxide_browser_context.h" #include "oxide_form_factor_detection.h" #include "oxide_message_pump.h" -#include "oxide_web_contents_unloader.h" namespace content { @@ -581,14 +579,6 @@ void BrowserProcessMainImpl::Shutdown() { MessagePump::Get()->Stop(); - WebContentsUnloader::GetInstance()->Shutdown(); - - if (process_model_ != PROCESS_MODEL_SINGLE_PROCESS) { - // In single process mode, we do this check after destroying - // threads, as we hold the single BrowserContext alive until then - BrowserContext::AssertNoContextsExist(); - } - browser_main_runner_->Shutdown(); browser_main_runner_.reset();
CWE-20
null
null
13,814
const char* GetGLImplName(gl::GLImplementation impl) { switch (impl) { case gl::kGLImplementationDesktopGL: return gl::kGLImplementationDesktopName; case gl::kGLImplementationOSMesaGL: return gl::kGLImplementationOSMesaName; case gl::kGLImplementationEGLGLES2: return gl::kGLImplementationEGLName; default: return "unknown"; } }
null
0
const char* GetGLImplName(gl::GLImplementation impl) { switch (impl) { case gl::kGLImplementationDesktopGL: return gl::kGLImplementationDesktopName; case gl::kGLImplementationOSMesaGL: return gl::kGLImplementationOSMesaName; case gl::kGLImplementationEGLGLES2: return gl::kGLImplementationEGLName; default: return "unknown"; } }
@@ -72,10 +72,8 @@ #include "shared/common/oxide_content_client.h" #include "shared/common/oxide_form_factor.h" -#include "oxide_browser_context.h" #include "oxide_form_factor_detection.h" #include "oxide_message_pump.h" -#include "oxide_web_contents_unloader.h" namespace content { @@ -581,14 +579,6 @@ void BrowserProcessMainImpl::Shutdown() { MessagePump::Get()->Stop(); - WebContentsUnloader::GetInstance()->Shutdown(); - - if (process_model_ != PROCESS_MODEL_SINGLE_PROCESS) { - // In single process mode, we do this check after destroying - // threads, as we hold the single BrowserContext alive until then - BrowserContext::AssertNoContextsExist(); - } - browser_main_runner_->Shutdown(); browser_main_runner_.reset();
CWE-20
null
null
13,815
base::FilePath GetSharedMemoryPath(base::Environment* env) { std::string snap_name; if (env->GetVar("SNAP_NAME", &snap_name)) { return base::FilePath(std::string("/dev/shm/snap.") + snap_name + ".oxide"); } std::string app_pkgname; if (env->GetVar("APP_ID", &app_pkgname)) { app_pkgname = app_pkgname.substr(0, app_pkgname.find("_")); if (!app_pkgname.empty()) { return base::FilePath(std::string("/dev/shm/") + app_pkgname + ".oxide"); } } return base::FilePath("/dev/shm"); }
null
0
base::FilePath GetSharedMemoryPath(base::Environment* env) { std::string snap_name; if (env->GetVar("SNAP_NAME", &snap_name)) { return base::FilePath(std::string("/dev/shm/snap.") + snap_name + ".oxide"); } std::string app_pkgname; if (env->GetVar("APP_ID", &app_pkgname)) { app_pkgname = app_pkgname.substr(0, app_pkgname.find("_")); if (!app_pkgname.empty()) { return base::FilePath(std::string("/dev/shm/") + app_pkgname + ".oxide"); } } return base::FilePath("/dev/shm"); }
@@ -72,10 +72,8 @@ #include "shared/common/oxide_content_client.h" #include "shared/common/oxide_form_factor.h" -#include "oxide_browser_context.h" #include "oxide_form_factor_detection.h" #include "oxide_message_pump.h" -#include "oxide_web_contents_unloader.h" namespace content { @@ -581,14 +579,6 @@ void BrowserProcessMainImpl::Shutdown() { MessagePump::Get()->Stop(); - WebContentsUnloader::GetInstance()->Shutdown(); - - if (process_model_ != PROCESS_MODEL_SINGLE_PROCESS) { - // In single process mode, we do this check after destroying - // threads, as we hold the single BrowserContext alive until then - BrowserContext::AssertNoContextsExist(); - } - browser_main_runner_->Shutdown(); browser_main_runner_.reset();
CWE-20
null
null
13,816
base::FilePath GetSubprocessPath(base::Environment* env) { std::string override_subprocess_path = GetEnvironmentOption("SUBPROCESS_PATH", env); if (!override_subprocess_path.empty()) { #if defined(OS_POSIX) base::FilePath subprocess_path(override_subprocess_path); #else base::FilePath subprocess_path(base::UTF8ToUTF16(override_subprocess_path)); #endif return base::MakeAbsoluteFilePath(subprocess_path); } base::FilePath subprocess_exe = base::FilePath(FILE_PATH_LITERAL(OXIDE_SUBPROCESS_PATH)); if (subprocess_exe.IsAbsolute()) { return subprocess_exe; } #if defined(OS_LINUX) Dl_info info; int rv = dladdr(reinterpret_cast<void *>(BrowserProcessMain::GetInstance), &info); DCHECK_NE(rv, 0) << "Failed to determine module path"; base::FilePath subprocess_rel(subprocess_exe); subprocess_exe = base::FilePath(info.dli_fname).DirName(); std::vector<base::FilePath::StringType> components; subprocess_rel.GetComponents(&components); for (size_t i = 0; i < components.size(); ++i) { subprocess_exe = subprocess_exe.Append(components[i]); } #else # error "GetSubprocessPath is not implemented for this platform" #endif return subprocess_exe; }
null
0
base::FilePath GetSubprocessPath(base::Environment* env) { std::string override_subprocess_path = GetEnvironmentOption("SUBPROCESS_PATH", env); if (!override_subprocess_path.empty()) { #if defined(OS_POSIX) base::FilePath subprocess_path(override_subprocess_path); #else base::FilePath subprocess_path(base::UTF8ToUTF16(override_subprocess_path)); #endif return base::MakeAbsoluteFilePath(subprocess_path); } base::FilePath subprocess_exe = base::FilePath(FILE_PATH_LITERAL(OXIDE_SUBPROCESS_PATH)); if (subprocess_exe.IsAbsolute()) { return subprocess_exe; } #if defined(OS_LINUX) Dl_info info; int rv = dladdr(reinterpret_cast<void *>(BrowserProcessMain::GetInstance), &info); DCHECK_NE(rv, 0) << "Failed to determine module path"; base::FilePath subprocess_rel(subprocess_exe); subprocess_exe = base::FilePath(info.dli_fname).DirName(); std::vector<base::FilePath::StringType> components; subprocess_rel.GetComponents(&components); for (size_t i = 0; i < components.size(); ++i) { subprocess_exe = subprocess_exe.Append(components[i]); } #else # error "GetSubprocessPath is not implemented for this platform" #endif return subprocess_exe; }
@@ -72,10 +72,8 @@ #include "shared/common/oxide_content_client.h" #include "shared/common/oxide_form_factor.h" -#include "oxide_browser_context.h" #include "oxide_form_factor_detection.h" #include "oxide_message_pump.h" -#include "oxide_web_contents_unloader.h" namespace content { @@ -581,14 +579,6 @@ void BrowserProcessMainImpl::Shutdown() { MessagePump::Get()->Stop(); - WebContentsUnloader::GetInstance()->Shutdown(); - - if (process_model_ != PROCESS_MODEL_SINGLE_PROCESS) { - // In single process mode, we do this check after destroying - // threads, as we hold the single BrowserContext alive until then - BrowserContext::AssertNoContextsExist(); - } - browser_main_runner_->Shutdown(); browser_main_runner_.reset();
CWE-20
null
null
13,817
void InitializeCommandLine(const std::string& argv0, const base::FilePath& subprocess_path, ProcessModel process_model, gl::GLImplementation gl_impl, base::Environment* env) { const char* argv0_c = nullptr; if (!argv0.empty()) { argv0_c = argv0.c_str(); } CHECK(base::CommandLine::Init(argv0_c ? 1 : 0, argv0_c ? &argv0_c : nullptr)) << "CommandLine already exists. Did you call BrowserProcessMain::Start " "in a child process?"; base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); command_line->AppendSwitchASCII(switches::kBrowserSubprocessPath, subprocess_path.value().c_str()); command_line->AppendSwitch(switches::kInProcessGPU); command_line->AppendSwitch(switches::kDisableGpuShaderDiskCache); command_line->AppendSwitch(switches::kDisableGpuEarlyInit); command_line->AppendSwitch(switches::kUIPrioritizeInGpuProcess); command_line->AppendSwitch(switches::kEnableSmoothScrolling); command_line->AppendSwitchASCII(switches::kProfilerTiming, switches::kProfilerTimingDisabledValue); if (gl_impl == gl::kGLImplementationNone || IsEnvironmentOptionEnabled("DISABLE_GPU", env)) { command_line->AppendSwitch(switches::kDisableGpu); } else { command_line->AppendSwitchASCII(switches::kUseGL, GetGLImplName(gl_impl)); } if (IsEnvironmentOptionEnabled("DISABLE_GPU_COMPOSITING", env)) { command_line->AppendSwitch(switches::kDisableGpuCompositing); } std::string renderer_cmd_prefix = GetEnvironmentOption("RENDERER_CMD_PREFIX", env); if (!renderer_cmd_prefix.empty()) { command_line->AppendSwitchASCII(switches::kRendererCmdPrefix, renderer_cmd_prefix); } if (IsEnvironmentOptionEnabled("NO_SANDBOX", env)) { command_line->AppendSwitch(switches::kNoSandbox); } else { command_line->AppendSwitch(switches::kDisableNamespaceSandbox); if (IsEnvironmentOptionEnabled("DISABLE_SETUID_SANDBOX", env)) { command_line->AppendSwitch(switches::kDisableSetuidSandbox); } if (IsEnvironmentOptionEnabled("DISABLE_SECCOMP_FILTER_SANDBOX", env)) { command_line->AppendSwitch(switches::kDisableSeccompFilterSandbox); } } if (IsEnvironmentOptionEnabled("IGNORE_GPU_BLACKLIST", env)) { command_line->AppendSwitch(switches::kIgnoreGpuBlacklist); } if (IsEnvironmentOptionEnabled("DISABLE_GPU_DRIVER_BUG_WORKAROUNDS", env)) { command_line->AppendSwitch(switches::kDisableGpuDriverBugWorkarounds); } if (IsEnvironmentOptionEnabled("ENABLE_GPU_SERVICE_LOGGING", env)) { command_line->AppendSwitch(switches::kEnableGPUServiceLogging); } if (IsEnvironmentOptionEnabled("ENABLE_GPU_DEBUGGING", env)) { command_line->AppendSwitch(switches::kEnableGPUDebugging); } if (process_model == PROCESS_MODEL_SINGLE_PROCESS) { command_line->AppendSwitch(switches::kSingleProcess); } else if (process_model == PROCESS_MODEL_PROCESS_PER_VIEW) { command_line->AppendSwitch(switches::kProcessPerTab); } else if (process_model == PROCESS_MODEL_PROCESS_PER_SITE) { command_line->AppendSwitch(switches::kProcessPerSite); } else if (process_model == PROCESS_MODEL_SITE_PER_PROCESS) { command_line->AppendSwitch(switches::kSitePerProcess); } else { DCHECK(process_model == PROCESS_MODEL_PROCESS_PER_SITE_INSTANCE || process_model == PROCESS_MODEL_MULTI_PROCESS); } if (IsEnvironmentOptionEnabled("ALLOW_SANDBOX_DEBUGGING", env)) { command_line->AppendSwitch(switches::kAllowSandboxDebugging); } if (IsEnvironmentOptionEnabled("ENABLE_MEDIA_HUB_AUDIO", env)) { command_line->AppendSwitch(switches::kEnableMediaHubAudio); } std::string mediahub_fixed_session_domains = GetEnvironmentOption("MEDIA_HUB_FIXED_SESSION_DOMAINS", env); if (!mediahub_fixed_session_domains.empty()) { command_line->AppendSwitchASCII(switches::kMediaHubFixedSessionDomains, mediahub_fixed_session_domains); if (!IsEnvironmentOptionEnabled("ENABLE_MEDIA_HUB_AUDIO", env)) { command_line->AppendSwitch(switches::kEnableMediaHubAudio); } } if (IsEnvironmentOptionEnabled("TESTING_MODE", env)) { command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); } #if defined(OS_POSIX) command_line->AppendSwitchPath(switches::kSharedMemoryOverridePath, GetSharedMemoryPath(env)); #endif const std::string& verbose_log_level = GetEnvironmentOption("VERBOSE_LOG_LEVEL", env); if (!verbose_log_level.empty()) { command_line->AppendSwitch(switches::kEnableLogging); command_line->AppendSwitchASCII(switches::kV, verbose_log_level); } const std::string& extra_cmd_arg_list = GetEnvironmentOption("EXTRA_CMD_ARGS", env); if (!extra_cmd_arg_list.empty()) { std::vector<std::string> args = base::SplitString(extra_cmd_arg_list, base::kWhitespaceASCII, base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); base::CommandLine::StringVector new_args; new_args.push_back(command_line->argv()[0]); new_args.insert(new_args.end(), args.begin(), args.end()); base::CommandLine extra_cmd_line(new_args); command_line->AppendArguments(extra_cmd_line, false); } }
null
0
void InitializeCommandLine(const std::string& argv0, const base::FilePath& subprocess_path, ProcessModel process_model, gl::GLImplementation gl_impl, base::Environment* env) { const char* argv0_c = nullptr; if (!argv0.empty()) { argv0_c = argv0.c_str(); } CHECK(base::CommandLine::Init(argv0_c ? 1 : 0, argv0_c ? &argv0_c : nullptr)) << "CommandLine already exists. Did you call BrowserProcessMain::Start " "in a child process?"; base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); command_line->AppendSwitchASCII(switches::kBrowserSubprocessPath, subprocess_path.value().c_str()); command_line->AppendSwitch(switches::kInProcessGPU); command_line->AppendSwitch(switches::kDisableGpuShaderDiskCache); command_line->AppendSwitch(switches::kDisableGpuEarlyInit); command_line->AppendSwitch(switches::kUIPrioritizeInGpuProcess); command_line->AppendSwitch(switches::kEnableSmoothScrolling); command_line->AppendSwitchASCII(switches::kProfilerTiming, switches::kProfilerTimingDisabledValue); if (gl_impl == gl::kGLImplementationNone || IsEnvironmentOptionEnabled("DISABLE_GPU", env)) { command_line->AppendSwitch(switches::kDisableGpu); } else { command_line->AppendSwitchASCII(switches::kUseGL, GetGLImplName(gl_impl)); } if (IsEnvironmentOptionEnabled("DISABLE_GPU_COMPOSITING", env)) { command_line->AppendSwitch(switches::kDisableGpuCompositing); } std::string renderer_cmd_prefix = GetEnvironmentOption("RENDERER_CMD_PREFIX", env); if (!renderer_cmd_prefix.empty()) { command_line->AppendSwitchASCII(switches::kRendererCmdPrefix, renderer_cmd_prefix); } if (IsEnvironmentOptionEnabled("NO_SANDBOX", env)) { command_line->AppendSwitch(switches::kNoSandbox); } else { command_line->AppendSwitch(switches::kDisableNamespaceSandbox); if (IsEnvironmentOptionEnabled("DISABLE_SETUID_SANDBOX", env)) { command_line->AppendSwitch(switches::kDisableSetuidSandbox); } if (IsEnvironmentOptionEnabled("DISABLE_SECCOMP_FILTER_SANDBOX", env)) { command_line->AppendSwitch(switches::kDisableSeccompFilterSandbox); } } if (IsEnvironmentOptionEnabled("IGNORE_GPU_BLACKLIST", env)) { command_line->AppendSwitch(switches::kIgnoreGpuBlacklist); } if (IsEnvironmentOptionEnabled("DISABLE_GPU_DRIVER_BUG_WORKAROUNDS", env)) { command_line->AppendSwitch(switches::kDisableGpuDriverBugWorkarounds); } if (IsEnvironmentOptionEnabled("ENABLE_GPU_SERVICE_LOGGING", env)) { command_line->AppendSwitch(switches::kEnableGPUServiceLogging); } if (IsEnvironmentOptionEnabled("ENABLE_GPU_DEBUGGING", env)) { command_line->AppendSwitch(switches::kEnableGPUDebugging); } if (process_model == PROCESS_MODEL_SINGLE_PROCESS) { command_line->AppendSwitch(switches::kSingleProcess); } else if (process_model == PROCESS_MODEL_PROCESS_PER_VIEW) { command_line->AppendSwitch(switches::kProcessPerTab); } else if (process_model == PROCESS_MODEL_PROCESS_PER_SITE) { command_line->AppendSwitch(switches::kProcessPerSite); } else if (process_model == PROCESS_MODEL_SITE_PER_PROCESS) { command_line->AppendSwitch(switches::kSitePerProcess); } else { DCHECK(process_model == PROCESS_MODEL_PROCESS_PER_SITE_INSTANCE || process_model == PROCESS_MODEL_MULTI_PROCESS); } if (IsEnvironmentOptionEnabled("ALLOW_SANDBOX_DEBUGGING", env)) { command_line->AppendSwitch(switches::kAllowSandboxDebugging); } if (IsEnvironmentOptionEnabled("ENABLE_MEDIA_HUB_AUDIO", env)) { command_line->AppendSwitch(switches::kEnableMediaHubAudio); } std::string mediahub_fixed_session_domains = GetEnvironmentOption("MEDIA_HUB_FIXED_SESSION_DOMAINS", env); if (!mediahub_fixed_session_domains.empty()) { command_line->AppendSwitchASCII(switches::kMediaHubFixedSessionDomains, mediahub_fixed_session_domains); if (!IsEnvironmentOptionEnabled("ENABLE_MEDIA_HUB_AUDIO", env)) { command_line->AppendSwitch(switches::kEnableMediaHubAudio); } } if (IsEnvironmentOptionEnabled("TESTING_MODE", env)) { command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); } #if defined(OS_POSIX) command_line->AppendSwitchPath(switches::kSharedMemoryOverridePath, GetSharedMemoryPath(env)); #endif const std::string& verbose_log_level = GetEnvironmentOption("VERBOSE_LOG_LEVEL", env); if (!verbose_log_level.empty()) { command_line->AppendSwitch(switches::kEnableLogging); command_line->AppendSwitchASCII(switches::kV, verbose_log_level); } const std::string& extra_cmd_arg_list = GetEnvironmentOption("EXTRA_CMD_ARGS", env); if (!extra_cmd_arg_list.empty()) { std::vector<std::string> args = base::SplitString(extra_cmd_arg_list, base::kWhitespaceASCII, base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); base::CommandLine::StringVector new_args; new_args.push_back(command_line->argv()[0]); new_args.insert(new_args.end(), args.begin(), args.end()); base::CommandLine extra_cmd_line(new_args); command_line->AppendArguments(extra_cmd_line, false); } }
@@ -72,10 +72,8 @@ #include "shared/common/oxide_content_client.h" #include "shared/common/oxide_form_factor.h" -#include "oxide_browser_context.h" #include "oxide_form_factor_detection.h" #include "oxide_message_pump.h" -#include "oxide_web_contents_unloader.h" namespace content { @@ -581,14 +579,6 @@ void BrowserProcessMainImpl::Shutdown() { MessagePump::Get()->Stop(); - WebContentsUnloader::GetInstance()->Shutdown(); - - if (process_model_ != PROCESS_MODEL_SINGLE_PROCESS) { - // In single process mode, we do this check after destroying - // threads, as we hold the single BrowserContext alive until then - BrowserContext::AssertNoContextsExist(); - } - browser_main_runner_->Shutdown(); browser_main_runner_.reset();
CWE-20
null
null
13,818
bool IsEnvironmentOptionEnabled(base::StringPiece option, base::Environment* env) { std::string name("OXIDE_"); name += option.data(); std::string result; if (!env->GetVar(name, &result)) { return false; } return result.size() > 0 && result[0] != '0'; }
null
0
bool IsEnvironmentOptionEnabled(base::StringPiece option, base::Environment* env) { std::string name("OXIDE_"); name += option.data(); std::string result; if (!env->GetVar(name, &result)) { return false; } return result.size() > 0 && result[0] != '0'; }
@@ -72,10 +72,8 @@ #include "shared/common/oxide_content_client.h" #include "shared/common/oxide_form_factor.h" -#include "oxide_browser_context.h" #include "oxide_form_factor_detection.h" #include "oxide_message_pump.h" -#include "oxide_web_contents_unloader.h" namespace content { @@ -581,14 +579,6 @@ void BrowserProcessMainImpl::Shutdown() { MessagePump::Get()->Stop(); - WebContentsUnloader::GetInstance()->Shutdown(); - - if (process_model_ != PROCESS_MODEL_SINGLE_PROCESS) { - // In single process mode, we do this check after destroying - // threads, as we hold the single BrowserContext alive until then - BrowserContext::AssertNoContextsExist(); - } - browser_main_runner_->Shutdown(); browser_main_runner_.reset();
CWE-20
null
null
13,819
bool IsUnsupportedProcessModel(ProcessModel process_model) { switch (process_model) { case PROCESS_MODEL_MULTI_PROCESS: case PROCESS_MODEL_SINGLE_PROCESS: case PROCESS_MODEL_PROCESS_PER_SITE_INSTANCE: return false; default: return true; } }
null
0
bool IsUnsupportedProcessModel(ProcessModel process_model) { switch (process_model) { case PROCESS_MODEL_MULTI_PROCESS: case PROCESS_MODEL_SINGLE_PROCESS: case PROCESS_MODEL_PROCESS_PER_SITE_INSTANCE: return false; default: return true; } }
@@ -72,10 +72,8 @@ #include "shared/common/oxide_content_client.h" #include "shared/common/oxide_form_factor.h" -#include "oxide_browser_context.h" #include "oxide_form_factor_detection.h" #include "oxide_message_pump.h" -#include "oxide_web_contents_unloader.h" namespace content { @@ -581,14 +579,6 @@ void BrowserProcessMainImpl::Shutdown() { MessagePump::Get()->Stop(); - WebContentsUnloader::GetInstance()->Shutdown(); - - if (process_model_ != PROCESS_MODEL_SINGLE_PROCESS) { - // In single process mode, we do this check after destroying - // threads, as we hold the single BrowserContext alive until then - BrowserContext::AssertNoContextsExist(); - } - browser_main_runner_->Shutdown(); browser_main_runner_.reset();
CWE-20
null
null
13,820
static void Set(ContentMainDelegate* delegate, bool single_process) { ContentClient* content_client = oxide::ContentClient::GetInstance(); content_client->browser_ = delegate->CreateContentBrowserClient(); if (single_process) { content_client->renderer_ = delegate->CreateContentRendererClient(); content_client->utility_ = delegate->CreateContentUtilityClient(); } }
null
0
static void Set(ContentMainDelegate* delegate, bool single_process) { ContentClient* content_client = oxide::ContentClient::GetInstance(); content_client->browser_ = delegate->CreateContentBrowserClient(); if (single_process) { content_client->renderer_ = delegate->CreateContentRendererClient(); content_client->utility_ = delegate->CreateContentUtilityClient(); } }
@@ -72,10 +72,8 @@ #include "shared/common/oxide_content_client.h" #include "shared/common/oxide_form_factor.h" -#include "oxide_browser_context.h" #include "oxide_form_factor_detection.h" #include "oxide_message_pump.h" -#include "oxide_web_contents_unloader.h" namespace content { @@ -581,14 +579,6 @@ void BrowserProcessMainImpl::Shutdown() { MessagePump::Get()->Stop(); - WebContentsUnloader::GetInstance()->Shutdown(); - - if (process_model_ != PROCESS_MODEL_SINGLE_PROCESS) { - // In single process mode, we do this check after destroying - // threads, as we hold the single BrowserContext alive until then - BrowserContext::AssertNoContextsExist(); - } - browser_main_runner_->Shutdown(); browser_main_runner_.reset();
CWE-20
null
null
13,821
void SetupAndVerifySignalHandlers() { struct sigaction sigact; CHECK(sigaction(SIGCHLD, nullptr, &sigact) == 0); CHECK(sigact.sa_handler != SIG_IGN) << "SIGCHLD should not be ignored"; CHECK((sigact.sa_flags & SA_NOCLDWAIT) == 0) << "SA_NOCLDWAIT should not be set"; CHECK(sigaction(SIGPIPE, nullptr, &sigact) == 0); if (sigact.sa_handler == SIG_DFL) { sigact.sa_handler = SIG_IGN; CHECK(sigaction(SIGPIPE, &sigact, nullptr) == 0); } }
null
0
void SetupAndVerifySignalHandlers() { struct sigaction sigact; CHECK(sigaction(SIGCHLD, nullptr, &sigact) == 0); CHECK(sigact.sa_handler != SIG_IGN) << "SIGCHLD should not be ignored"; CHECK((sigact.sa_flags & SA_NOCLDWAIT) == 0) << "SA_NOCLDWAIT should not be set"; CHECK(sigaction(SIGPIPE, nullptr, &sigact) == 0); if (sigact.sa_handler == SIG_DFL) { sigact.sa_handler = SIG_IGN; CHECK(sigaction(SIGPIPE, &sigact, nullptr) == 0); } }
@@ -72,10 +72,8 @@ #include "shared/common/oxide_content_client.h" #include "shared/common/oxide_form_factor.h" -#include "oxide_browser_context.h" #include "oxide_form_factor_detection.h" #include "oxide_message_pump.h" -#include "oxide_web_contents_unloader.h" namespace content { @@ -581,14 +579,6 @@ void BrowserProcessMainImpl::Shutdown() { MessagePump::Get()->Stop(); - WebContentsUnloader::GetInstance()->Shutdown(); - - if (process_model_ != PROCESS_MODEL_SINGLE_PROCESS) { - // In single process mode, we do this check after destroying - // threads, as we hold the single BrowserContext alive until then - BrowserContext::AssertNoContextsExist(); - } - browser_main_runner_->Shutdown(); browser_main_runner_.reset();
CWE-20
null
null
13,822
content::BrowserMainParts* ContentBrowserClient::CreateBrowserMainParts( const content::MainFunctionParams& parameters) { return new BrowserMainParts(); }
null
0
content::BrowserMainParts* ContentBrowserClient::CreateBrowserMainParts( const content::MainFunctionParams& parameters) { return new BrowserMainParts(); }
@@ -46,7 +46,9 @@ #include "shared/common/oxide_content_client.h" #include "display_form_factor.h" +#include "in_process_renderer_observer.h" #include "oxide_browser_context.h" +#include "oxide_browser_context_destroyer.h" #include "oxide_browser_main_parts.h" #include "oxide_browser_platform_integration.h" #include "oxide_browser_process_main.h" @@ -92,12 +94,17 @@ content::BrowserMainParts* ContentBrowserClient::CreateBrowserMainParts( void ContentBrowserClient::RenderProcessWillLaunch( content::RenderProcessHost* host) { + if (content::RenderProcessHost::run_renderer_in_process()) { + host->AddObserver(new InProcessRendererObserver()); + } + host->AddFilter(new RenderMessageFilter(host)); } -std::string ContentBrowserClient::GetAcceptLangs( - content::BrowserContext* browser_context) { - return UserAgentSettings::Get(browser_context)->GetAcceptLangs(); +void ContentBrowserClient::SiteInstanceGotProcess( + content::SiteInstance* site_instance) { + BrowserContextDestroyer::RenderProcessHostAssignedToSiteInstance( + site_instance->GetProcess()); } void ContentBrowserClient::AppendExtraCommandLineSwitches( @@ -130,6 +137,16 @@ void ContentBrowserClient::AppendExtraCommandLineSwitches( } } +std::string +ContentBrowserClient::GetApplicationLocale() { + return application_locale_; +} + +std::string ContentBrowserClient::GetAcceptLangs( + content::BrowserContext* browser_context) { + return UserAgentSettings::Get(browser_context)->GetAcceptLangs(); +} + bool ContentBrowserClient::AllowGetCookie(const GURL& url, const GURL& first_party, const net::CookieList& cookie_list, @@ -339,11 +356,6 @@ ContentBrowserClient::GetOsTypeOverrideForGpuDataManager( #endif } -std::string -ContentBrowserClient::GetApplicationLocale() { - return application_locale_; -} - ContentBrowserClient::ContentBrowserClient( const std::string& application_locale, BrowserPlatformIntegration* integration)
CWE-20
null
null
13,823
CatalogueCloseFont (FontPathElementPtr fpe, FontPtr pFont) { /* Note: this gets called with the actual subfpe where we found * the font, not the catalogue fpe. */ FontFileCloseFont(fpe, pFont); }
Overflow
0
CatalogueCloseFont (FontPathElementPtr fpe, FontPtr pFont) { /* Note: this gets called with the actual subfpe where we found * the font, not the catalogue fpe. */ FontFileCloseFont(fpe, pFont); }
@@ -156,7 +156,7 @@ CatalogueRescan (FontPathElementPtr fpe) while (entry = readdir(dir), entry != NULL) { snprintf(link, sizeof link, "%s/%s", path, entry->d_name); - len = readlink(link, dest, sizeof dest); + len = readlink(link, dest, sizeof dest - 1); if (len < 0) continue;
CWE-119
null
null
13,824
CatalogueFreeFPE (FontPathElementPtr fpe) { CataloguePtr cat = fpe->private; /* If the catalogue is modified while the xserver has fonts open * from the previous subfpes, we'll unref the old subfpes when we * reload the catalogue, and the xserver will the call FreeFPE on * them once it drops its last reference. Thus, the FreeFPE call * for the subfpe ends up here and we just forward it to * FontFileFreeFPE. */ if (!CatalogueNameCheck (fpe->name)) return FontFileFreeFPE (fpe); CatalogueUnrefFPEs (fpe); xfree(cat->fpeList); xfree(cat); return Successful; }
Overflow
0
CatalogueFreeFPE (FontPathElementPtr fpe) { CataloguePtr cat = fpe->private; /* If the catalogue is modified while the xserver has fonts open * from the previous subfpes, we'll unref the old subfpes when we * reload the catalogue, and the xserver will the call FreeFPE on * them once it drops its last reference. Thus, the FreeFPE call * for the subfpe ends up here and we just forward it to * FontFileFreeFPE. */ if (!CatalogueNameCheck (fpe->name)) return FontFileFreeFPE (fpe); CatalogueUnrefFPEs (fpe); xfree(cat->fpeList); xfree(cat); return Successful; }
@@ -156,7 +156,7 @@ CatalogueRescan (FontPathElementPtr fpe) while (entry = readdir(dir), entry != NULL) { snprintf(link, sizeof link, "%s/%s", path, entry->d_name); - len = readlink(link, dest, sizeof dest); + len = readlink(link, dest, sizeof dest - 1); if (len < 0) continue;
CWE-119
null
null
13,825
CatalogueInitFPE (FontPathElementPtr fpe) { CataloguePtr cat; cat = (CataloguePtr) xalloc(sizeof *cat); if (cat == NULL) return AllocError; fpe->private = (pointer) cat; cat->fpeCount = 0; cat->fpeAlloc = 0; cat->fpeList = NULL; cat->mtime = 0; return CatalogueRescan (fpe); }
Overflow
0
CatalogueInitFPE (FontPathElementPtr fpe) { CataloguePtr cat; cat = (CataloguePtr) xalloc(sizeof *cat); if (cat == NULL) return AllocError; fpe->private = (pointer) cat; cat->fpeCount = 0; cat->fpeAlloc = 0; cat->fpeList = NULL; cat->mtime = 0; return CatalogueRescan (fpe); }
@@ -156,7 +156,7 @@ CatalogueRescan (FontPathElementPtr fpe) while (entry = readdir(dir), entry != NULL) { snprintf(link, sizeof link, "%s/%s", path, entry->d_name); - len = readlink(link, dest, sizeof dest); + len = readlink(link, dest, sizeof dest - 1); if (len < 0) continue;
CWE-119
null
null
13,826
CatalogueListFonts (pointer client, FontPathElementPtr fpe, char *pat, int len, int max, FontNamesPtr names) { CataloguePtr cat = fpe->private; FontPathElementPtr subfpe; FontDirectoryPtr dir; int i; CatalogueRescan (fpe); for (i = 0; i < cat->fpeCount; i++) { subfpe = cat->fpeList[i]; dir = subfpe->private; FontFileListFonts(client, subfpe, pat, len, max, names); } return Successful; }
Overflow
0
CatalogueListFonts (pointer client, FontPathElementPtr fpe, char *pat, int len, int max, FontNamesPtr names) { CataloguePtr cat = fpe->private; FontPathElementPtr subfpe; FontDirectoryPtr dir; int i; CatalogueRescan (fpe); for (i = 0; i < cat->fpeCount; i++) { subfpe = cat->fpeList[i]; dir = subfpe->private; FontFileListFonts(client, subfpe, pat, len, max, names); } return Successful; }
@@ -156,7 +156,7 @@ CatalogueRescan (FontPathElementPtr fpe) while (entry = readdir(dir), entry != NULL) { snprintf(link, sizeof link, "%s/%s", path, entry->d_name); - len = readlink(link, dest, sizeof dest); + len = readlink(link, dest, sizeof dest - 1); if (len < 0) continue;
CWE-119
null
null
13,827
CatalogueListNextFontOrAlias(pointer client, FontPathElementPtr fpe, char **namep, int *namelenp, char **resolvedp, int *resolvedlenp, pointer private) { LFWIDataPtr data = private; CataloguePtr cat = fpe->private; int ret; if (data->current == cat->fpeCount) { xfree(data); return BadFontName; } ret = FontFileListNextFontOrAlias(client, cat->fpeList[data->current], namep, namelenp, resolvedp, resolvedlenp, data->privates[data->current]); if (ret == BadFontName) { data->current++; return CatalogueListNextFontOrAlias(client, fpe, namep, namelenp, resolvedp, resolvedlenp, private); } return ret; }
Overflow
0
CatalogueListNextFontOrAlias(pointer client, FontPathElementPtr fpe, char **namep, int *namelenp, char **resolvedp, int *resolvedlenp, pointer private) { LFWIDataPtr data = private; CataloguePtr cat = fpe->private; int ret; if (data->current == cat->fpeCount) { xfree(data); return BadFontName; } ret = FontFileListNextFontOrAlias(client, cat->fpeList[data->current], namep, namelenp, resolvedp, resolvedlenp, data->privates[data->current]); if (ret == BadFontName) { data->current++; return CatalogueListNextFontOrAlias(client, fpe, namep, namelenp, resolvedp, resolvedlenp, private); } return ret; }
@@ -156,7 +156,7 @@ CatalogueRescan (FontPathElementPtr fpe) while (entry = readdir(dir), entry != NULL) { snprintf(link, sizeof link, "%s/%s", path, entry->d_name); - len = readlink(link, dest, sizeof dest); + len = readlink(link, dest, sizeof dest - 1); if (len < 0) continue;
CWE-119
null
null
13,828
CatalogueListNextFontWithInfo(pointer client, FontPathElementPtr fpe, char **namep, int *namelenp, FontInfoPtr *pFontInfo, int *numFonts, pointer private) { LFWIDataPtr data = private; CataloguePtr cat = fpe->private; int ret; if (data->current == cat->fpeCount) { xfree(data); return BadFontName; } ret = FontFileListNextFontWithInfo(client, cat->fpeList[data->current], namep, namelenp, pFontInfo, numFonts, data->privates[data->current]); if (ret == BadFontName) { data->current++; return CatalogueListNextFontWithInfo(client, fpe, namep, namelenp, pFontInfo, numFonts, private); } return ret; }
Overflow
0
CatalogueListNextFontWithInfo(pointer client, FontPathElementPtr fpe, char **namep, int *namelenp, FontInfoPtr *pFontInfo, int *numFonts, pointer private) { LFWIDataPtr data = private; CataloguePtr cat = fpe->private; int ret; if (data->current == cat->fpeCount) { xfree(data); return BadFontName; } ret = FontFileListNextFontWithInfo(client, cat->fpeList[data->current], namep, namelenp, pFontInfo, numFonts, data->privates[data->current]); if (ret == BadFontName) { data->current++; return CatalogueListNextFontWithInfo(client, fpe, namep, namelenp, pFontInfo, numFonts, private); } return ret; }
@@ -156,7 +156,7 @@ CatalogueRescan (FontPathElementPtr fpe) while (entry = readdir(dir), entry != NULL) { snprintf(link, sizeof link, "%s/%s", path, entry->d_name); - len = readlink(link, dest, sizeof dest); + len = readlink(link, dest, sizeof dest - 1); if (len < 0) continue;
CWE-119
null
null
13,829
CatalogueNameCheck (char *name) { return strncmp(name, CataloguePrefix, sizeof(CataloguePrefix) - 1) == 0; }
Overflow
0
CatalogueNameCheck (char *name) { return strncmp(name, CataloguePrefix, sizeof(CataloguePrefix) - 1) == 0; }
@@ -156,7 +156,7 @@ CatalogueRescan (FontPathElementPtr fpe) while (entry = readdir(dir), entry != NULL) { snprintf(link, sizeof link, "%s/%s", path, entry->d_name); - len = readlink(link, dest, sizeof dest); + len = readlink(link, dest, sizeof dest - 1); if (len < 0) continue;
CWE-119
null
null
13,830
CatalogueOpenFont (pointer client, FontPathElementPtr fpe, Mask flags, char *name, int namelen, fsBitmapFormat format, fsBitmapFormatMask fmask, XID id, FontPtr *pFont, char **aliasName, FontPtr non_cachable_font) { CataloguePtr cat = fpe->private; FontPathElementPtr subfpe; FontDirectoryPtr dir; int i, status; CatalogueRescan (fpe); for (i = 0; i < cat->fpeCount; i++) { subfpe = cat->fpeList[i]; dir = subfpe->private; status = FontFileOpenFont(client, subfpe, flags, name, namelen, format, fmask, id, pFont, aliasName, non_cachable_font); if (status == Successful || status == FontNameAlias) return status; } return BadFontName; }
Overflow
0
CatalogueOpenFont (pointer client, FontPathElementPtr fpe, Mask flags, char *name, int namelen, fsBitmapFormat format, fsBitmapFormatMask fmask, XID id, FontPtr *pFont, char **aliasName, FontPtr non_cachable_font) { CataloguePtr cat = fpe->private; FontPathElementPtr subfpe; FontDirectoryPtr dir; int i, status; CatalogueRescan (fpe); for (i = 0; i < cat->fpeCount; i++) { subfpe = cat->fpeList[i]; dir = subfpe->private; status = FontFileOpenFont(client, subfpe, flags, name, namelen, format, fmask, id, pFont, aliasName, non_cachable_font); if (status == Successful || status == FontNameAlias) return status; } return BadFontName; }
@@ -156,7 +156,7 @@ CatalogueRescan (FontPathElementPtr fpe) while (entry = readdir(dir), entry != NULL) { snprintf(link, sizeof link, "%s/%s", path, entry->d_name); - len = readlink(link, dest, sizeof dest); + len = readlink(link, dest, sizeof dest - 1); if (len < 0) continue;
CWE-119
null
null
13,831
CatalogueRegisterLocalFpeFunctions (void) { RegisterFPEFunctions(CatalogueNameCheck, CatalogueInitFPE, CatalogueFreeFPE, CatalogueResetFPE, CatalogueOpenFont, CatalogueCloseFont, CatalogueListFonts, CatalogueStartListFontsWithInfo, CatalogueListNextFontWithInfo, NULL, NULL, NULL, CatalogueStartListFontsAndAliases, CatalogueListNextFontOrAlias, FontFileEmptyBitmapSource); }
Overflow
0
CatalogueRegisterLocalFpeFunctions (void) { RegisterFPEFunctions(CatalogueNameCheck, CatalogueInitFPE, CatalogueFreeFPE, CatalogueResetFPE, CatalogueOpenFont, CatalogueCloseFont, CatalogueListFonts, CatalogueStartListFontsWithInfo, CatalogueListNextFontWithInfo, NULL, NULL, NULL, CatalogueStartListFontsAndAliases, CatalogueListNextFontOrAlias, FontFileEmptyBitmapSource); }
@@ -156,7 +156,7 @@ CatalogueRescan (FontPathElementPtr fpe) while (entry = readdir(dir), entry != NULL) { snprintf(link, sizeof link, "%s/%s", path, entry->d_name); - len = readlink(link, dest, sizeof dest); + len = readlink(link, dest, sizeof dest - 1); if (len < 0) continue;
CWE-119
null
null
13,832
CatalogueResetFPE (FontPathElementPtr fpe) { /* Always just tell the caller to close and re-open */ return FPEResetFailed; }
Overflow
0
CatalogueResetFPE (FontPathElementPtr fpe) { /* Always just tell the caller to close and re-open */ return FPEResetFailed; }
@@ -156,7 +156,7 @@ CatalogueRescan (FontPathElementPtr fpe) while (entry = readdir(dir), entry != NULL) { snprintf(link, sizeof link, "%s/%s", path, entry->d_name); - len = readlink(link, dest, sizeof dest); + len = readlink(link, dest, sizeof dest - 1); if (len < 0) continue;
CWE-119
null
null
13,833
CatalogueStartListFontsAndAliases(pointer client, FontPathElementPtr fpe, char *pat, int len, int max, pointer *privatep) { return CatalogueStartListFonts(client, fpe, pat, len, max, privatep, 1); }
Overflow
0
CatalogueStartListFontsAndAliases(pointer client, FontPathElementPtr fpe, char *pat, int len, int max, pointer *privatep) { return CatalogueStartListFonts(client, fpe, pat, len, max, privatep, 1); }
@@ -156,7 +156,7 @@ CatalogueRescan (FontPathElementPtr fpe) while (entry = readdir(dir), entry != NULL) { snprintf(link, sizeof link, "%s/%s", path, entry->d_name); - len = readlink(link, dest, sizeof dest); + len = readlink(link, dest, sizeof dest - 1); if (len < 0) continue;
CWE-119
null
null
13,834
CatalogueStartListFontsWithInfo(pointer client, FontPathElementPtr fpe, char *pat, int len, int max, pointer *privatep) { return CatalogueStartListFonts(client, fpe, pat, len, max, privatep, 0); }
Overflow
0
CatalogueStartListFontsWithInfo(pointer client, FontPathElementPtr fpe, char *pat, int len, int max, pointer *privatep) { return CatalogueStartListFonts(client, fpe, pat, len, max, privatep, 0); }
@@ -156,7 +156,7 @@ CatalogueRescan (FontPathElementPtr fpe) while (entry = readdir(dir), entry != NULL) { snprintf(link, sizeof link, "%s/%s", path, entry->d_name); - len = readlink(link, dest, sizeof dest); + len = readlink(link, dest, sizeof dest - 1); if (len < 0) continue;
CWE-119
null
null
13,835
tt_cmap10_char_index( TT_CMap cmap, FT_UInt32 char_code ) { FT_Byte* table = cmap->data; FT_UInt result = 0; FT_Byte* p = table + 12; FT_UInt32 start = TT_NEXT_ULONG( p ); FT_UInt32 count = TT_NEXT_ULONG( p ); FT_UInt32 idx; if ( char_code < start ) return 0; idx = char_code - start; if ( idx < count ) { p += 2 * idx; result = TT_PEEK_USHORT( p ); } return result; }
null
0
tt_cmap10_char_index( TT_CMap cmap, FT_UInt32 char_code ) { FT_Byte* table = cmap->data; FT_UInt result = 0; FT_Byte* p = table + 12; FT_UInt32 start = TT_NEXT_ULONG( p ); FT_UInt32 count = TT_NEXT_ULONG( p ); FT_UInt32 idx; if ( char_code < start ) return 0; idx = char_code - start; if ( idx < count ) { p += 2 * idx; result = TT_PEEK_USHORT( p ); } return result; }
@@ -2968,12 +2968,17 @@ /* through the normal Unicode cmap, no GIDs, just check order) */ if ( defOff != 0 ) { - FT_Byte* defp = table + defOff; - FT_ULong numRanges = TT_NEXT_ULONG( defp ); + FT_Byte* defp = table + defOff; + FT_ULong numRanges; FT_ULong i; - FT_ULong lastBase = 0; + FT_ULong lastBase = 0; + if ( defp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + + numRanges = TT_NEXT_ULONG( defp ); + /* defp + numRanges * 4 > valid->limit ? */ if ( numRanges > (FT_ULong)( valid->limit - defp ) / 4 ) FT_INVALID_TOO_SHORT; @@ -2997,13 +3002,18 @@ /* and the non-default table (these glyphs are specified here) */ if ( nondefOff != 0 ) { - FT_Byte* ndp = table + nondefOff; - FT_ULong numMappings = TT_NEXT_ULONG( ndp ); - FT_ULong i, lastUni = 0; + FT_Byte* ndp = table + nondefOff; + FT_ULong numMappings; + FT_ULong i, lastUni = 0; + + + if ( ndp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + numMappings = TT_NEXT_ULONG( ndp ); - /* numMappings * 4 > (FT_ULong)( valid->limit - ndp ) ? */ - if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 4 ) + /* numMappings * 5 > (FT_ULong)( valid->limit - ndp ) ? */ + if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 5 ) FT_INVALID_TOO_SHORT; for ( i = 0; i < numMappings; ++i )
CWE-125
null
null
13,836
tt_cmap12_char_next( TT_CMap cmap, FT_UInt32 *pchar_code ) { TT_CMap12 cmap12 = (TT_CMap12)cmap; FT_UInt gindex; /* no need to search */ if ( cmap12->valid && cmap12->cur_charcode == *pchar_code ) { tt_cmap12_next( cmap12 ); if ( cmap12->valid ) { gindex = cmap12->cur_gindex; *pchar_code = (FT_UInt32)cmap12->cur_charcode; } else gindex = 0; } else gindex = tt_cmap12_char_map_binary( cmap, pchar_code, 1 ); return gindex; }
null
0
tt_cmap12_char_next( TT_CMap cmap, FT_UInt32 *pchar_code ) { TT_CMap12 cmap12 = (TT_CMap12)cmap; FT_UInt gindex; /* no need to search */ if ( cmap12->valid && cmap12->cur_charcode == *pchar_code ) { tt_cmap12_next( cmap12 ); if ( cmap12->valid ) { gindex = cmap12->cur_gindex; *pchar_code = (FT_UInt32)cmap12->cur_charcode; } else gindex = 0; } else gindex = tt_cmap12_char_map_binary( cmap, pchar_code, 1 ); return gindex; }
@@ -2968,12 +2968,17 @@ /* through the normal Unicode cmap, no GIDs, just check order) */ if ( defOff != 0 ) { - FT_Byte* defp = table + defOff; - FT_ULong numRanges = TT_NEXT_ULONG( defp ); + FT_Byte* defp = table + defOff; + FT_ULong numRanges; FT_ULong i; - FT_ULong lastBase = 0; + FT_ULong lastBase = 0; + if ( defp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + + numRanges = TT_NEXT_ULONG( defp ); + /* defp + numRanges * 4 > valid->limit ? */ if ( numRanges > (FT_ULong)( valid->limit - defp ) / 4 ) FT_INVALID_TOO_SHORT; @@ -2997,13 +3002,18 @@ /* and the non-default table (these glyphs are specified here) */ if ( nondefOff != 0 ) { - FT_Byte* ndp = table + nondefOff; - FT_ULong numMappings = TT_NEXT_ULONG( ndp ); - FT_ULong i, lastUni = 0; + FT_Byte* ndp = table + nondefOff; + FT_ULong numMappings; + FT_ULong i, lastUni = 0; + + + if ( ndp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + numMappings = TT_NEXT_ULONG( ndp ); - /* numMappings * 4 > (FT_ULong)( valid->limit - ndp ) ? */ - if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 4 ) + /* numMappings * 5 > (FT_ULong)( valid->limit - ndp ) ? */ + if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 5 ) FT_INVALID_TOO_SHORT; for ( i = 0; i < numMappings; ++i )
CWE-125
null
null
13,837
tt_cmap12_next( TT_CMap12 cmap ) { FT_Face face = cmap->cmap.cmap.charmap.face; FT_Byte* p; FT_ULong start, end, start_id, char_code; FT_ULong n; FT_UInt gindex; if ( cmap->cur_charcode >= 0xFFFFFFFFUL ) goto Fail; char_code = cmap->cur_charcode + 1; for ( n = cmap->cur_group; n < cmap->num_groups; n++ ) { p = cmap->cmap.data + 16 + 12 * n; start = TT_NEXT_ULONG( p ); end = TT_NEXT_ULONG( p ); start_id = TT_PEEK_ULONG( p ); if ( char_code < start ) char_code = start; Again: if ( char_code <= end ) { /* ignore invalid group */ if ( start_id > 0xFFFFFFFFUL - ( char_code - start ) ) continue; gindex = (FT_UInt)( start_id + ( char_code - start ) ); /* does first element of group point to `.notdef' glyph? */ if ( gindex == 0 ) { if ( char_code >= 0xFFFFFFFFUL ) goto Fail; char_code++; goto Again; } /* if `gindex' is invalid, the remaining values */ /* in this group are invalid, too */ if ( gindex >= (FT_UInt)face->num_glyphs ) { gindex = 0; continue; } cmap->cur_charcode = char_code; cmap->cur_gindex = gindex; cmap->cur_group = n; return; } } Fail: cmap->valid = 0; }
null
0
tt_cmap12_next( TT_CMap12 cmap ) { FT_Face face = cmap->cmap.cmap.charmap.face; FT_Byte* p; FT_ULong start, end, start_id, char_code; FT_ULong n; FT_UInt gindex; if ( cmap->cur_charcode >= 0xFFFFFFFFUL ) goto Fail; char_code = cmap->cur_charcode + 1; for ( n = cmap->cur_group; n < cmap->num_groups; n++ ) { p = cmap->cmap.data + 16 + 12 * n; start = TT_NEXT_ULONG( p ); end = TT_NEXT_ULONG( p ); start_id = TT_PEEK_ULONG( p ); if ( char_code < start ) char_code = start; Again: if ( char_code <= end ) { /* ignore invalid group */ if ( start_id > 0xFFFFFFFFUL - ( char_code - start ) ) continue; gindex = (FT_UInt)( start_id + ( char_code - start ) ); /* does first element of group point to `.notdef' glyph? */ if ( gindex == 0 ) { if ( char_code >= 0xFFFFFFFFUL ) goto Fail; char_code++; goto Again; } /* if `gindex' is invalid, the remaining values */ /* in this group are invalid, too */ if ( gindex >= (FT_UInt)face->num_glyphs ) { gindex = 0; continue; } cmap->cur_charcode = char_code; cmap->cur_gindex = gindex; cmap->cur_group = n; return; } } Fail: cmap->valid = 0; }
@@ -2968,12 +2968,17 @@ /* through the normal Unicode cmap, no GIDs, just check order) */ if ( defOff != 0 ) { - FT_Byte* defp = table + defOff; - FT_ULong numRanges = TT_NEXT_ULONG( defp ); + FT_Byte* defp = table + defOff; + FT_ULong numRanges; FT_ULong i; - FT_ULong lastBase = 0; + FT_ULong lastBase = 0; + if ( defp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + + numRanges = TT_NEXT_ULONG( defp ); + /* defp + numRanges * 4 > valid->limit ? */ if ( numRanges > (FT_ULong)( valid->limit - defp ) / 4 ) FT_INVALID_TOO_SHORT; @@ -2997,13 +3002,18 @@ /* and the non-default table (these glyphs are specified here) */ if ( nondefOff != 0 ) { - FT_Byte* ndp = table + nondefOff; - FT_ULong numMappings = TT_NEXT_ULONG( ndp ); - FT_ULong i, lastUni = 0; + FT_Byte* ndp = table + nondefOff; + FT_ULong numMappings; + FT_ULong i, lastUni = 0; + + + if ( ndp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + numMappings = TT_NEXT_ULONG( ndp ); - /* numMappings * 4 > (FT_ULong)( valid->limit - ndp ) ? */ - if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 4 ) + /* numMappings * 5 > (FT_ULong)( valid->limit - ndp ) ? */ + if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 5 ) FT_INVALID_TOO_SHORT; for ( i = 0; i < numMappings; ++i )
CWE-125
null
null
13,838
tt_cmap13_char_next( TT_CMap cmap, FT_UInt32 *pchar_code ) { TT_CMap13 cmap13 = (TT_CMap13)cmap; FT_UInt gindex; /* no need to search */ if ( cmap13->valid && cmap13->cur_charcode == *pchar_code ) { tt_cmap13_next( cmap13 ); if ( cmap13->valid ) { gindex = cmap13->cur_gindex; *pchar_code = cmap13->cur_charcode; } else gindex = 0; } else gindex = tt_cmap13_char_map_binary( cmap, pchar_code, 1 ); return gindex; }
null
0
tt_cmap13_char_next( TT_CMap cmap, FT_UInt32 *pchar_code ) { TT_CMap13 cmap13 = (TT_CMap13)cmap; FT_UInt gindex; /* no need to search */ if ( cmap13->valid && cmap13->cur_charcode == *pchar_code ) { tt_cmap13_next( cmap13 ); if ( cmap13->valid ) { gindex = cmap13->cur_gindex; *pchar_code = cmap13->cur_charcode; } else gindex = 0; } else gindex = tt_cmap13_char_map_binary( cmap, pchar_code, 1 ); return gindex; }
@@ -2968,12 +2968,17 @@ /* through the normal Unicode cmap, no GIDs, just check order) */ if ( defOff != 0 ) { - FT_Byte* defp = table + defOff; - FT_ULong numRanges = TT_NEXT_ULONG( defp ); + FT_Byte* defp = table + defOff; + FT_ULong numRanges; FT_ULong i; - FT_ULong lastBase = 0; + FT_ULong lastBase = 0; + if ( defp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + + numRanges = TT_NEXT_ULONG( defp ); + /* defp + numRanges * 4 > valid->limit ? */ if ( numRanges > (FT_ULong)( valid->limit - defp ) / 4 ) FT_INVALID_TOO_SHORT; @@ -2997,13 +3002,18 @@ /* and the non-default table (these glyphs are specified here) */ if ( nondefOff != 0 ) { - FT_Byte* ndp = table + nondefOff; - FT_ULong numMappings = TT_NEXT_ULONG( ndp ); - FT_ULong i, lastUni = 0; + FT_Byte* ndp = table + nondefOff; + FT_ULong numMappings; + FT_ULong i, lastUni = 0; + + + if ( ndp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + numMappings = TT_NEXT_ULONG( ndp ); - /* numMappings * 4 > (FT_ULong)( valid->limit - ndp ) ? */ - if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 4 ) + /* numMappings * 5 > (FT_ULong)( valid->limit - ndp ) ? */ + if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 5 ) FT_INVALID_TOO_SHORT; for ( i = 0; i < numMappings; ++i )
CWE-125
null
null
13,839
tt_cmap2_char_index( TT_CMap cmap, FT_UInt32 char_code ) { FT_Byte* table = cmap->data; FT_UInt result = 0; FT_Byte* subheader; subheader = tt_cmap2_get_subheader( table, char_code ); if ( subheader ) { FT_Byte* p = subheader; FT_UInt idx = (FT_UInt)(char_code & 0xFF); FT_UInt start, count; FT_Int delta; FT_UInt offset; start = TT_NEXT_USHORT( p ); count = TT_NEXT_USHORT( p ); delta = TT_NEXT_SHORT ( p ); offset = TT_PEEK_USHORT( p ); idx -= start; if ( idx < count && offset != 0 ) { p += offset + 2 * idx; idx = TT_PEEK_USHORT( p ); if ( idx != 0 ) result = (FT_UInt)( (FT_Int)idx + delta ) & 0xFFFFU; } } return result; }
null
0
tt_cmap2_char_index( TT_CMap cmap, FT_UInt32 char_code ) { FT_Byte* table = cmap->data; FT_UInt result = 0; FT_Byte* subheader; subheader = tt_cmap2_get_subheader( table, char_code ); if ( subheader ) { FT_Byte* p = subheader; FT_UInt idx = (FT_UInt)(char_code & 0xFF); FT_UInt start, count; FT_Int delta; FT_UInt offset; start = TT_NEXT_USHORT( p ); count = TT_NEXT_USHORT( p ); delta = TT_NEXT_SHORT ( p ); offset = TT_PEEK_USHORT( p ); idx -= start; if ( idx < count && offset != 0 ) { p += offset + 2 * idx; idx = TT_PEEK_USHORT( p ); if ( idx != 0 ) result = (FT_UInt)( (FT_Int)idx + delta ) & 0xFFFFU; } } return result; }
@@ -2968,12 +2968,17 @@ /* through the normal Unicode cmap, no GIDs, just check order) */ if ( defOff != 0 ) { - FT_Byte* defp = table + defOff; - FT_ULong numRanges = TT_NEXT_ULONG( defp ); + FT_Byte* defp = table + defOff; + FT_ULong numRanges; FT_ULong i; - FT_ULong lastBase = 0; + FT_ULong lastBase = 0; + if ( defp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + + numRanges = TT_NEXT_ULONG( defp ); + /* defp + numRanges * 4 > valid->limit ? */ if ( numRanges > (FT_ULong)( valid->limit - defp ) / 4 ) FT_INVALID_TOO_SHORT; @@ -2997,13 +3002,18 @@ /* and the non-default table (these glyphs are specified here) */ if ( nondefOff != 0 ) { - FT_Byte* ndp = table + nondefOff; - FT_ULong numMappings = TT_NEXT_ULONG( ndp ); - FT_ULong i, lastUni = 0; + FT_Byte* ndp = table + nondefOff; + FT_ULong numMappings; + FT_ULong i, lastUni = 0; + + + if ( ndp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + numMappings = TT_NEXT_ULONG( ndp ); - /* numMappings * 4 > (FT_ULong)( valid->limit - ndp ) ? */ - if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 4 ) + /* numMappings * 5 > (FT_ULong)( valid->limit - ndp ) ? */ + if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 5 ) FT_INVALID_TOO_SHORT; for ( i = 0; i < numMappings; ++i )
CWE-125
null
null
13,840
tt_cmap2_char_next( TT_CMap cmap, FT_UInt32 *pcharcode ) { FT_Byte* table = cmap->data; FT_UInt gindex = 0; FT_UInt32 result = 0; FT_UInt32 charcode = *pcharcode + 1; FT_Byte* subheader; while ( charcode < 0x10000UL ) { subheader = tt_cmap2_get_subheader( table, charcode ); if ( subheader ) { FT_Byte* p = subheader; FT_UInt start = TT_NEXT_USHORT( p ); FT_UInt count = TT_NEXT_USHORT( p ); FT_Int delta = TT_NEXT_SHORT ( p ); FT_UInt offset = TT_PEEK_USHORT( p ); FT_UInt char_lo = (FT_UInt)( charcode & 0xFF ); FT_UInt pos, idx; if ( offset == 0 ) goto Next_SubHeader; if ( char_lo < start ) { char_lo = start; pos = 0; } else pos = (FT_UInt)( char_lo - start ); p += offset + pos * 2; charcode = FT_PAD_FLOOR( charcode, 256 ) + char_lo; for ( ; pos < count; pos++, charcode++ ) { idx = TT_NEXT_USHORT( p ); if ( idx != 0 ) { gindex = (FT_UInt)( (FT_Int)idx + delta ) & 0xFFFFU; if ( gindex != 0 ) { result = charcode; goto Exit; } } } } /* jump to next sub-header, i.e. higher byte value */ Next_SubHeader: charcode = FT_PAD_FLOOR( charcode, 256 ) + 256; } Exit: *pcharcode = result; return gindex; }
null
0
tt_cmap2_char_next( TT_CMap cmap, FT_UInt32 *pcharcode ) { FT_Byte* table = cmap->data; FT_UInt gindex = 0; FT_UInt32 result = 0; FT_UInt32 charcode = *pcharcode + 1; FT_Byte* subheader; while ( charcode < 0x10000UL ) { subheader = tt_cmap2_get_subheader( table, charcode ); if ( subheader ) { FT_Byte* p = subheader; FT_UInt start = TT_NEXT_USHORT( p ); FT_UInt count = TT_NEXT_USHORT( p ); FT_Int delta = TT_NEXT_SHORT ( p ); FT_UInt offset = TT_PEEK_USHORT( p ); FT_UInt char_lo = (FT_UInt)( charcode & 0xFF ); FT_UInt pos, idx; if ( offset == 0 ) goto Next_SubHeader; if ( char_lo < start ) { char_lo = start; pos = 0; } else pos = (FT_UInt)( char_lo - start ); p += offset + pos * 2; charcode = FT_PAD_FLOOR( charcode, 256 ) + char_lo; for ( ; pos < count; pos++, charcode++ ) { idx = TT_NEXT_USHORT( p ); if ( idx != 0 ) { gindex = (FT_UInt)( (FT_Int)idx + delta ) & 0xFFFFU; if ( gindex != 0 ) { result = charcode; goto Exit; } } } } /* jump to next sub-header, i.e. higher byte value */ Next_SubHeader: charcode = FT_PAD_FLOOR( charcode, 256 ) + 256; } Exit: *pcharcode = result; return gindex; }
@@ -2968,12 +2968,17 @@ /* through the normal Unicode cmap, no GIDs, just check order) */ if ( defOff != 0 ) { - FT_Byte* defp = table + defOff; - FT_ULong numRanges = TT_NEXT_ULONG( defp ); + FT_Byte* defp = table + defOff; + FT_ULong numRanges; FT_ULong i; - FT_ULong lastBase = 0; + FT_ULong lastBase = 0; + if ( defp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + + numRanges = TT_NEXT_ULONG( defp ); + /* defp + numRanges * 4 > valid->limit ? */ if ( numRanges > (FT_ULong)( valid->limit - defp ) / 4 ) FT_INVALID_TOO_SHORT; @@ -2997,13 +3002,18 @@ /* and the non-default table (these glyphs are specified here) */ if ( nondefOff != 0 ) { - FT_Byte* ndp = table + nondefOff; - FT_ULong numMappings = TT_NEXT_ULONG( ndp ); - FT_ULong i, lastUni = 0; + FT_Byte* ndp = table + nondefOff; + FT_ULong numMappings; + FT_ULong i, lastUni = 0; + + + if ( ndp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + numMappings = TT_NEXT_ULONG( ndp ); - /* numMappings * 4 > (FT_ULong)( valid->limit - ndp ) ? */ - if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 4 ) + /* numMappings * 5 > (FT_ULong)( valid->limit - ndp ) ? */ + if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 5 ) FT_INVALID_TOO_SHORT; for ( i = 0; i < numMappings; ++i )
CWE-125
null
null
13,841
tt_cmap4_char_map_binary( TT_CMap cmap, FT_UInt32* pcharcode, FT_Bool next ) { FT_UInt num_segs2, start, end, offset; FT_Int delta; FT_UInt max, min, mid, num_segs; FT_UInt charcode = (FT_UInt)*pcharcode; FT_UInt gindex = 0; FT_Byte* p; p = cmap->data + 6; num_segs2 = FT_PAD_FLOOR( TT_PEEK_USHORT( p ), 2 ); if ( !num_segs2 ) return 0; num_segs = num_segs2 >> 1; /* make compiler happy */ mid = num_segs; end = 0xFFFFU; if ( next ) charcode++; min = 0; max = num_segs; /* binary search */ while ( min < max ) { mid = ( min + max ) >> 1; p = cmap->data + 14 + mid * 2; end = TT_PEEK_USHORT( p ); p += 2 + num_segs2; start = TT_PEEK_USHORT( p ); if ( charcode < start ) max = mid; else if ( charcode > end ) min = mid + 1; else { p += num_segs2; delta = TT_PEEK_SHORT( p ); p += num_segs2; offset = TT_PEEK_USHORT( p ); /* some fonts have an incorrect last segment; */ /* we have to catch it */ if ( mid >= num_segs - 1 && start == 0xFFFFU && end == 0xFFFFU ) { TT_Face face = (TT_Face)cmap->cmap.charmap.face; FT_Byte* limit = face->cmap_table + face->cmap_size; if ( offset && p + offset + 2 > limit ) { delta = 1; offset = 0; } } /* search the first segment containing `charcode' */ if ( cmap->flags & TT_CMAP_FLAG_OVERLAPPING ) { FT_UInt i; /* call the current segment `max' */ max = mid; if ( offset == 0xFFFFU ) mid = max + 1; /* search in segments before the current segment */ for ( i = max ; i > 0; i-- ) { FT_UInt prev_end; FT_Byte* old_p; old_p = p; p = cmap->data + 14 + ( i - 1 ) * 2; prev_end = TT_PEEK_USHORT( p ); if ( charcode > prev_end ) { p = old_p; break; } end = prev_end; p += 2 + num_segs2; start = TT_PEEK_USHORT( p ); p += num_segs2; delta = TT_PEEK_SHORT( p ); p += num_segs2; offset = TT_PEEK_USHORT( p ); if ( offset != 0xFFFFU ) mid = i - 1; } /* no luck */ if ( mid == max + 1 ) { if ( i != max ) { p = cmap->data + 14 + max * 2; end = TT_PEEK_USHORT( p ); p += 2 + num_segs2; start = TT_PEEK_USHORT( p ); p += num_segs2; delta = TT_PEEK_SHORT( p ); p += num_segs2; offset = TT_PEEK_USHORT( p ); } mid = max; /* search in segments after the current segment */ for ( i = max + 1; i < num_segs; i++ ) { FT_UInt next_end, next_start; p = cmap->data + 14 + i * 2; next_end = TT_PEEK_USHORT( p ); p += 2 + num_segs2; next_start = TT_PEEK_USHORT( p ); if ( charcode < next_start ) break; end = next_end; start = next_start; p += num_segs2; delta = TT_PEEK_SHORT( p ); p += num_segs2; offset = TT_PEEK_USHORT( p ); if ( offset != 0xFFFFU ) mid = i; } i--; /* still no luck */ if ( mid == max ) { mid = i; break; } } /* end, start, delta, and offset are for the i'th segment */ if ( mid != i ) { p = cmap->data + 14 + mid * 2; end = TT_PEEK_USHORT( p ); p += 2 + num_segs2; start = TT_PEEK_USHORT( p ); p += num_segs2; delta = TT_PEEK_SHORT( p ); p += num_segs2; offset = TT_PEEK_USHORT( p ); } } else { if ( offset == 0xFFFFU ) break; } if ( offset ) { p += offset + ( charcode - start ) * 2; gindex = TT_PEEK_USHORT( p ); if ( gindex != 0 ) gindex = (FT_UInt)( (FT_Int)gindex + delta ) & 0xFFFFU; } else gindex = (FT_UInt)( (FT_Int)charcode + delta ) & 0xFFFFU; break; } } if ( next ) { TT_CMap4 cmap4 = (TT_CMap4)cmap; /* if `charcode' is not in any segment, then `mid' is */ /* the segment nearest to `charcode' */ if ( charcode > end ) { mid++; if ( mid == num_segs ) return 0; } if ( tt_cmap4_set_range( cmap4, mid ) ) { if ( gindex ) *pcharcode = charcode; } else { cmap4->cur_charcode = charcode; if ( gindex ) cmap4->cur_gindex = gindex; else { cmap4->cur_charcode = charcode; tt_cmap4_next( cmap4 ); gindex = cmap4->cur_gindex; } if ( gindex ) *pcharcode = cmap4->cur_charcode; } } return gindex; }
null
0
tt_cmap4_char_map_binary( TT_CMap cmap, FT_UInt32* pcharcode, FT_Bool next ) { FT_UInt num_segs2, start, end, offset; FT_Int delta; FT_UInt max, min, mid, num_segs; FT_UInt charcode = (FT_UInt)*pcharcode; FT_UInt gindex = 0; FT_Byte* p; p = cmap->data + 6; num_segs2 = FT_PAD_FLOOR( TT_PEEK_USHORT( p ), 2 ); if ( !num_segs2 ) return 0; num_segs = num_segs2 >> 1; /* make compiler happy */ mid = num_segs; end = 0xFFFFU; if ( next ) charcode++; min = 0; max = num_segs; /* binary search */ while ( min < max ) { mid = ( min + max ) >> 1; p = cmap->data + 14 + mid * 2; end = TT_PEEK_USHORT( p ); p += 2 + num_segs2; start = TT_PEEK_USHORT( p ); if ( charcode < start ) max = mid; else if ( charcode > end ) min = mid + 1; else { p += num_segs2; delta = TT_PEEK_SHORT( p ); p += num_segs2; offset = TT_PEEK_USHORT( p ); /* some fonts have an incorrect last segment; */ /* we have to catch it */ if ( mid >= num_segs - 1 && start == 0xFFFFU && end == 0xFFFFU ) { TT_Face face = (TT_Face)cmap->cmap.charmap.face; FT_Byte* limit = face->cmap_table + face->cmap_size; if ( offset && p + offset + 2 > limit ) { delta = 1; offset = 0; } } /* search the first segment containing `charcode' */ if ( cmap->flags & TT_CMAP_FLAG_OVERLAPPING ) { FT_UInt i; /* call the current segment `max' */ max = mid; if ( offset == 0xFFFFU ) mid = max + 1; /* search in segments before the current segment */ for ( i = max ; i > 0; i-- ) { FT_UInt prev_end; FT_Byte* old_p; old_p = p; p = cmap->data + 14 + ( i - 1 ) * 2; prev_end = TT_PEEK_USHORT( p ); if ( charcode > prev_end ) { p = old_p; break; } end = prev_end; p += 2 + num_segs2; start = TT_PEEK_USHORT( p ); p += num_segs2; delta = TT_PEEK_SHORT( p ); p += num_segs2; offset = TT_PEEK_USHORT( p ); if ( offset != 0xFFFFU ) mid = i - 1; } /* no luck */ if ( mid == max + 1 ) { if ( i != max ) { p = cmap->data + 14 + max * 2; end = TT_PEEK_USHORT( p ); p += 2 + num_segs2; start = TT_PEEK_USHORT( p ); p += num_segs2; delta = TT_PEEK_SHORT( p ); p += num_segs2; offset = TT_PEEK_USHORT( p ); } mid = max; /* search in segments after the current segment */ for ( i = max + 1; i < num_segs; i++ ) { FT_UInt next_end, next_start; p = cmap->data + 14 + i * 2; next_end = TT_PEEK_USHORT( p ); p += 2 + num_segs2; next_start = TT_PEEK_USHORT( p ); if ( charcode < next_start ) break; end = next_end; start = next_start; p += num_segs2; delta = TT_PEEK_SHORT( p ); p += num_segs2; offset = TT_PEEK_USHORT( p ); if ( offset != 0xFFFFU ) mid = i; } i--; /* still no luck */ if ( mid == max ) { mid = i; break; } } /* end, start, delta, and offset are for the i'th segment */ if ( mid != i ) { p = cmap->data + 14 + mid * 2; end = TT_PEEK_USHORT( p ); p += 2 + num_segs2; start = TT_PEEK_USHORT( p ); p += num_segs2; delta = TT_PEEK_SHORT( p ); p += num_segs2; offset = TT_PEEK_USHORT( p ); } } else { if ( offset == 0xFFFFU ) break; } if ( offset ) { p += offset + ( charcode - start ) * 2; gindex = TT_PEEK_USHORT( p ); if ( gindex != 0 ) gindex = (FT_UInt)( (FT_Int)gindex + delta ) & 0xFFFFU; } else gindex = (FT_UInt)( (FT_Int)charcode + delta ) & 0xFFFFU; break; } } if ( next ) { TT_CMap4 cmap4 = (TT_CMap4)cmap; /* if `charcode' is not in any segment, then `mid' is */ /* the segment nearest to `charcode' */ if ( charcode > end ) { mid++; if ( mid == num_segs ) return 0; } if ( tt_cmap4_set_range( cmap4, mid ) ) { if ( gindex ) *pcharcode = charcode; } else { cmap4->cur_charcode = charcode; if ( gindex ) cmap4->cur_gindex = gindex; else { cmap4->cur_charcode = charcode; tt_cmap4_next( cmap4 ); gindex = cmap4->cur_gindex; } if ( gindex ) *pcharcode = cmap4->cur_charcode; } } return gindex; }
@@ -2968,12 +2968,17 @@ /* through the normal Unicode cmap, no GIDs, just check order) */ if ( defOff != 0 ) { - FT_Byte* defp = table + defOff; - FT_ULong numRanges = TT_NEXT_ULONG( defp ); + FT_Byte* defp = table + defOff; + FT_ULong numRanges; FT_ULong i; - FT_ULong lastBase = 0; + FT_ULong lastBase = 0; + if ( defp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + + numRanges = TT_NEXT_ULONG( defp ); + /* defp + numRanges * 4 > valid->limit ? */ if ( numRanges > (FT_ULong)( valid->limit - defp ) / 4 ) FT_INVALID_TOO_SHORT; @@ -2997,13 +3002,18 @@ /* and the non-default table (these glyphs are specified here) */ if ( nondefOff != 0 ) { - FT_Byte* ndp = table + nondefOff; - FT_ULong numMappings = TT_NEXT_ULONG( ndp ); - FT_ULong i, lastUni = 0; + FT_Byte* ndp = table + nondefOff; + FT_ULong numMappings; + FT_ULong i, lastUni = 0; + + + if ( ndp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + numMappings = TT_NEXT_ULONG( ndp ); - /* numMappings * 4 > (FT_ULong)( valid->limit - ndp ) ? */ - if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 4 ) + /* numMappings * 5 > (FT_ULong)( valid->limit - ndp ) ? */ + if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 5 ) FT_INVALID_TOO_SHORT; for ( i = 0; i < numMappings; ++i )
CWE-125
null
null
13,842
tt_cmap4_char_map_linear( TT_CMap cmap, FT_UInt32* pcharcode, FT_Bool next ) { TT_Face face = (TT_Face)cmap->cmap.charmap.face; FT_Byte* limit = face->cmap_table + face->cmap_size; FT_UInt num_segs2, start, end, offset; FT_Int delta; FT_UInt i, num_segs; FT_UInt32 charcode = *pcharcode; FT_UInt gindex = 0; FT_Byte* p; FT_Byte* q; p = cmap->data + 6; num_segs2 = FT_PAD_FLOOR( TT_PEEK_USHORT( p ), 2 ); num_segs = num_segs2 >> 1; if ( !num_segs ) return 0; if ( next ) charcode++; if ( charcode > 0xFFFFU ) return 0; /* linear search */ p = cmap->data + 14; /* ends table */ q = cmap->data + 16 + num_segs2; /* starts table */ for ( i = 0; i < num_segs; i++ ) { end = TT_NEXT_USHORT( p ); start = TT_NEXT_USHORT( q ); if ( charcode < start ) { if ( next ) charcode = start; else break; } Again: if ( charcode <= end ) { FT_Byte* r; r = q - 2 + num_segs2; delta = TT_PEEK_SHORT( r ); r += num_segs2; offset = TT_PEEK_USHORT( r ); /* some fonts have an incorrect last segment; */ /* we have to catch it */ if ( i >= num_segs - 1 && start == 0xFFFFU && end == 0xFFFFU ) { if ( offset && r + offset + 2 > limit ) { delta = 1; offset = 0; } } if ( offset == 0xFFFFU ) continue; if ( offset ) { r += offset + ( charcode - start ) * 2; /* if r > limit, the whole segment is invalid */ if ( next && r > limit ) continue; gindex = TT_PEEK_USHORT( r ); if ( gindex ) { gindex = (FT_UInt)( (FT_Int)gindex + delta ) & 0xFFFFU; if ( gindex >= (FT_UInt)face->root.num_glyphs ) gindex = 0; } } else { gindex = (FT_UInt)( (FT_Int)charcode + delta ) & 0xFFFFU; if ( next && gindex >= (FT_UInt)face->root.num_glyphs ) { /* we have an invalid glyph index; if there is an overflow, */ /* we can adjust `charcode', otherwise the whole segment is */ /* invalid */ gindex = 0; if ( (FT_Int)charcode + delta < 0 && (FT_Int)end + delta >= 0 ) charcode = (FT_UInt)( -delta ); else if ( (FT_Int)charcode + delta < 0x10000L && (FT_Int)end + delta >= 0x10000L ) charcode = (FT_UInt)( 0x10000L - delta ); else continue; } } if ( next && !gindex ) { if ( charcode >= 0xFFFFU ) break; charcode++; goto Again; } break; } } if ( next ) *pcharcode = charcode; return gindex; }
null
0
tt_cmap4_char_map_linear( TT_CMap cmap, FT_UInt32* pcharcode, FT_Bool next ) { TT_Face face = (TT_Face)cmap->cmap.charmap.face; FT_Byte* limit = face->cmap_table + face->cmap_size; FT_UInt num_segs2, start, end, offset; FT_Int delta; FT_UInt i, num_segs; FT_UInt32 charcode = *pcharcode; FT_UInt gindex = 0; FT_Byte* p; FT_Byte* q; p = cmap->data + 6; num_segs2 = FT_PAD_FLOOR( TT_PEEK_USHORT( p ), 2 ); num_segs = num_segs2 >> 1; if ( !num_segs ) return 0; if ( next ) charcode++; if ( charcode > 0xFFFFU ) return 0; /* linear search */ p = cmap->data + 14; /* ends table */ q = cmap->data + 16 + num_segs2; /* starts table */ for ( i = 0; i < num_segs; i++ ) { end = TT_NEXT_USHORT( p ); start = TT_NEXT_USHORT( q ); if ( charcode < start ) { if ( next ) charcode = start; else break; } Again: if ( charcode <= end ) { FT_Byte* r; r = q - 2 + num_segs2; delta = TT_PEEK_SHORT( r ); r += num_segs2; offset = TT_PEEK_USHORT( r ); /* some fonts have an incorrect last segment; */ /* we have to catch it */ if ( i >= num_segs - 1 && start == 0xFFFFU && end == 0xFFFFU ) { if ( offset && r + offset + 2 > limit ) { delta = 1; offset = 0; } } if ( offset == 0xFFFFU ) continue; if ( offset ) { r += offset + ( charcode - start ) * 2; /* if r > limit, the whole segment is invalid */ if ( next && r > limit ) continue; gindex = TT_PEEK_USHORT( r ); if ( gindex ) { gindex = (FT_UInt)( (FT_Int)gindex + delta ) & 0xFFFFU; if ( gindex >= (FT_UInt)face->root.num_glyphs ) gindex = 0; } } else { gindex = (FT_UInt)( (FT_Int)charcode + delta ) & 0xFFFFU; if ( next && gindex >= (FT_UInt)face->root.num_glyphs ) { /* we have an invalid glyph index; if there is an overflow, */ /* we can adjust `charcode', otherwise the whole segment is */ /* invalid */ gindex = 0; if ( (FT_Int)charcode + delta < 0 && (FT_Int)end + delta >= 0 ) charcode = (FT_UInt)( -delta ); else if ( (FT_Int)charcode + delta < 0x10000L && (FT_Int)end + delta >= 0x10000L ) charcode = (FT_UInt)( 0x10000L - delta ); else continue; } } if ( next && !gindex ) { if ( charcode >= 0xFFFFU ) break; charcode++; goto Again; } break; } } if ( next ) *pcharcode = charcode; return gindex; }
@@ -2968,12 +2968,17 @@ /* through the normal Unicode cmap, no GIDs, just check order) */ if ( defOff != 0 ) { - FT_Byte* defp = table + defOff; - FT_ULong numRanges = TT_NEXT_ULONG( defp ); + FT_Byte* defp = table + defOff; + FT_ULong numRanges; FT_ULong i; - FT_ULong lastBase = 0; + FT_ULong lastBase = 0; + if ( defp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + + numRanges = TT_NEXT_ULONG( defp ); + /* defp + numRanges * 4 > valid->limit ? */ if ( numRanges > (FT_ULong)( valid->limit - defp ) / 4 ) FT_INVALID_TOO_SHORT; @@ -2997,13 +3002,18 @@ /* and the non-default table (these glyphs are specified here) */ if ( nondefOff != 0 ) { - FT_Byte* ndp = table + nondefOff; - FT_ULong numMappings = TT_NEXT_ULONG( ndp ); - FT_ULong i, lastUni = 0; + FT_Byte* ndp = table + nondefOff; + FT_ULong numMappings; + FT_ULong i, lastUni = 0; + + + if ( ndp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + numMappings = TT_NEXT_ULONG( ndp ); - /* numMappings * 4 > (FT_ULong)( valid->limit - ndp ) ? */ - if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 4 ) + /* numMappings * 5 > (FT_ULong)( valid->limit - ndp ) ? */ + if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 5 ) FT_INVALID_TOO_SHORT; for ( i = 0; i < numMappings; ++i )
CWE-125
null
null
13,843
tt_cmap4_next( TT_CMap4 cmap ) { FT_UInt charcode; if ( cmap->cur_charcode >= 0xFFFFUL ) goto Fail; charcode = (FT_UInt)cmap->cur_charcode + 1; if ( charcode < cmap->cur_start ) charcode = cmap->cur_start; for ( ;; ) { FT_Byte* values = cmap->cur_values; FT_UInt end = cmap->cur_end; FT_Int delta = cmap->cur_delta; if ( charcode <= end ) { if ( values ) { FT_Byte* p = values + 2 * ( charcode - cmap->cur_start ); do { FT_UInt gindex = FT_NEXT_USHORT( p ); if ( gindex != 0 ) { gindex = (FT_UInt)( (FT_Int)gindex + delta ) & 0xFFFFU; if ( gindex != 0 ) { cmap->cur_charcode = charcode; cmap->cur_gindex = gindex; return; } } } while ( ++charcode <= end ); } else { do { FT_UInt gindex = (FT_UInt)( (FT_Int)charcode + delta ) & 0xFFFFU; if ( gindex != 0 ) { cmap->cur_charcode = charcode; cmap->cur_gindex = gindex; return; } } while ( ++charcode <= end ); } } /* we need to find another range */ if ( tt_cmap4_set_range( cmap, cmap->cur_range + 1 ) < 0 ) break; if ( charcode < cmap->cur_start ) charcode = cmap->cur_start; } Fail: cmap->cur_charcode = (FT_UInt32)0xFFFFFFFFUL; cmap->cur_gindex = 0; }
null
0
tt_cmap4_next( TT_CMap4 cmap ) { FT_UInt charcode; if ( cmap->cur_charcode >= 0xFFFFUL ) goto Fail; charcode = (FT_UInt)cmap->cur_charcode + 1; if ( charcode < cmap->cur_start ) charcode = cmap->cur_start; for ( ;; ) { FT_Byte* values = cmap->cur_values; FT_UInt end = cmap->cur_end; FT_Int delta = cmap->cur_delta; if ( charcode <= end ) { if ( values ) { FT_Byte* p = values + 2 * ( charcode - cmap->cur_start ); do { FT_UInt gindex = FT_NEXT_USHORT( p ); if ( gindex != 0 ) { gindex = (FT_UInt)( (FT_Int)gindex + delta ) & 0xFFFFU; if ( gindex != 0 ) { cmap->cur_charcode = charcode; cmap->cur_gindex = gindex; return; } } } while ( ++charcode <= end ); } else { do { FT_UInt gindex = (FT_UInt)( (FT_Int)charcode + delta ) & 0xFFFFU; if ( gindex != 0 ) { cmap->cur_charcode = charcode; cmap->cur_gindex = gindex; return; } } while ( ++charcode <= end ); } } /* we need to find another range */ if ( tt_cmap4_set_range( cmap, cmap->cur_range + 1 ) < 0 ) break; if ( charcode < cmap->cur_start ) charcode = cmap->cur_start; } Fail: cmap->cur_charcode = (FT_UInt32)0xFFFFFFFFUL; cmap->cur_gindex = 0; }
@@ -2968,12 +2968,17 @@ /* through the normal Unicode cmap, no GIDs, just check order) */ if ( defOff != 0 ) { - FT_Byte* defp = table + defOff; - FT_ULong numRanges = TT_NEXT_ULONG( defp ); + FT_Byte* defp = table + defOff; + FT_ULong numRanges; FT_ULong i; - FT_ULong lastBase = 0; + FT_ULong lastBase = 0; + if ( defp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + + numRanges = TT_NEXT_ULONG( defp ); + /* defp + numRanges * 4 > valid->limit ? */ if ( numRanges > (FT_ULong)( valid->limit - defp ) / 4 ) FT_INVALID_TOO_SHORT; @@ -2997,13 +3002,18 @@ /* and the non-default table (these glyphs are specified here) */ if ( nondefOff != 0 ) { - FT_Byte* ndp = table + nondefOff; - FT_ULong numMappings = TT_NEXT_ULONG( ndp ); - FT_ULong i, lastUni = 0; + FT_Byte* ndp = table + nondefOff; + FT_ULong numMappings; + FT_ULong i, lastUni = 0; + + + if ( ndp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + numMappings = TT_NEXT_ULONG( ndp ); - /* numMappings * 4 > (FT_ULong)( valid->limit - ndp ) ? */ - if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 4 ) + /* numMappings * 5 > (FT_ULong)( valid->limit - ndp ) ? */ + if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 5 ) FT_INVALID_TOO_SHORT; for ( i = 0; i < numMappings; ++i )
CWE-125
null
null
13,844
tt_cmap4_validate( FT_Byte* table, FT_Validator valid ) { FT_Byte* p; FT_UInt length; FT_Byte *ends, *starts, *offsets, *deltas, *glyph_ids; FT_UInt num_segs; FT_Error error = FT_Err_Ok; if ( table + 2 + 2 > valid->limit ) FT_INVALID_TOO_SHORT; p = table + 2; /* skip format */ length = TT_NEXT_USHORT( p ); /* in certain fonts, the `length' field is invalid and goes */ /* out of bound. We try to correct this here... */ if ( table + length > valid->limit ) { if ( valid->level >= FT_VALIDATE_TIGHT ) FT_INVALID_TOO_SHORT; length = (FT_UInt)( valid->limit - table ); } if ( length < 16 ) FT_INVALID_TOO_SHORT; p = table + 6; num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */ if ( valid->level >= FT_VALIDATE_PARANOID ) { /* check that we have an even value here */ if ( num_segs & 1 ) FT_INVALID_DATA; } num_segs /= 2; if ( length < 16 + num_segs * 2 * 4 ) FT_INVALID_TOO_SHORT; /* check the search parameters - even though we never use them */ /* */ if ( valid->level >= FT_VALIDATE_PARANOID ) { /* check the values of `searchRange', `entrySelector', `rangeShift' */ FT_UInt search_range = TT_NEXT_USHORT( p ); FT_UInt entry_selector = TT_NEXT_USHORT( p ); FT_UInt range_shift = TT_NEXT_USHORT( p ); if ( ( search_range | range_shift ) & 1 ) /* must be even values */ FT_INVALID_DATA; search_range /= 2; range_shift /= 2; /* `search range' is the greatest power of 2 that is <= num_segs */ if ( search_range > num_segs || search_range * 2 < num_segs || search_range + range_shift != num_segs || search_range != ( 1U << entry_selector ) ) FT_INVALID_DATA; } ends = table + 14; starts = table + 16 + num_segs * 2; deltas = starts + num_segs * 2; offsets = deltas + num_segs * 2; glyph_ids = offsets + num_segs * 2; /* check last segment; its end count value must be 0xFFFF */ if ( valid->level >= FT_VALIDATE_PARANOID ) { p = ends + ( num_segs - 1 ) * 2; if ( TT_PEEK_USHORT( p ) != 0xFFFFU ) FT_INVALID_DATA; } { FT_UInt start, end, offset, n; FT_UInt last_start = 0, last_end = 0; FT_Int delta; FT_Byte* p_start = starts; FT_Byte* p_end = ends; FT_Byte* p_delta = deltas; FT_Byte* p_offset = offsets; for ( n = 0; n < num_segs; n++ ) { p = p_offset; start = TT_NEXT_USHORT( p_start ); end = TT_NEXT_USHORT( p_end ); delta = TT_NEXT_SHORT( p_delta ); offset = TT_NEXT_USHORT( p_offset ); if ( start > end ) FT_INVALID_DATA; /* this test should be performed at default validation level; */ /* unfortunately, some popular Asian fonts have overlapping */ /* ranges in their charmaps */ /* */ if ( start <= last_end && n > 0 ) { if ( valid->level >= FT_VALIDATE_TIGHT ) FT_INVALID_DATA; else { /* allow overlapping segments, provided their start points */ /* and end points, respectively, are in ascending order */ /* */ if ( last_start > start || last_end > end ) error |= TT_CMAP_FLAG_UNSORTED; else error |= TT_CMAP_FLAG_OVERLAPPING; } } if ( offset && offset != 0xFFFFU ) { p += offset; /* start of glyph ID array */ /* check that we point within the glyph IDs table only */ if ( valid->level >= FT_VALIDATE_TIGHT ) { if ( p < glyph_ids || p + ( end - start + 1 ) * 2 > table + length ) FT_INVALID_DATA; } /* Some fonts handle the last segment incorrectly. In */ /* theory, 0xFFFF might point to an ordinary glyph -- */ /* a cmap 4 is versatile and could be used for any */ /* encoding, not only Unicode. However, reality shows */ /* that far too many fonts are sloppy and incorrectly */ /* set all fields but `start' and `end' for the last */ /* segment if it contains only a single character. */ /* */ /* We thus omit the test here, delaying it to the */ /* routines that actually access the cmap. */ else if ( n != num_segs - 1 || !( start == 0xFFFFU && end == 0xFFFFU ) ) { if ( p < glyph_ids || p + ( end - start + 1 ) * 2 > valid->limit ) FT_INVALID_DATA; } /* check glyph indices within the segment range */ if ( valid->level >= FT_VALIDATE_TIGHT ) { FT_UInt i, idx; for ( i = start; i < end; i++ ) { idx = FT_NEXT_USHORT( p ); if ( idx != 0 ) { idx = (FT_UInt)( (FT_Int)idx + delta ) & 0xFFFFU; if ( idx >= TT_VALID_GLYPH_COUNT( valid ) ) FT_INVALID_GLYPH_ID; } } } } else if ( offset == 0xFFFFU ) { /* some fonts (erroneously?) use a range offset of 0xFFFF */ /* to mean missing glyph in cmap table */ /* */ if ( valid->level >= FT_VALIDATE_PARANOID || n != num_segs - 1 || !( start == 0xFFFFU && end == 0xFFFFU ) ) FT_INVALID_DATA; } last_start = start; last_end = end; } } return error; }
null
0
tt_cmap4_validate( FT_Byte* table, FT_Validator valid ) { FT_Byte* p; FT_UInt length; FT_Byte *ends, *starts, *offsets, *deltas, *glyph_ids; FT_UInt num_segs; FT_Error error = FT_Err_Ok; if ( table + 2 + 2 > valid->limit ) FT_INVALID_TOO_SHORT; p = table + 2; /* skip format */ length = TT_NEXT_USHORT( p ); /* in certain fonts, the `length' field is invalid and goes */ /* out of bound. We try to correct this here... */ if ( table + length > valid->limit ) { if ( valid->level >= FT_VALIDATE_TIGHT ) FT_INVALID_TOO_SHORT; length = (FT_UInt)( valid->limit - table ); } if ( length < 16 ) FT_INVALID_TOO_SHORT; p = table + 6; num_segs = TT_NEXT_USHORT( p ); /* read segCountX2 */ if ( valid->level >= FT_VALIDATE_PARANOID ) { /* check that we have an even value here */ if ( num_segs & 1 ) FT_INVALID_DATA; } num_segs /= 2; if ( length < 16 + num_segs * 2 * 4 ) FT_INVALID_TOO_SHORT; /* check the search parameters - even though we never use them */ /* */ if ( valid->level >= FT_VALIDATE_PARANOID ) { /* check the values of `searchRange', `entrySelector', `rangeShift' */ FT_UInt search_range = TT_NEXT_USHORT( p ); FT_UInt entry_selector = TT_NEXT_USHORT( p ); FT_UInt range_shift = TT_NEXT_USHORT( p ); if ( ( search_range | range_shift ) & 1 ) /* must be even values */ FT_INVALID_DATA; search_range /= 2; range_shift /= 2; /* `search range' is the greatest power of 2 that is <= num_segs */ if ( search_range > num_segs || search_range * 2 < num_segs || search_range + range_shift != num_segs || search_range != ( 1U << entry_selector ) ) FT_INVALID_DATA; } ends = table + 14; starts = table + 16 + num_segs * 2; deltas = starts + num_segs * 2; offsets = deltas + num_segs * 2; glyph_ids = offsets + num_segs * 2; /* check last segment; its end count value must be 0xFFFF */ if ( valid->level >= FT_VALIDATE_PARANOID ) { p = ends + ( num_segs - 1 ) * 2; if ( TT_PEEK_USHORT( p ) != 0xFFFFU ) FT_INVALID_DATA; } { FT_UInt start, end, offset, n; FT_UInt last_start = 0, last_end = 0; FT_Int delta; FT_Byte* p_start = starts; FT_Byte* p_end = ends; FT_Byte* p_delta = deltas; FT_Byte* p_offset = offsets; for ( n = 0; n < num_segs; n++ ) { p = p_offset; start = TT_NEXT_USHORT( p_start ); end = TT_NEXT_USHORT( p_end ); delta = TT_NEXT_SHORT( p_delta ); offset = TT_NEXT_USHORT( p_offset ); if ( start > end ) FT_INVALID_DATA; /* this test should be performed at default validation level; */ /* unfortunately, some popular Asian fonts have overlapping */ /* ranges in their charmaps */ /* */ if ( start <= last_end && n > 0 ) { if ( valid->level >= FT_VALIDATE_TIGHT ) FT_INVALID_DATA; else { /* allow overlapping segments, provided their start points */ /* and end points, respectively, are in ascending order */ /* */ if ( last_start > start || last_end > end ) error |= TT_CMAP_FLAG_UNSORTED; else error |= TT_CMAP_FLAG_OVERLAPPING; } } if ( offset && offset != 0xFFFFU ) { p += offset; /* start of glyph ID array */ /* check that we point within the glyph IDs table only */ if ( valid->level >= FT_VALIDATE_TIGHT ) { if ( p < glyph_ids || p + ( end - start + 1 ) * 2 > table + length ) FT_INVALID_DATA; } /* Some fonts handle the last segment incorrectly. In */ /* theory, 0xFFFF might point to an ordinary glyph -- */ /* a cmap 4 is versatile and could be used for any */ /* encoding, not only Unicode. However, reality shows */ /* that far too many fonts are sloppy and incorrectly */ /* set all fields but `start' and `end' for the last */ /* segment if it contains only a single character. */ /* */ /* We thus omit the test here, delaying it to the */ /* routines that actually access the cmap. */ else if ( n != num_segs - 1 || !( start == 0xFFFFU && end == 0xFFFFU ) ) { if ( p < glyph_ids || p + ( end - start + 1 ) * 2 > valid->limit ) FT_INVALID_DATA; } /* check glyph indices within the segment range */ if ( valid->level >= FT_VALIDATE_TIGHT ) { FT_UInt i, idx; for ( i = start; i < end; i++ ) { idx = FT_NEXT_USHORT( p ); if ( idx != 0 ) { idx = (FT_UInt)( (FT_Int)idx + delta ) & 0xFFFFU; if ( idx >= TT_VALID_GLYPH_COUNT( valid ) ) FT_INVALID_GLYPH_ID; } } } } else if ( offset == 0xFFFFU ) { /* some fonts (erroneously?) use a range offset of 0xFFFF */ /* to mean missing glyph in cmap table */ /* */ if ( valid->level >= FT_VALIDATE_PARANOID || n != num_segs - 1 || !( start == 0xFFFFU && end == 0xFFFFU ) ) FT_INVALID_DATA; } last_start = start; last_end = end; } } return error; }
@@ -2968,12 +2968,17 @@ /* through the normal Unicode cmap, no GIDs, just check order) */ if ( defOff != 0 ) { - FT_Byte* defp = table + defOff; - FT_ULong numRanges = TT_NEXT_ULONG( defp ); + FT_Byte* defp = table + defOff; + FT_ULong numRanges; FT_ULong i; - FT_ULong lastBase = 0; + FT_ULong lastBase = 0; + if ( defp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + + numRanges = TT_NEXT_ULONG( defp ); + /* defp + numRanges * 4 > valid->limit ? */ if ( numRanges > (FT_ULong)( valid->limit - defp ) / 4 ) FT_INVALID_TOO_SHORT; @@ -2997,13 +3002,18 @@ /* and the non-default table (these glyphs are specified here) */ if ( nondefOff != 0 ) { - FT_Byte* ndp = table + nondefOff; - FT_ULong numMappings = TT_NEXT_ULONG( ndp ); - FT_ULong i, lastUni = 0; + FT_Byte* ndp = table + nondefOff; + FT_ULong numMappings; + FT_ULong i, lastUni = 0; + + + if ( ndp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + numMappings = TT_NEXT_ULONG( ndp ); - /* numMappings * 4 > (FT_ULong)( valid->limit - ndp ) ? */ - if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 4 ) + /* numMappings * 5 > (FT_ULong)( valid->limit - ndp ) ? */ + if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 5 ) FT_INVALID_TOO_SHORT; for ( i = 0; i < numMappings; ++i )
CWE-125
null
null
13,845
tt_cmap6_char_index( TT_CMap cmap, FT_UInt32 char_code ) { FT_Byte* table = cmap->data; FT_UInt result = 0; FT_Byte* p = table + 6; FT_UInt start = TT_NEXT_USHORT( p ); FT_UInt count = TT_NEXT_USHORT( p ); FT_UInt idx = (FT_UInt)( char_code - start ); if ( idx < count ) { p += 2 * idx; result = TT_PEEK_USHORT( p ); } return result; }
null
0
tt_cmap6_char_index( TT_CMap cmap, FT_UInt32 char_code ) { FT_Byte* table = cmap->data; FT_UInt result = 0; FT_Byte* p = table + 6; FT_UInt start = TT_NEXT_USHORT( p ); FT_UInt count = TT_NEXT_USHORT( p ); FT_UInt idx = (FT_UInt)( char_code - start ); if ( idx < count ) { p += 2 * idx; result = TT_PEEK_USHORT( p ); } return result; }
@@ -2968,12 +2968,17 @@ /* through the normal Unicode cmap, no GIDs, just check order) */ if ( defOff != 0 ) { - FT_Byte* defp = table + defOff; - FT_ULong numRanges = TT_NEXT_ULONG( defp ); + FT_Byte* defp = table + defOff; + FT_ULong numRanges; FT_ULong i; - FT_ULong lastBase = 0; + FT_ULong lastBase = 0; + if ( defp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + + numRanges = TT_NEXT_ULONG( defp ); + /* defp + numRanges * 4 > valid->limit ? */ if ( numRanges > (FT_ULong)( valid->limit - defp ) / 4 ) FT_INVALID_TOO_SHORT; @@ -2997,13 +3002,18 @@ /* and the non-default table (these glyphs are specified here) */ if ( nondefOff != 0 ) { - FT_Byte* ndp = table + nondefOff; - FT_ULong numMappings = TT_NEXT_ULONG( ndp ); - FT_ULong i, lastUni = 0; + FT_Byte* ndp = table + nondefOff; + FT_ULong numMappings; + FT_ULong i, lastUni = 0; + + + if ( ndp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + numMappings = TT_NEXT_ULONG( ndp ); - /* numMappings * 4 > (FT_ULong)( valid->limit - ndp ) ? */ - if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 4 ) + /* numMappings * 5 > (FT_ULong)( valid->limit - ndp ) ? */ + if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 5 ) FT_INVALID_TOO_SHORT; for ( i = 0; i < numMappings; ++i )
CWE-125
null
null
13,846
tt_cmap6_char_next( TT_CMap cmap, FT_UInt32 *pchar_code ) { FT_Byte* table = cmap->data; FT_UInt32 result = 0; FT_UInt32 char_code = *pchar_code + 1; FT_UInt gindex = 0; FT_Byte* p = table + 6; FT_UInt start = TT_NEXT_USHORT( p ); FT_UInt count = TT_NEXT_USHORT( p ); FT_UInt idx; if ( char_code >= 0x10000UL ) return 0; if ( char_code < start ) char_code = start; idx = (FT_UInt)( char_code - start ); p += 2 * idx; for ( ; idx < count; idx++ ) { gindex = TT_NEXT_USHORT( p ); if ( gindex != 0 ) { result = char_code; break; } if ( char_code >= 0xFFFFU ) return 0; char_code++; } *pchar_code = result; return gindex; }
null
0
tt_cmap6_char_next( TT_CMap cmap, FT_UInt32 *pchar_code ) { FT_Byte* table = cmap->data; FT_UInt32 result = 0; FT_UInt32 char_code = *pchar_code + 1; FT_UInt gindex = 0; FT_Byte* p = table + 6; FT_UInt start = TT_NEXT_USHORT( p ); FT_UInt count = TT_NEXT_USHORT( p ); FT_UInt idx; if ( char_code >= 0x10000UL ) return 0; if ( char_code < start ) char_code = start; idx = (FT_UInt)( char_code - start ); p += 2 * idx; for ( ; idx < count; idx++ ) { gindex = TT_NEXT_USHORT( p ); if ( gindex != 0 ) { result = char_code; break; } if ( char_code >= 0xFFFFU ) return 0; char_code++; } *pchar_code = result; return gindex; }
@@ -2968,12 +2968,17 @@ /* through the normal Unicode cmap, no GIDs, just check order) */ if ( defOff != 0 ) { - FT_Byte* defp = table + defOff; - FT_ULong numRanges = TT_NEXT_ULONG( defp ); + FT_Byte* defp = table + defOff; + FT_ULong numRanges; FT_ULong i; - FT_ULong lastBase = 0; + FT_ULong lastBase = 0; + if ( defp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + + numRanges = TT_NEXT_ULONG( defp ); + /* defp + numRanges * 4 > valid->limit ? */ if ( numRanges > (FT_ULong)( valid->limit - defp ) / 4 ) FT_INVALID_TOO_SHORT; @@ -2997,13 +3002,18 @@ /* and the non-default table (these glyphs are specified here) */ if ( nondefOff != 0 ) { - FT_Byte* ndp = table + nondefOff; - FT_ULong numMappings = TT_NEXT_ULONG( ndp ); - FT_ULong i, lastUni = 0; + FT_Byte* ndp = table + nondefOff; + FT_ULong numMappings; + FT_ULong i, lastUni = 0; + + + if ( ndp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + numMappings = TT_NEXT_ULONG( ndp ); - /* numMappings * 4 > (FT_ULong)( valid->limit - ndp ) ? */ - if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 4 ) + /* numMappings * 5 > (FT_ULong)( valid->limit - ndp ) ? */ + if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 5 ) FT_INVALID_TOO_SHORT; for ( i = 0; i < numMappings; ++i )
CWE-125
null
null
13,847
tt_cmap8_char_index( TT_CMap cmap, FT_UInt32 char_code ) { FT_Byte* table = cmap->data; FT_UInt result = 0; FT_Byte* p = table + 8204; FT_UInt32 num_groups = TT_NEXT_ULONG( p ); FT_UInt32 start, end, start_id; for ( ; num_groups > 0; num_groups-- ) { start = TT_NEXT_ULONG( p ); end = TT_NEXT_ULONG( p ); start_id = TT_NEXT_ULONG( p ); if ( char_code < start ) break; if ( char_code <= end ) { if ( start_id > 0xFFFFFFFFUL - ( char_code - start ) ) return 0; result = (FT_UInt)( start_id + ( char_code - start ) ); break; } } return result; }
null
0
tt_cmap8_char_index( TT_CMap cmap, FT_UInt32 char_code ) { FT_Byte* table = cmap->data; FT_UInt result = 0; FT_Byte* p = table + 8204; FT_UInt32 num_groups = TT_NEXT_ULONG( p ); FT_UInt32 start, end, start_id; for ( ; num_groups > 0; num_groups-- ) { start = TT_NEXT_ULONG( p ); end = TT_NEXT_ULONG( p ); start_id = TT_NEXT_ULONG( p ); if ( char_code < start ) break; if ( char_code <= end ) { if ( start_id > 0xFFFFFFFFUL - ( char_code - start ) ) return 0; result = (FT_UInt)( start_id + ( char_code - start ) ); break; } } return result; }
@@ -2968,12 +2968,17 @@ /* through the normal Unicode cmap, no GIDs, just check order) */ if ( defOff != 0 ) { - FT_Byte* defp = table + defOff; - FT_ULong numRanges = TT_NEXT_ULONG( defp ); + FT_Byte* defp = table + defOff; + FT_ULong numRanges; FT_ULong i; - FT_ULong lastBase = 0; + FT_ULong lastBase = 0; + if ( defp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + + numRanges = TT_NEXT_ULONG( defp ); + /* defp + numRanges * 4 > valid->limit ? */ if ( numRanges > (FT_ULong)( valid->limit - defp ) / 4 ) FT_INVALID_TOO_SHORT; @@ -2997,13 +3002,18 @@ /* and the non-default table (these glyphs are specified here) */ if ( nondefOff != 0 ) { - FT_Byte* ndp = table + nondefOff; - FT_ULong numMappings = TT_NEXT_ULONG( ndp ); - FT_ULong i, lastUni = 0; + FT_Byte* ndp = table + nondefOff; + FT_ULong numMappings; + FT_ULong i, lastUni = 0; + + + if ( ndp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + numMappings = TT_NEXT_ULONG( ndp ); - /* numMappings * 4 > (FT_ULong)( valid->limit - ndp ) ? */ - if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 4 ) + /* numMappings * 5 > (FT_ULong)( valid->limit - ndp ) ? */ + if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 5 ) FT_INVALID_TOO_SHORT; for ( i = 0; i < numMappings; ++i )
CWE-125
null
null
13,848
tt_cmap8_char_next( TT_CMap cmap, FT_UInt32 *pchar_code ) { FT_Face face = cmap->cmap.charmap.face; FT_UInt32 result = 0; FT_UInt32 char_code; FT_UInt gindex = 0; FT_Byte* table = cmap->data; FT_Byte* p = table + 8204; FT_UInt32 num_groups = TT_NEXT_ULONG( p ); FT_UInt32 start, end, start_id; if ( *pchar_code >= 0xFFFFFFFFUL ) return 0; char_code = *pchar_code + 1; p = table + 8208; for ( ; num_groups > 0; num_groups-- ) { start = TT_NEXT_ULONG( p ); end = TT_NEXT_ULONG( p ); start_id = TT_NEXT_ULONG( p ); if ( char_code < start ) char_code = start; Again: if ( char_code <= end ) { /* ignore invalid group */ if ( start_id > 0xFFFFFFFFUL - ( char_code - start ) ) continue; gindex = (FT_UInt)( start_id + ( char_code - start ) ); /* does first element of group point to `.notdef' glyph? */ if ( gindex == 0 ) { if ( char_code >= 0xFFFFFFFFUL ) break; char_code++; goto Again; } /* if `gindex' is invalid, the remaining values */ /* in this group are invalid, too */ if ( gindex >= (FT_UInt)face->num_glyphs ) { gindex = 0; continue; } result = char_code; break; } } *pchar_code = result; return gindex; }
null
0
tt_cmap8_char_next( TT_CMap cmap, FT_UInt32 *pchar_code ) { FT_Face face = cmap->cmap.charmap.face; FT_UInt32 result = 0; FT_UInt32 char_code; FT_UInt gindex = 0; FT_Byte* table = cmap->data; FT_Byte* p = table + 8204; FT_UInt32 num_groups = TT_NEXT_ULONG( p ); FT_UInt32 start, end, start_id; if ( *pchar_code >= 0xFFFFFFFFUL ) return 0; char_code = *pchar_code + 1; p = table + 8208; for ( ; num_groups > 0; num_groups-- ) { start = TT_NEXT_ULONG( p ); end = TT_NEXT_ULONG( p ); start_id = TT_NEXT_ULONG( p ); if ( char_code < start ) char_code = start; Again: if ( char_code <= end ) { /* ignore invalid group */ if ( start_id > 0xFFFFFFFFUL - ( char_code - start ) ) continue; gindex = (FT_UInt)( start_id + ( char_code - start ) ); /* does first element of group point to `.notdef' glyph? */ if ( gindex == 0 ) { if ( char_code >= 0xFFFFFFFFUL ) break; char_code++; goto Again; } /* if `gindex' is invalid, the remaining values */ /* in this group are invalid, too */ if ( gindex >= (FT_UInt)face->num_glyphs ) { gindex = 0; continue; } result = char_code; break; } } *pchar_code = result; return gindex; }
@@ -2968,12 +2968,17 @@ /* through the normal Unicode cmap, no GIDs, just check order) */ if ( defOff != 0 ) { - FT_Byte* defp = table + defOff; - FT_ULong numRanges = TT_NEXT_ULONG( defp ); + FT_Byte* defp = table + defOff; + FT_ULong numRanges; FT_ULong i; - FT_ULong lastBase = 0; + FT_ULong lastBase = 0; + if ( defp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + + numRanges = TT_NEXT_ULONG( defp ); + /* defp + numRanges * 4 > valid->limit ? */ if ( numRanges > (FT_ULong)( valid->limit - defp ) / 4 ) FT_INVALID_TOO_SHORT; @@ -2997,13 +3002,18 @@ /* and the non-default table (these glyphs are specified here) */ if ( nondefOff != 0 ) { - FT_Byte* ndp = table + nondefOff; - FT_ULong numMappings = TT_NEXT_ULONG( ndp ); - FT_ULong i, lastUni = 0; + FT_Byte* ndp = table + nondefOff; + FT_ULong numMappings; + FT_ULong i, lastUni = 0; + + + if ( ndp + 4 > valid->limit ) + FT_INVALID_TOO_SHORT; + numMappings = TT_NEXT_ULONG( ndp ); - /* numMappings * 4 > (FT_ULong)( valid->limit - ndp ) ? */ - if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 4 ) + /* numMappings * 5 > (FT_ULong)( valid->limit - ndp ) ? */ + if ( numMappings > ( (FT_ULong)( valid->limit - ndp ) ) / 5 ) FT_INVALID_TOO_SHORT; for ( i = 0; i < numMappings; ++i )
CWE-125
null
null
13,849
T1_Finalize_Parser( T1_Parser parser ) { FT_Memory memory = parser->root.memory; /* always free the private dictionary */ FT_FREE( parser->private_dict ); /* free the base dictionary only when we have a disk stream */ if ( !parser->in_memory ) FT_FREE( parser->base_dict ); parser->root.funcs.done( &parser->root ); }
null
0
T1_Finalize_Parser( T1_Parser parser ) { FT_Memory memory = parser->root.memory; /* always free the private dictionary */ FT_FREE( parser->private_dict ); /* free the base dictionary only when we have a disk stream */ if ( !parser->in_memory ) FT_FREE( parser->base_dict ); parser->root.funcs.done( &parser->root ); }
@@ -334,7 +334,6 @@ /* first of all, look at the `eexec' keyword */ FT_Byte* cur = parser->base_dict; FT_Byte* limit = cur + parser->base_len; - FT_Byte c; FT_Pointer pos_lf; FT_Bool test_cr; @@ -342,9 +341,9 @@ Again: for (;;) { - c = cur[0]; - if ( c == 'e' && cur + 9 < limit ) /* 9 = 5 letters for `eexec' + */ - /* whitespace + 4 chars */ + if ( cur[0] == 'e' && + cur + 9 < limit ) /* 9 = 5 letters for `eexec' + */ + /* whitespace + 4 chars */ { if ( cur[1] == 'e' && cur[2] == 'x' && @@ -374,8 +373,15 @@ while ( cur < limit ) { - if ( *cur == 'e' && ft_strncmp( (char*)cur, "eexec", 5 ) == 0 ) - goto Found; + if ( cur[0] == 'e' && + cur + 5 < limit ) + { + if ( cur[1] == 'e' && + cur[2] == 'x' && + cur[3] == 'e' && + cur[4] == 'c' ) + goto Found; + } T1_Skip_PS_Token( parser ); if ( parser->root.error )
CWE-125
null
null
13,850
T1_New_Parser( T1_Parser parser, FT_Stream stream, FT_Memory memory, PSAux_Service psaux ) { FT_Error error; FT_UShort tag; FT_ULong size; psaux->ps_parser_funcs->init( &parser->root, NULL, NULL, memory ); parser->stream = stream; parser->base_len = 0; parser->base_dict = NULL; parser->private_len = 0; parser->private_dict = NULL; parser->in_pfb = 0; parser->in_memory = 0; parser->single_block = 0; /* check the header format */ error = check_type1_format( stream, "%!PS-AdobeFont", 14 ); if ( error ) { if ( FT_ERR_NEQ( error, Unknown_File_Format ) ) goto Exit; error = check_type1_format( stream, "%!FontType", 10 ); if ( error ) { FT_TRACE2(( " not a Type 1 font\n" )); goto Exit; } } /******************************************************************/ /* */ /* Here a short summary of what is going on: */ /* */ /* When creating a new Type 1 parser, we try to locate and load */ /* the base dictionary if this is possible (i.e., for PFB */ /* files). Otherwise, we load the whole font into memory. */ /* */ /* When `loading' the base dictionary, we only setup pointers */ /* in the case of a memory-based stream. Otherwise, we */ /* allocate and load the base dictionary in it. */ /* */ /* parser->in_pfb is set if we are in a binary (`.pfb') font. */ /* parser->in_memory is set if we have a memory stream. */ /* */ /* try to compute the size of the base dictionary; */ /* look for a Postscript binary file tag, i.e., 0x8001 */ if ( FT_STREAM_SEEK( 0L ) ) goto Exit; error = read_pfb_tag( stream, &tag, &size ); if ( error ) goto Exit; if ( tag != 0x8001U ) { /* assume that this is a PFA file for now; an error will */ /* be produced later when more things are checked */ if ( FT_STREAM_SEEK( 0L ) ) goto Exit; size = stream->size; } else parser->in_pfb = 1; /* now, try to load `size' bytes of the `base' dictionary we */ /* found previously */ /* if it is a memory-based resource, set up pointers */ if ( !stream->read ) { parser->base_dict = (FT_Byte*)stream->base + stream->pos; parser->base_len = size; parser->in_memory = 1; /* check that the `size' field is valid */ if ( FT_STREAM_SKIP( size ) ) goto Exit; } else { /* read segment in memory -- this is clumsy, but so does the format */ if ( FT_ALLOC( parser->base_dict, size ) || FT_STREAM_READ( parser->base_dict, size ) ) goto Exit; parser->base_len = size; } parser->root.base = parser->base_dict; parser->root.cursor = parser->base_dict; parser->root.limit = parser->root.cursor + parser->base_len; Exit: if ( error && !parser->in_memory ) FT_FREE( parser->base_dict ); return error; }
null
0
T1_New_Parser( T1_Parser parser, FT_Stream stream, FT_Memory memory, PSAux_Service psaux ) { FT_Error error; FT_UShort tag; FT_ULong size; psaux->ps_parser_funcs->init( &parser->root, NULL, NULL, memory ); parser->stream = stream; parser->base_len = 0; parser->base_dict = NULL; parser->private_len = 0; parser->private_dict = NULL; parser->in_pfb = 0; parser->in_memory = 0; parser->single_block = 0; /* check the header format */ error = check_type1_format( stream, "%!PS-AdobeFont", 14 ); if ( error ) { if ( FT_ERR_NEQ( error, Unknown_File_Format ) ) goto Exit; error = check_type1_format( stream, "%!FontType", 10 ); if ( error ) { FT_TRACE2(( " not a Type 1 font\n" )); goto Exit; } } /******************************************************************/ /* */ /* Here a short summary of what is going on: */ /* */ /* When creating a new Type 1 parser, we try to locate and load */ /* the base dictionary if this is possible (i.e., for PFB */ /* files). Otherwise, we load the whole font into memory. */ /* */ /* When `loading' the base dictionary, we only setup pointers */ /* in the case of a memory-based stream. Otherwise, we */ /* allocate and load the base dictionary in it. */ /* */ /* parser->in_pfb is set if we are in a binary (`.pfb') font. */ /* parser->in_memory is set if we have a memory stream. */ /* */ /* try to compute the size of the base dictionary; */ /* look for a Postscript binary file tag, i.e., 0x8001 */ if ( FT_STREAM_SEEK( 0L ) ) goto Exit; error = read_pfb_tag( stream, &tag, &size ); if ( error ) goto Exit; if ( tag != 0x8001U ) { /* assume that this is a PFA file for now; an error will */ /* be produced later when more things are checked */ if ( FT_STREAM_SEEK( 0L ) ) goto Exit; size = stream->size; } else parser->in_pfb = 1; /* now, try to load `size' bytes of the `base' dictionary we */ /* found previously */ /* if it is a memory-based resource, set up pointers */ if ( !stream->read ) { parser->base_dict = (FT_Byte*)stream->base + stream->pos; parser->base_len = size; parser->in_memory = 1; /* check that the `size' field is valid */ if ( FT_STREAM_SKIP( size ) ) goto Exit; } else { /* read segment in memory -- this is clumsy, but so does the format */ if ( FT_ALLOC( parser->base_dict, size ) || FT_STREAM_READ( parser->base_dict, size ) ) goto Exit; parser->base_len = size; } parser->root.base = parser->base_dict; parser->root.cursor = parser->base_dict; parser->root.limit = parser->root.cursor + parser->base_len; Exit: if ( error && !parser->in_memory ) FT_FREE( parser->base_dict ); return error; }
@@ -389,6 +389,15 @@ cur = limit; limit = parser->base_dict + parser->base_len; + + if ( cur >= limit ) + { + FT_ERROR(( "T1_Get_Private_Dict:" + " premature end in private dictionary\n" )); + error = FT_THROW( Invalid_File_Format ); + goto Exit; + } + goto Again; /* now determine where to write the _encrypted_ binary private */
CWE-125
null
null
13,851
check_type1_format( FT_Stream stream, const char* header_string, size_t header_length ) { FT_Error error; FT_UShort tag; FT_ULong dummy; if ( FT_STREAM_SEEK( 0 ) ) goto Exit; error = read_pfb_tag( stream, &tag, &dummy ); if ( error ) goto Exit; /* We assume that the first segment in a PFB is always encoded as */ /* text. This might be wrong (and the specification doesn't insist */ /* on that), but we have never seen a counterexample. */ if ( tag != 0x8001U && FT_STREAM_SEEK( 0 ) ) goto Exit; if ( !FT_FRAME_ENTER( header_length ) ) { error = FT_Err_Ok; if ( ft_memcmp( stream->cursor, header_string, header_length ) != 0 ) error = FT_THROW( Unknown_File_Format ); FT_FRAME_EXIT(); } Exit: return error; }
null
0
check_type1_format( FT_Stream stream, const char* header_string, size_t header_length ) { FT_Error error; FT_UShort tag; FT_ULong dummy; if ( FT_STREAM_SEEK( 0 ) ) goto Exit; error = read_pfb_tag( stream, &tag, &dummy ); if ( error ) goto Exit; /* We assume that the first segment in a PFB is always encoded as */ /* text. This might be wrong (and the specification doesn't insist */ /* on that), but we have never seen a counterexample. */ if ( tag != 0x8001U && FT_STREAM_SEEK( 0 ) ) goto Exit; if ( !FT_FRAME_ENTER( header_length ) ) { error = FT_Err_Ok; if ( ft_memcmp( stream->cursor, header_string, header_length ) != 0 ) error = FT_THROW( Unknown_File_Format ); FT_FRAME_EXIT(); } Exit: return error; }
@@ -389,6 +389,15 @@ cur = limit; limit = parser->base_dict + parser->base_len; + + if ( cur >= limit ) + { + FT_ERROR(( "T1_Get_Private_Dict:" + " premature end in private dictionary\n" )); + error = FT_THROW( Invalid_File_Format ); + goto Exit; + } + goto Again; /* now determine where to write the _encrypted_ binary private */
CWE-125
null
null
13,852
_eXosip_is_public_address (const char *c_address) { return (0 != strncmp (c_address, "192.168", 7) && 0 != strncmp (c_address, "10.", 3) && 0 != strncmp (c_address, "172.16.", 7) && 0 != strncmp (c_address, "172.17.", 7) && 0 != strncmp (c_address, "172.18.", 7) && 0 != strncmp (c_address, "172.19.", 7) && 0 != strncmp (c_address, "172.20.", 7) && 0 != strncmp (c_address, "172.21.", 7) && 0 != strncmp (c_address, "172.22.", 7) && 0 != strncmp (c_address, "172.23.", 7) && 0 != strncmp (c_address, "172.24.", 7) && 0 != strncmp (c_address, "172.25.", 7) && 0 != strncmp (c_address, "172.26.", 7) && 0 != strncmp (c_address, "172.27.", 7) && 0 != strncmp (c_address, "172.28.", 7) && 0 != strncmp (c_address, "172.29.", 7) && 0 != strncmp (c_address, "172.30.", 7) && 0 != strncmp (c_address, "172.31.", 7) && 0 != strncmp (c_address, "169.254", 7)); }
null
0
_eXosip_is_public_address (const char *c_address) { return (0 != strncmp (c_address, "192.168", 7) && 0 != strncmp (c_address, "10.", 3) && 0 != strncmp (c_address, "172.16.", 7) && 0 != strncmp (c_address, "172.17.", 7) && 0 != strncmp (c_address, "172.18.", 7) && 0 != strncmp (c_address, "172.19.", 7) && 0 != strncmp (c_address, "172.20.", 7) && 0 != strncmp (c_address, "172.21.", 7) && 0 != strncmp (c_address, "172.22.", 7) && 0 != strncmp (c_address, "172.23.", 7) && 0 != strncmp (c_address, "172.24.", 7) && 0 != strncmp (c_address, "172.25.", 7) && 0 != strncmp (c_address, "172.26.", 7) && 0 != strncmp (c_address, "172.27.", 7) && 0 != strncmp (c_address, "172.28.", 7) && 0 != strncmp (c_address, "172.29.", 7) && 0 != strncmp (c_address, "172.30.", 7) && 0 != strncmp (c_address, "172.31.", 7) && 0 != strncmp (c_address, "169.254", 7)); }
@@ -730,6 +730,7 @@ eXosip_init (struct eXosip_t *excontext) excontext->autoanswer_bye = 1; excontext->auto_masquerade_contact = 1; excontext->masquerade_via=0; + excontext->use_ephemeral_port=1; return OSIP_SUCCESS; } @@ -1057,7 +1058,10 @@ eXosip_set_option (struct eXosip_t *excontext, int opt, const void *value) val = *((int *) value); excontext->reuse_tcp_port = val; break; - + case EXOSIP_OPT_ENABLE_USE_EPHEMERAL_PORT: + val = *((int *) value); + excontext->use_ephemeral_port = val; + break; default: return OSIP_BADPARAMETER; }
CWE-189
null
null
13,853
eXosip_enable_ipv6 (int _ipv6_enable) { /* obsolete, use: eXosip_set_option(excontext, EXOSIP_OPT_ENABLE_IPV6, &val); */ }
null
0
eXosip_enable_ipv6 (int _ipv6_enable) { /* obsolete, use: eXosip_set_option(excontext, EXOSIP_OPT_ENABLE_IPV6, &val); */ }
@@ -730,6 +730,7 @@ eXosip_init (struct eXosip_t *excontext) excontext->autoanswer_bye = 1; excontext->auto_masquerade_contact = 1; excontext->masquerade_via=0; + excontext->use_ephemeral_port=1; return OSIP_SUCCESS; } @@ -1057,7 +1058,10 @@ eXosip_set_option (struct eXosip_t *excontext, int opt, const void *value) val = *((int *) value); excontext->reuse_tcp_port = val; break; - + case EXOSIP_OPT_ENABLE_USE_EPHEMERAL_PORT: + val = *((int *) value); + excontext->use_ephemeral_port = val; + break; default: return OSIP_BADPARAMETER; }
CWE-189
null
null
13,854
eXosip_find_free_port (struct eXosip_t *excontext, int free_port, int transport) { int res1; int res2; struct addrinfo *addrinfo_rtp = NULL; struct addrinfo *curinfo_rtp; struct addrinfo *addrinfo_rtcp = NULL; struct addrinfo *curinfo_rtcp; int sock; int count; for (count = 0; count < 8; count++) { if (excontext->ipv6_enable == 0) res1 = _eXosip_get_addrinfo (excontext, &addrinfo_rtp, "0.0.0.0", free_port + count * 2, transport); else res1 = _eXosip_get_addrinfo (excontext, &addrinfo_rtp, "::", free_port + count * 2, transport); if (res1 != 0) return res1; if (excontext->ipv6_enable == 0) res2 = _eXosip_get_addrinfo (excontext, &addrinfo_rtcp, "0.0.0.0", free_port + count * 2 + 1, transport); else res2 = _eXosip_get_addrinfo (excontext, &addrinfo_rtcp, "::", free_port + count * 2 + 1, transport); if (res2 != 0) { _eXosip_freeaddrinfo (addrinfo_rtp); return res2; } sock = -1; for (curinfo_rtp = addrinfo_rtp; curinfo_rtp; curinfo_rtp = curinfo_rtp->ai_next) { if (curinfo_rtp->ai_protocol && curinfo_rtp->ai_protocol != transport) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO3, NULL, "eXosip: Skipping protocol %d\n", curinfo_rtp->ai_protocol)); continue; } sock = (int) socket (curinfo_rtp->ai_family, curinfo_rtp->ai_socktype, curinfo_rtp->ai_protocol); if (sock < 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: Cannot create socket!\n")); continue; } if (curinfo_rtp->ai_family == AF_INET6) { #ifdef IPV6_V6ONLY if (setsockopt_ipv6only (sock)) { close (sock); sock = -1; OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: Cannot set socket option!\n")); continue; } #endif /* IPV6_V6ONLY */ } res1 = bind (sock, curinfo_rtp->ai_addr, curinfo_rtp->ai_addrlen); if (res1 < 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_WARNING, NULL, "eXosip: Cannot bind socket node: 0.0.0.0 family:%d\n", curinfo_rtp->ai_family)); close (sock); sock = -1; continue; } break; } _eXosip_freeaddrinfo (addrinfo_rtp); if (sock == -1) { _eXosip_freeaddrinfo (addrinfo_rtcp); continue; } close (sock); sock = -1; for (curinfo_rtcp = addrinfo_rtcp; curinfo_rtcp; curinfo_rtcp = curinfo_rtcp->ai_next) { if (curinfo_rtcp->ai_protocol && curinfo_rtcp->ai_protocol != transport) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO3, NULL, "eXosip: Skipping protocol %d\n", curinfo_rtcp->ai_protocol)); continue; } sock = (int) socket (curinfo_rtcp->ai_family, curinfo_rtcp->ai_socktype, curinfo_rtcp->ai_protocol); if (sock < 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: Cannot create socket!\n")); continue; } if (curinfo_rtcp->ai_family == AF_INET6) { #ifdef IPV6_V6ONLY if (setsockopt_ipv6only (sock)) { close (sock); sock = -1; OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: Cannot set socket option!\n")); continue; } #endif /* IPV6_V6ONLY */ } res1 = bind (sock, curinfo_rtcp->ai_addr, curinfo_rtcp->ai_addrlen); if (res1 < 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_WARNING, NULL, "eXosip: Cannot bind socket node: 0.0.0.0 family:%d\n", curinfo_rtp->ai_family)); close (sock); sock = -1; continue; } break; } _eXosip_freeaddrinfo (addrinfo_rtcp); /* the pair must be free */ if (sock == -1) continue; close (sock); sock = -1; return free_port + count * 2; } /* just get a free port */ if (excontext->ipv6_enable == 0) res1 = _eXosip_get_addrinfo (excontext, &addrinfo_rtp, "0.0.0.0", 0, transport); else res1 = _eXosip_get_addrinfo (excontext, &addrinfo_rtp, "::", 0, transport); if (res1) return res1; sock = -1; for (curinfo_rtp = addrinfo_rtp; curinfo_rtp; curinfo_rtp = curinfo_rtp->ai_next) { socklen_t len; struct sockaddr_storage ai_addr; if (curinfo_rtp->ai_protocol && curinfo_rtp->ai_protocol != transport) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO3, NULL, "eXosip: Skipping protocol %d\n", curinfo_rtp->ai_protocol)); continue; } sock = (int) socket (curinfo_rtp->ai_family, curinfo_rtp->ai_socktype, curinfo_rtp->ai_protocol); if (sock < 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: Cannot create socket!\n")); continue; } if (curinfo_rtp->ai_family == AF_INET6) { #ifdef IPV6_V6ONLY if (setsockopt_ipv6only (sock)) { close (sock); sock = -1; OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: Cannot set socket option!\n")); continue; } #endif /* IPV6_V6ONLY */ } res1 = bind (sock, curinfo_rtp->ai_addr, curinfo_rtp->ai_addrlen); if (res1 < 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_WARNING, NULL, "eXosip: Cannot bind socket node: 0.0.0.0 family:%d\n", curinfo_rtp->ai_family)); close (sock); sock = -1; continue; } len = sizeof (ai_addr); res1 = getsockname (sock, (struct sockaddr *) &ai_addr, &len); if (res1 != 0) { close (sock); sock = -1; continue; } close (sock); sock = -1; _eXosip_freeaddrinfo (addrinfo_rtp); if (curinfo_rtp->ai_family == AF_INET) return ntohs (((struct sockaddr_in *) &ai_addr)->sin_port); else return ntohs (((struct sockaddr_in6 *) &ai_addr)->sin6_port); } _eXosip_freeaddrinfo (addrinfo_rtp); if (sock != -1) { close (sock); sock = -1; } return OSIP_UNDEFINED_ERROR; }
null
0
eXosip_find_free_port (struct eXosip_t *excontext, int free_port, int transport) { int res1; int res2; struct addrinfo *addrinfo_rtp = NULL; struct addrinfo *curinfo_rtp; struct addrinfo *addrinfo_rtcp = NULL; struct addrinfo *curinfo_rtcp; int sock; int count; for (count = 0; count < 8; count++) { if (excontext->ipv6_enable == 0) res1 = _eXosip_get_addrinfo (excontext, &addrinfo_rtp, "0.0.0.0", free_port + count * 2, transport); else res1 = _eXosip_get_addrinfo (excontext, &addrinfo_rtp, "::", free_port + count * 2, transport); if (res1 != 0) return res1; if (excontext->ipv6_enable == 0) res2 = _eXosip_get_addrinfo (excontext, &addrinfo_rtcp, "0.0.0.0", free_port + count * 2 + 1, transport); else res2 = _eXosip_get_addrinfo (excontext, &addrinfo_rtcp, "::", free_port + count * 2 + 1, transport); if (res2 != 0) { _eXosip_freeaddrinfo (addrinfo_rtp); return res2; } sock = -1; for (curinfo_rtp = addrinfo_rtp; curinfo_rtp; curinfo_rtp = curinfo_rtp->ai_next) { if (curinfo_rtp->ai_protocol && curinfo_rtp->ai_protocol != transport) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO3, NULL, "eXosip: Skipping protocol %d\n", curinfo_rtp->ai_protocol)); continue; } sock = (int) socket (curinfo_rtp->ai_family, curinfo_rtp->ai_socktype, curinfo_rtp->ai_protocol); if (sock < 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: Cannot create socket!\n")); continue; } if (curinfo_rtp->ai_family == AF_INET6) { #ifdef IPV6_V6ONLY if (setsockopt_ipv6only (sock)) { close (sock); sock = -1; OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: Cannot set socket option!\n")); continue; } #endif /* IPV6_V6ONLY */ } res1 = bind (sock, curinfo_rtp->ai_addr, curinfo_rtp->ai_addrlen); if (res1 < 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_WARNING, NULL, "eXosip: Cannot bind socket node: 0.0.0.0 family:%d\n", curinfo_rtp->ai_family)); close (sock); sock = -1; continue; } break; } _eXosip_freeaddrinfo (addrinfo_rtp); if (sock == -1) { _eXosip_freeaddrinfo (addrinfo_rtcp); continue; } close (sock); sock = -1; for (curinfo_rtcp = addrinfo_rtcp; curinfo_rtcp; curinfo_rtcp = curinfo_rtcp->ai_next) { if (curinfo_rtcp->ai_protocol && curinfo_rtcp->ai_protocol != transport) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO3, NULL, "eXosip: Skipping protocol %d\n", curinfo_rtcp->ai_protocol)); continue; } sock = (int) socket (curinfo_rtcp->ai_family, curinfo_rtcp->ai_socktype, curinfo_rtcp->ai_protocol); if (sock < 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: Cannot create socket!\n")); continue; } if (curinfo_rtcp->ai_family == AF_INET6) { #ifdef IPV6_V6ONLY if (setsockopt_ipv6only (sock)) { close (sock); sock = -1; OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: Cannot set socket option!\n")); continue; } #endif /* IPV6_V6ONLY */ } res1 = bind (sock, curinfo_rtcp->ai_addr, curinfo_rtcp->ai_addrlen); if (res1 < 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_WARNING, NULL, "eXosip: Cannot bind socket node: 0.0.0.0 family:%d\n", curinfo_rtp->ai_family)); close (sock); sock = -1; continue; } break; } _eXosip_freeaddrinfo (addrinfo_rtcp); /* the pair must be free */ if (sock == -1) continue; close (sock); sock = -1; return free_port + count * 2; } /* just get a free port */ if (excontext->ipv6_enable == 0) res1 = _eXosip_get_addrinfo (excontext, &addrinfo_rtp, "0.0.0.0", 0, transport); else res1 = _eXosip_get_addrinfo (excontext, &addrinfo_rtp, "::", 0, transport); if (res1) return res1; sock = -1; for (curinfo_rtp = addrinfo_rtp; curinfo_rtp; curinfo_rtp = curinfo_rtp->ai_next) { socklen_t len; struct sockaddr_storage ai_addr; if (curinfo_rtp->ai_protocol && curinfo_rtp->ai_protocol != transport) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO3, NULL, "eXosip: Skipping protocol %d\n", curinfo_rtp->ai_protocol)); continue; } sock = (int) socket (curinfo_rtp->ai_family, curinfo_rtp->ai_socktype, curinfo_rtp->ai_protocol); if (sock < 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: Cannot create socket!\n")); continue; } if (curinfo_rtp->ai_family == AF_INET6) { #ifdef IPV6_V6ONLY if (setsockopt_ipv6only (sock)) { close (sock); sock = -1; OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: Cannot set socket option!\n")); continue; } #endif /* IPV6_V6ONLY */ } res1 = bind (sock, curinfo_rtp->ai_addr, curinfo_rtp->ai_addrlen); if (res1 < 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_WARNING, NULL, "eXosip: Cannot bind socket node: 0.0.0.0 family:%d\n", curinfo_rtp->ai_family)); close (sock); sock = -1; continue; } len = sizeof (ai_addr); res1 = getsockname (sock, (struct sockaddr *) &ai_addr, &len); if (res1 != 0) { close (sock); sock = -1; continue; } close (sock); sock = -1; _eXosip_freeaddrinfo (addrinfo_rtp); if (curinfo_rtp->ai_family == AF_INET) return ntohs (((struct sockaddr_in *) &ai_addr)->sin_port); else return ntohs (((struct sockaddr_in6 *) &ai_addr)->sin6_port); } _eXosip_freeaddrinfo (addrinfo_rtp); if (sock != -1) { close (sock); sock = -1; } return OSIP_UNDEFINED_ERROR; }
@@ -730,6 +730,7 @@ eXosip_init (struct eXosip_t *excontext) excontext->autoanswer_bye = 1; excontext->auto_masquerade_contact = 1; excontext->masquerade_via=0; + excontext->use_ephemeral_port=1; return OSIP_SUCCESS; } @@ -1057,7 +1058,10 @@ eXosip_set_option (struct eXosip_t *excontext, int opt, const void *value) val = *((int *) value); excontext->reuse_tcp_port = val; break; - + case EXOSIP_OPT_ENABLE_USE_EPHEMERAL_PORT: + val = *((int *) value); + excontext->use_ephemeral_port = val; + break; default: return OSIP_BADPARAMETER; }
CWE-189
null
null
13,855
eXosip_get_version (void) { return EXOSIP_VERSION; }
null
0
eXosip_get_version (void) { return EXOSIP_VERSION; }
@@ -730,6 +730,7 @@ eXosip_init (struct eXosip_t *excontext) excontext->autoanswer_bye = 1; excontext->auto_masquerade_contact = 1; excontext->masquerade_via=0; + excontext->use_ephemeral_port=1; return OSIP_SUCCESS; } @@ -1057,7 +1058,10 @@ eXosip_set_option (struct eXosip_t *excontext, int opt, const void *value) val = *((int *) value); excontext->reuse_tcp_port = val; break; - + case EXOSIP_OPT_ENABLE_USE_EPHEMERAL_PORT: + val = *((int *) value); + excontext->use_ephemeral_port = val; + break; default: return OSIP_BADPARAMETER; }
CWE-189
null
null
13,856
eXosip_listen_addr (struct eXosip_t *excontext, int transport, const char *addr, int port, int family, int secure) { int i = -1; if (excontext->eXtl_transport.enabled > 0) { /* already set */ OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: already listening somewhere\n")); return OSIP_WRONG_STATE; } if (transport == IPPROTO_UDP && secure == 0) eXosip_transport_udp_init (excontext); else if (transport == IPPROTO_TCP && secure == 0) eXosip_transport_tcp_init (excontext); #ifdef HAVE_OPENSSL_SSL_H #if !(OPENSSL_VERSION_NUMBER < 0x00908000L) else if (transport == IPPROTO_UDP) eXosip_transport_dtls_init (excontext); #endif else if (transport == IPPROTO_TCP) eXosip_transport_tls_init (excontext); #endif else return OSIP_BADPARAMETER; if (excontext->eXtl_transport.tl_init != NULL) excontext->eXtl_transport.tl_init (excontext); excontext->eXtl_transport.proto_family = family; excontext->eXtl_transport.proto_port = port; if (addr != NULL) snprintf (excontext->eXtl_transport.proto_ifs, sizeof (excontext->eXtl_transport.proto_ifs), "%s", addr); #ifdef AF_INET6 if (family == AF_INET6 && !addr) snprintf (excontext->eXtl_transport.proto_ifs, sizeof (excontext->eXtl_transport.proto_ifs), "::0"); #endif i = excontext->eXtl_transport.tl_open (excontext); if (i != 0) { if (excontext->eXtl_transport.tl_free != NULL) excontext->eXtl_transport.tl_free (excontext); return i; } if (transport == IPPROTO_UDP && secure == 0) snprintf (excontext->transport, sizeof (excontext->transport), "%s", "UDP"); else if (transport == IPPROTO_TCP && secure == 0) snprintf (excontext->transport, sizeof (excontext->transport), "%s", "TCP"); else if (transport == IPPROTO_UDP) snprintf (excontext->transport, sizeof (excontext->transport), "%s", "DTLS-UDP"); else if (transport == IPPROTO_TCP) snprintf (excontext->transport, sizeof (excontext->transport), "%s", "TLS"); #ifndef OSIP_MONOTHREAD if (excontext->j_thread == NULL) { excontext->j_thread = (void *) osip_thread_create (20000, _eXosip_thread, excontext); if (excontext->j_thread == NULL) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: Cannot start thread!\n")); return OSIP_UNDEFINED_ERROR; } } #endif return OSIP_SUCCESS; }
null
0
eXosip_listen_addr (struct eXosip_t *excontext, int transport, const char *addr, int port, int family, int secure) { int i = -1; if (excontext->eXtl_transport.enabled > 0) { /* already set */ OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: already listening somewhere\n")); return OSIP_WRONG_STATE; } if (transport == IPPROTO_UDP && secure == 0) eXosip_transport_udp_init (excontext); else if (transport == IPPROTO_TCP && secure == 0) eXosip_transport_tcp_init (excontext); #ifdef HAVE_OPENSSL_SSL_H #if !(OPENSSL_VERSION_NUMBER < 0x00908000L) else if (transport == IPPROTO_UDP) eXosip_transport_dtls_init (excontext); #endif else if (transport == IPPROTO_TCP) eXosip_transport_tls_init (excontext); #endif else return OSIP_BADPARAMETER; if (excontext->eXtl_transport.tl_init != NULL) excontext->eXtl_transport.tl_init (excontext); excontext->eXtl_transport.proto_family = family; excontext->eXtl_transport.proto_port = port; if (addr != NULL) snprintf (excontext->eXtl_transport.proto_ifs, sizeof (excontext->eXtl_transport.proto_ifs), "%s", addr); #ifdef AF_INET6 if (family == AF_INET6 && !addr) snprintf (excontext->eXtl_transport.proto_ifs, sizeof (excontext->eXtl_transport.proto_ifs), "::0"); #endif i = excontext->eXtl_transport.tl_open (excontext); if (i != 0) { if (excontext->eXtl_transport.tl_free != NULL) excontext->eXtl_transport.tl_free (excontext); return i; } if (transport == IPPROTO_UDP && secure == 0) snprintf (excontext->transport, sizeof (excontext->transport), "%s", "UDP"); else if (transport == IPPROTO_TCP && secure == 0) snprintf (excontext->transport, sizeof (excontext->transport), "%s", "TCP"); else if (transport == IPPROTO_UDP) snprintf (excontext->transport, sizeof (excontext->transport), "%s", "DTLS-UDP"); else if (transport == IPPROTO_TCP) snprintf (excontext->transport, sizeof (excontext->transport), "%s", "TLS"); #ifndef OSIP_MONOTHREAD if (excontext->j_thread == NULL) { excontext->j_thread = (void *) osip_thread_create (20000, _eXosip_thread, excontext); if (excontext->j_thread == NULL) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "eXosip: Cannot start thread!\n")); return OSIP_UNDEFINED_ERROR; } } #endif return OSIP_SUCCESS; }
@@ -730,6 +730,7 @@ eXosip_init (struct eXosip_t *excontext) excontext->autoanswer_bye = 1; excontext->auto_masquerade_contact = 1; excontext->masquerade_via=0; + excontext->use_ephemeral_port=1; return OSIP_SUCCESS; } @@ -1057,7 +1058,10 @@ eXosip_set_option (struct eXosip_t *excontext, int opt, const void *value) val = *((int *) value); excontext->reuse_tcp_port = val; break; - + case EXOSIP_OPT_ENABLE_USE_EPHEMERAL_PORT: + val = *((int *) value); + excontext->use_ephemeral_port = val; + break; default: return OSIP_BADPARAMETER; }
CWE-189
null
null
13,857
eXosip_malloc (void) { struct eXosip_t *ptr = (struct eXosip_t *) osip_malloc (sizeof (eXosip_t)); if (ptr) memset (ptr, 0, sizeof (eXosip_t)); return ptr; }
null
0
eXosip_malloc (void) { struct eXosip_t *ptr = (struct eXosip_t *) osip_malloc (sizeof (eXosip_t)); if (ptr) memset (ptr, 0, sizeof (eXosip_t)); return ptr; }
@@ -730,6 +730,7 @@ eXosip_init (struct eXosip_t *excontext) excontext->autoanswer_bye = 1; excontext->auto_masquerade_contact = 1; excontext->masquerade_via=0; + excontext->use_ephemeral_port=1; return OSIP_SUCCESS; } @@ -1057,7 +1058,10 @@ eXosip_set_option (struct eXosip_t *excontext, int opt, const void *value) val = *((int *) value); excontext->reuse_tcp_port = val; break; - + case EXOSIP_OPT_ENABLE_USE_EPHEMERAL_PORT: + val = *((int *) value); + excontext->use_ephemeral_port = val; + break; default: return OSIP_BADPARAMETER; }
CWE-189
null
null
13,858
eXosip_reset_transports (struct eXosip_t *excontext) { int i = OSIP_WRONG_STATE; if (excontext->eXtl_transport.tl_reset) i = excontext->eXtl_transport.tl_reset (excontext); return i; }
null
0
eXosip_reset_transports (struct eXosip_t *excontext) { int i = OSIP_WRONG_STATE; if (excontext->eXtl_transport.tl_reset) i = excontext->eXtl_transport.tl_reset (excontext); return i; }
@@ -730,6 +730,7 @@ eXosip_init (struct eXosip_t *excontext) excontext->autoanswer_bye = 1; excontext->auto_masquerade_contact = 1; excontext->masquerade_via=0; + excontext->use_ephemeral_port=1; return OSIP_SUCCESS; } @@ -1057,7 +1058,10 @@ eXosip_set_option (struct eXosip_t *excontext, int opt, const void *value) val = *((int *) value); excontext->reuse_tcp_port = val; break; - + case EXOSIP_OPT_ENABLE_USE_EPHEMERAL_PORT: + val = *((int *) value); + excontext->use_ephemeral_port = val; + break; default: return OSIP_BADPARAMETER; }
CWE-189
null
null
13,859
_tcp_tl_check_connected (struct eXosip_t *excontext) { struct eXtltcp *reserved = (struct eXtltcp *) excontext->eXtltcp_reserved; int pos; int res; for (pos = 0; pos < EXOSIP_MAX_SOCKETS; pos++) { if (reserved->socket_tab[pos].invalid > 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "_tcp_tl_check_connected: socket node is in invalid state:%s:%i, socket %d [pos=%d], family:%d\n", reserved->socket_tab[pos].remote_ip, reserved->socket_tab[pos].remote_port, reserved->socket_tab[pos].socket, pos, reserved->socket_tab[pos].ai_addr.sa_family)); _tcp_tl_close_sockinfo (&reserved->socket_tab[pos]); continue; } if (reserved->socket_tab[pos].socket > 0 && reserved->socket_tab[pos].ai_addrlen > 0) { res = _tcp_tl_is_connected (reserved->socket_tab[pos].socket); if (res > 0) { res = connect (reserved->socket_tab[pos].socket, &reserved->socket_tab[pos].ai_addr, reserved->socket_tab[pos].ai_addrlen); OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "_tcp_tl_check_connected: socket node:%s:%i, socket %d [pos=%d], family:%d, in progress\n", reserved->socket_tab[pos].remote_ip, reserved->socket_tab[pos].remote_port, reserved->socket_tab[pos].socket, pos, reserved->socket_tab[pos].ai_addr.sa_family)); continue; } else if (res == 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL, "_tcp_tl_check_connected: socket node:%s:%i , socket %d [pos=%d], family:%d, connected\n", reserved->socket_tab[pos].remote_ip, reserved->socket_tab[pos].remote_port, reserved->socket_tab[pos].socket, pos, reserved->socket_tab[pos].ai_addr.sa_family)); /* stop calling "connect()" */ reserved->socket_tab[pos].ai_addrlen = 0; continue; } else { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "_tcp_tl_check_connected: socket node:%s:%i, socket %d [pos=%d], family:%d, error\n", reserved->socket_tab[pos].remote_ip, reserved->socket_tab[pos].remote_port, reserved->socket_tab[pos].socket, pos, reserved->socket_tab[pos].ai_addr.sa_family)); _tcp_tl_close_sockinfo (&reserved->socket_tab[pos]); continue; } } } return 0; }
null
0
_tcp_tl_check_connected (struct eXosip_t *excontext) { struct eXtltcp *reserved = (struct eXtltcp *) excontext->eXtltcp_reserved; int pos; int res; for (pos = 0; pos < EXOSIP_MAX_SOCKETS; pos++) { if (reserved->socket_tab[pos].invalid > 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "_tcp_tl_check_connected: socket node is in invalid state:%s:%i, socket %d [pos=%d], family:%d\n", reserved->socket_tab[pos].remote_ip, reserved->socket_tab[pos].remote_port, reserved->socket_tab[pos].socket, pos, reserved->socket_tab[pos].ai_addr.sa_family)); _tcp_tl_close_sockinfo (&reserved->socket_tab[pos]); continue; } if (reserved->socket_tab[pos].socket > 0 && reserved->socket_tab[pos].ai_addrlen > 0) { res = _tcp_tl_is_connected (reserved->socket_tab[pos].socket); if (res > 0) { res = connect (reserved->socket_tab[pos].socket, &reserved->socket_tab[pos].ai_addr, reserved->socket_tab[pos].ai_addrlen); OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "_tcp_tl_check_connected: socket node:%s:%i, socket %d [pos=%d], family:%d, in progress\n", reserved->socket_tab[pos].remote_ip, reserved->socket_tab[pos].remote_port, reserved->socket_tab[pos].socket, pos, reserved->socket_tab[pos].ai_addr.sa_family)); continue; } else if (res == 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL, "_tcp_tl_check_connected: socket node:%s:%i , socket %d [pos=%d], family:%d, connected\n", reserved->socket_tab[pos].remote_ip, reserved->socket_tab[pos].remote_port, reserved->socket_tab[pos].socket, pos, reserved->socket_tab[pos].ai_addr.sa_family)); /* stop calling "connect()" */ reserved->socket_tab[pos].ai_addrlen = 0; continue; } else { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO2, NULL, "_tcp_tl_check_connected: socket node:%s:%i, socket %d [pos=%d], family:%d, error\n", reserved->socket_tab[pos].remote_ip, reserved->socket_tab[pos].remote_port, reserved->socket_tab[pos].socket, pos, reserved->socket_tab[pos].ai_addr.sa_family)); _tcp_tl_close_sockinfo (&reserved->socket_tab[pos]); continue; } } } return 0; }
@@ -416,7 +416,8 @@ handle_messages (struct eXosip_t *excontext, struct _tcp_stream *sockinfo) OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL, "socket %s:%i: message has no content-length: <%s>\n", sockinfo->remote_ip, sockinfo->remote_port, buf)); } clen = clen_header ? atoi (clen_header) : 0; - + if (clen<0) + return sockinfo->buflen; /* discard data */ /* undo our overwrite and advance end_headers */ *end_headers = END_HEADERS_STR[0]; end_headers += const_strlen (END_HEADERS_STR); @@ -1324,7 +1325,8 @@ tcp_tl_send_message (struct eXosip_t *excontext, osip_transaction_t * tr, osip_m OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL, "reusing REQUEST connection (to dest=%s:%i)\n", reserved->socket_tab[pos].remote_ip, reserved->socket_tab[pos].remote_port)); if (MSG_IS_REGISTER (sip) && atoi(sip->cseq->number)!=1) { } else { - _tcp_tl_update_local_target_use_ephemeral_port (excontext, sip, reserved->socket_tab[pos].ephemeral_port); + if (excontext->use_ephemeral_port==1) + _tcp_tl_update_local_target_use_ephemeral_port (excontext, sip, reserved->socket_tab[pos].ephemeral_port); } if (excontext->tcp_firewall_ip[0] != '\0' || excontext->auto_masquerade_contact > 0) _tcp_tl_update_local_target (excontext, sip, reserved->socket_tab[pos].natted_ip, reserved->socket_tab[pos].natted_port); @@ -1369,7 +1371,8 @@ tcp_tl_send_message (struct eXosip_t *excontext, osip_transaction_t * tr, osip_m out_socket = reserved->socket_tab[pos].socket; if (MSG_IS_REGISTER (sip) && atoi(sip->cseq->number)!=1) { } else { - _tcp_tl_update_local_target_use_ephemeral_port (excontext, sip, reserved->socket_tab[pos].ephemeral_port); + if (excontext->use_ephemeral_port==1) + _tcp_tl_update_local_target_use_ephemeral_port (excontext, sip, reserved->socket_tab[pos].ephemeral_port); } if (excontext->tcp_firewall_ip[0] != '\0' || excontext->auto_masquerade_contact > 0) _tcp_tl_update_local_target (excontext, sip, reserved->socket_tab[pos].natted_ip, reserved->socket_tab[pos].natted_port);
CWE-189
null
null
13,860
_tls_add_certificates (SSL_CTX * ctx) { int count = 0; #ifdef HAVE_WINCRYPT_H PCCERT_CONTEXT pCertCtx; X509 *cert = NULL; HCERTSTORE hStore = CertOpenSystemStore (0, L"CA"); for (pCertCtx = CertEnumCertificatesInStore (hStore, NULL); pCertCtx != NULL; pCertCtx = CertEnumCertificatesInStore (hStore, pCertCtx)) { cert = d2i_X509 (NULL, (const unsigned char **) &pCertCtx->pbCertEncoded, pCertCtx->cbCertEncoded); if (cert == NULL) { continue; } /*tls_dump_cert_info("CA", cert); */ if (!X509_STORE_add_cert (ctx->cert_store, cert)) { X509_free (cert); continue; } count++; X509_free (cert); } CertCloseStore (hStore, 0); hStore = CertOpenSystemStore (0, L"ROOT"); for (pCertCtx = CertEnumCertificatesInStore (hStore, NULL); pCertCtx != NULL; pCertCtx = CertEnumCertificatesInStore (hStore, pCertCtx)) { cert = d2i_X509 (NULL, (const unsigned char **) &pCertCtx->pbCertEncoded, pCertCtx->cbCertEncoded); if (cert == NULL) { continue; } /*tls_dump_cert_info("ROOT", cert); */ if (!X509_STORE_add_cert (ctx->cert_store, cert)) { X509_free (cert); continue; } count++; X509_free (cert); } CertCloseStore (hStore, 0); hStore = CertOpenSystemStore (0, L"MY"); for (pCertCtx = CertEnumCertificatesInStore (hStore, NULL); pCertCtx != NULL; pCertCtx = CertEnumCertificatesInStore (hStore, pCertCtx)) { cert = d2i_X509 (NULL, (const unsigned char **) &pCertCtx->pbCertEncoded, pCertCtx->cbCertEncoded); if (cert == NULL) { continue; } /*tls_dump_cert_info("MY", cert); */ if (!X509_STORE_add_cert (ctx->cert_store, cert)) { X509_free (cert); continue; } count++; X509_free (cert); } CertCloseStore (hStore, 0); hStore = CertOpenSystemStore (0, L"Trustedpublisher"); for (pCertCtx = CertEnumCertificatesInStore (hStore, NULL); pCertCtx != NULL; pCertCtx = CertEnumCertificatesInStore (hStore, pCertCtx)) { cert = d2i_X509 (NULL, (const unsigned char **) &pCertCtx->pbCertEncoded, pCertCtx->cbCertEncoded); if (cert == NULL) { continue; } /*tls_dump_cert_info("Trustedpublisher", cert); */ if (!X509_STORE_add_cert (ctx->cert_store, cert)) { X509_free (cert); continue; } count++; X509_free (cert); } CertCloseStore (hStore, 0); #elif defined(__APPLE__) && (TARGET_OS_IPHONE==0) SecKeychainSearchRef pSecKeychainSearch = NULL; SecKeychainRef pSecKeychain; OSStatus status = noErr; X509 *cert = NULL; SInt32 osx_version = 0; if (Gestalt (gestaltSystemVersion, &osx_version) != noErr) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "macosx certificate store: can't get osx version")); return 0; } if (osx_version >= 0x1050) { /* Leopard store location */ status = SecKeychainOpen ("/System/Library/Keychains/SystemRootCertificates.keychain", &pSecKeychain); } else { /* Tiger and below store location */ status = SecKeychainOpen ("/System/Library/Keychains/X509Anchors", &pSecKeychain); } if (status != noErr) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "macosx certificate store: can't get osx version")); return 0; } status = SecKeychainSearchCreateFromAttributes (pSecKeychain, kSecCertificateItemClass, NULL, &pSecKeychainSearch); for (;;) { SecKeychainItemRef pSecKeychainItem = nil; status = SecKeychainSearchCopyNext (pSecKeychainSearch, &pSecKeychainItem); if (status == errSecItemNotFound) { break; } if (status == noErr) { void *_pCertData; UInt32 _pCertLength; status = SecKeychainItemCopyAttributesAndData (pSecKeychainItem, NULL, NULL, NULL, &_pCertLength, &_pCertData); if (status == noErr && _pCertData != NULL) { unsigned char *ptr; ptr = _pCertData; /*required because d2i_X509 is modifying pointer */ cert = d2i_X509 (NULL, (const unsigned char **) &ptr, _pCertLength); if (cert == NULL) { continue; } /*tls_dump_cert_info("ROOT", cert); */ if (!X509_STORE_add_cert (ctx->cert_store, cert)) { X509_free (cert); continue; } count++; X509_free (cert); status = SecKeychainItemFreeAttributesAndData (NULL, _pCertData); } } if (pSecKeychainItem != NULL) CFRelease (pSecKeychainItem); if (status != noErr) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "macosx certificate store: can't add certificate (%i)", status)); } } CFRelease (pSecKeychainSearch); CFRelease (pSecKeychain); #endif return count; }
null
0
_tls_add_certificates (SSL_CTX * ctx) { int count = 0; #ifdef HAVE_WINCRYPT_H PCCERT_CONTEXT pCertCtx; X509 *cert = NULL; HCERTSTORE hStore = CertOpenSystemStore (0, L"CA"); for (pCertCtx = CertEnumCertificatesInStore (hStore, NULL); pCertCtx != NULL; pCertCtx = CertEnumCertificatesInStore (hStore, pCertCtx)) { cert = d2i_X509 (NULL, (const unsigned char **) &pCertCtx->pbCertEncoded, pCertCtx->cbCertEncoded); if (cert == NULL) { continue; } /*tls_dump_cert_info("CA", cert); */ if (!X509_STORE_add_cert (ctx->cert_store, cert)) { X509_free (cert); continue; } count++; X509_free (cert); } CertCloseStore (hStore, 0); hStore = CertOpenSystemStore (0, L"ROOT"); for (pCertCtx = CertEnumCertificatesInStore (hStore, NULL); pCertCtx != NULL; pCertCtx = CertEnumCertificatesInStore (hStore, pCertCtx)) { cert = d2i_X509 (NULL, (const unsigned char **) &pCertCtx->pbCertEncoded, pCertCtx->cbCertEncoded); if (cert == NULL) { continue; } /*tls_dump_cert_info("ROOT", cert); */ if (!X509_STORE_add_cert (ctx->cert_store, cert)) { X509_free (cert); continue; } count++; X509_free (cert); } CertCloseStore (hStore, 0); hStore = CertOpenSystemStore (0, L"MY"); for (pCertCtx = CertEnumCertificatesInStore (hStore, NULL); pCertCtx != NULL; pCertCtx = CertEnumCertificatesInStore (hStore, pCertCtx)) { cert = d2i_X509 (NULL, (const unsigned char **) &pCertCtx->pbCertEncoded, pCertCtx->cbCertEncoded); if (cert == NULL) { continue; } /*tls_dump_cert_info("MY", cert); */ if (!X509_STORE_add_cert (ctx->cert_store, cert)) { X509_free (cert); continue; } count++; X509_free (cert); } CertCloseStore (hStore, 0); hStore = CertOpenSystemStore (0, L"Trustedpublisher"); for (pCertCtx = CertEnumCertificatesInStore (hStore, NULL); pCertCtx != NULL; pCertCtx = CertEnumCertificatesInStore (hStore, pCertCtx)) { cert = d2i_X509 (NULL, (const unsigned char **) &pCertCtx->pbCertEncoded, pCertCtx->cbCertEncoded); if (cert == NULL) { continue; } /*tls_dump_cert_info("Trustedpublisher", cert); */ if (!X509_STORE_add_cert (ctx->cert_store, cert)) { X509_free (cert); continue; } count++; X509_free (cert); } CertCloseStore (hStore, 0); #elif defined(__APPLE__) && (TARGET_OS_IPHONE==0) SecKeychainSearchRef pSecKeychainSearch = NULL; SecKeychainRef pSecKeychain; OSStatus status = noErr; X509 *cert = NULL; SInt32 osx_version = 0; if (Gestalt (gestaltSystemVersion, &osx_version) != noErr) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "macosx certificate store: can't get osx version")); return 0; } if (osx_version >= 0x1050) { /* Leopard store location */ status = SecKeychainOpen ("/System/Library/Keychains/SystemRootCertificates.keychain", &pSecKeychain); } else { /* Tiger and below store location */ status = SecKeychainOpen ("/System/Library/Keychains/X509Anchors", &pSecKeychain); } if (status != noErr) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "macosx certificate store: can't get osx version")); return 0; } status = SecKeychainSearchCreateFromAttributes (pSecKeychain, kSecCertificateItemClass, NULL, &pSecKeychainSearch); for (;;) { SecKeychainItemRef pSecKeychainItem = nil; status = SecKeychainSearchCopyNext (pSecKeychainSearch, &pSecKeychainItem); if (status == errSecItemNotFound) { break; } if (status == noErr) { void *_pCertData; UInt32 _pCertLength; status = SecKeychainItemCopyAttributesAndData (pSecKeychainItem, NULL, NULL, NULL, &_pCertLength, &_pCertData); if (status == noErr && _pCertData != NULL) { unsigned char *ptr; ptr = _pCertData; /*required because d2i_X509 is modifying pointer */ cert = d2i_X509 (NULL, (const unsigned char **) &ptr, _pCertLength); if (cert == NULL) { continue; } /*tls_dump_cert_info("ROOT", cert); */ if (!X509_STORE_add_cert (ctx->cert_store, cert)) { X509_free (cert); continue; } count++; X509_free (cert); status = SecKeychainItemFreeAttributesAndData (NULL, _pCertData); } } if (pSecKeychainItem != NULL) CFRelease (pSecKeychainItem); if (status != noErr) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "macosx certificate store: can't add certificate (%i)", status)); } } CFRelease (pSecKeychainSearch); CFRelease (pSecKeychain); #endif return count; }
@@ -1971,7 +1971,8 @@ handle_messages (struct eXosip_t *excontext, struct _tls_stream *sockinfo) OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL, "socket %s:%i: message has no content-length: <%s>\n", sockinfo->remote_ip, sockinfo->remote_port, buf)); } clen = clen_header ? atoi (clen_header) : 0; - + if (clen<0) + return sockinfo->buflen; /* discard data */ /* undo our overwrite and advance end_headers */ *end_headers = END_HEADERS_STR[0]; end_headers += const_strlen (END_HEADERS_STR); @@ -2789,7 +2790,8 @@ tls_tl_send_message (struct eXosip_t *excontext, osip_transaction_t * tr, osip_m OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL, "reusing REQUEST connection (to dest=%s:%i)\n", reserved->socket_tab[pos].remote_ip, reserved->socket_tab[pos].remote_port)); if (MSG_IS_REGISTER (sip) && atoi(sip->cseq->number)!=1) { } else { - _tls_tl_update_local_target_use_ephemeral_port (excontext, sip, reserved->socket_tab[pos].ephemeral_port); + if (excontext->use_ephemeral_port==1) + _tls_tl_update_local_target_use_ephemeral_port (excontext, sip, reserved->socket_tab[pos].ephemeral_port); } if (excontext->tls_firewall_ip[0] != '\0' || excontext->auto_masquerade_contact > 0) _tls_tl_update_local_target (excontext, sip, reserved->socket_tab[pos].natted_ip, reserved->socket_tab[pos].natted_port); @@ -2832,7 +2834,8 @@ tls_tl_send_message (struct eXosip_t *excontext, osip_transaction_t * tr, osip_m ssl = reserved->socket_tab[pos].ssl_conn; if (MSG_IS_REGISTER (sip) && atoi(sip->cseq->number)!=1) { } else { - _tls_tl_update_local_target_use_ephemeral_port (excontext, sip, reserved->socket_tab[pos].ephemeral_port); + if (excontext->use_ephemeral_port==1) + _tls_tl_update_local_target_use_ephemeral_port (excontext, sip, reserved->socket_tab[pos].ephemeral_port); } if (excontext->tls_firewall_ip[0] != '\0' || excontext->auto_masquerade_contact > 0) _tls_tl_update_local_target (excontext, sip, reserved->socket_tab[pos].natted_ip, reserved->socket_tab[pos].natted_port);
CWE-189
null
null
13,861
_tls_set_certificate (SSL_CTX * ctx, const char *cn) { #ifdef HAVE_WINCRYPT_H PCCERT_CONTEXT pCertCtx; X509 *cert = NULL; HCERTSTORE hStore = CertOpenSystemStore (0, L"CA"); for (pCertCtx = CertEnumCertificatesInStore (hStore, NULL); pCertCtx != NULL; pCertCtx = CertEnumCertificatesInStore (hStore, pCertCtx)) { char peer_CN[65]; cert = d2i_X509 (NULL, (const unsigned char **) &pCertCtx->pbCertEncoded, pCertCtx->cbCertEncoded); if (cert == NULL) { continue; } memset (peer_CN, 0, sizeof (peer_CN)); X509_NAME_get_text_by_NID (X509_get_subject_name (cert), NID_commonName, peer_CN, sizeof (peer_CN)); if (osip_strcasecmp (cn, peer_CN) == 0) { break; } X509_free (cert); cert = NULL; } CertCloseStore (hStore, 0); if (cert == NULL) { hStore = CertOpenSystemStore (0, L"ROOT"); for (pCertCtx = CertEnumCertificatesInStore (hStore, NULL); pCertCtx != NULL; pCertCtx = CertEnumCertificatesInStore (hStore, pCertCtx)) { char peer_CN[65]; cert = d2i_X509 (NULL, (const unsigned char **) &pCertCtx->pbCertEncoded, pCertCtx->cbCertEncoded); if (cert == NULL) { continue; } memset (peer_CN, 0, sizeof (peer_CN)); X509_NAME_get_text_by_NID (X509_get_subject_name (cert), NID_commonName, peer_CN, sizeof (peer_CN)); if (osip_strcasecmp (cn, peer_CN) == 0) { break; } X509_free (cert); cert = NULL; } CertCloseStore (hStore, 0); } if (cert == NULL) { hStore = CertOpenSystemStore (0, L"MY"); for (pCertCtx = CertEnumCertificatesInStore (hStore, NULL); pCertCtx != NULL; pCertCtx = CertEnumCertificatesInStore (hStore, pCertCtx)) { char peer_CN[65]; cert = d2i_X509 (NULL, (const unsigned char **) &pCertCtx->pbCertEncoded, pCertCtx->cbCertEncoded); if (cert == NULL) { continue; } memset (peer_CN, 0, sizeof (peer_CN)); X509_NAME_get_text_by_NID (X509_get_subject_name (cert), NID_commonName, peer_CN, sizeof (peer_CN)); if (osip_strcasecmp (cn, peer_CN) == 0) { break; } X509_free (cert); cert = NULL; } CertCloseStore (hStore, 0); } if (cert == NULL) { hStore = CertOpenSystemStore (0, L"Trustedpublisher"); for (pCertCtx = CertEnumCertificatesInStore (hStore, NULL); pCertCtx != NULL; pCertCtx = CertEnumCertificatesInStore (hStore, pCertCtx)) { char peer_CN[65]; cert = d2i_X509 (NULL, (const unsigned char **) &pCertCtx->pbCertEncoded, pCertCtx->cbCertEncoded); if (cert == NULL) { continue; } memset (peer_CN, 0, sizeof (peer_CN)); X509_NAME_get_text_by_NID (X509_get_subject_name (cert), NID_commonName, peer_CN, sizeof (peer_CN)); if (osip_strcasecmp (cn, peer_CN) == 0) { break; } X509_free (cert); cert = NULL; } CertCloseStore (hStore, 0); } if (cert == NULL) return NULL; { RSA *rsa = NULL, *pub_rsa; struct rsa_ctx *priv; RSA_METHOD *rsa_meth; priv = osip_malloc (sizeof (*priv)); rsa_meth = osip_malloc (sizeof (*rsa_meth)); if (priv == NULL || rsa_meth == NULL) { CertFreeCertificateContext (pCertCtx); osip_free (priv); osip_free (rsa_meth); X509_free (cert); return NULL; } memset (priv, 0, sizeof (*priv)); memset (rsa_meth, 0, sizeof (*rsa_meth)); priv->cert = pCertCtx; if (CryptAcquireCertificatePrivateKey (pCertCtx, CRYPT_ACQUIRE_COMPARE_KEY_FLAG, NULL, &priv->crypt_prov, &priv->key_spec, &priv->free_crypt_prov) == 0) { CertFreeCertificateContext (priv->cert); osip_free (priv); osip_free (rsa_meth); X509_free (cert); return NULL; } if (!CryptGetUserKey (priv->crypt_prov, priv->key_spec, &priv->hCryptKey)) { CertFreeCertificateContext (priv->cert); if (priv->crypt_prov && priv->free_crypt_prov) CryptReleaseContext (priv->crypt_prov, 0); osip_free (priv); osip_free (rsa_meth); X509_free (cert); return NULL; } rsa_meth->name = "Microsoft CryptoAPI RSA Method"; rsa_meth->rsa_pub_enc = rsa_pub_enc; rsa_meth->rsa_pub_dec = rsa_pub_dec; rsa_meth->rsa_priv_enc = rsa_priv_enc; rsa_meth->rsa_priv_dec = rsa_priv_dec; rsa_meth->finish = rsa_finish; rsa_meth->flags = RSA_METHOD_FLAG_NO_CHECK; rsa_meth->app_data = (char *) priv; rsa = RSA_new (); if (rsa == NULL) { CertFreeCertificateContext (priv->cert); if (priv->crypt_prov && priv->free_crypt_prov) CryptReleaseContext (priv->crypt_prov, 0); osip_free (priv); osip_free (rsa_meth); X509_free (cert); RSA_free (rsa); return NULL; } if (!SSL_CTX_use_certificate (ctx, cert)) { CertFreeCertificateContext (priv->cert); if (priv->crypt_prov && priv->free_crypt_prov) CryptReleaseContext (priv->crypt_prov, 0); osip_free (priv); osip_free (rsa_meth); X509_free (cert); return NULL; } pub_rsa = cert->cert_info->key->pkey->pkey.rsa; rsa->n = BN_dup (pub_rsa->n); rsa->e = BN_dup (pub_rsa->e); if (!RSA_set_method (rsa, rsa_meth)) { CertFreeCertificateContext (priv->cert); if (priv->crypt_prov && priv->free_crypt_prov) CryptReleaseContext (priv->crypt_prov, 0); osip_free (priv); osip_free (rsa_meth); RSA_free (rsa); X509_free (cert); SSL_CTX_free (ctx); return NULL; } if (!SSL_CTX_use_RSAPrivateKey (ctx, rsa)) { RSA_free (rsa); X509_free (cert); SSL_CTX_free (ctx); return NULL; } RSA_free (rsa); return cert; } #endif return NULL; }
null
0
_tls_set_certificate (SSL_CTX * ctx, const char *cn) { #ifdef HAVE_WINCRYPT_H PCCERT_CONTEXT pCertCtx; X509 *cert = NULL; HCERTSTORE hStore = CertOpenSystemStore (0, L"CA"); for (pCertCtx = CertEnumCertificatesInStore (hStore, NULL); pCertCtx != NULL; pCertCtx = CertEnumCertificatesInStore (hStore, pCertCtx)) { char peer_CN[65]; cert = d2i_X509 (NULL, (const unsigned char **) &pCertCtx->pbCertEncoded, pCertCtx->cbCertEncoded); if (cert == NULL) { continue; } memset (peer_CN, 0, sizeof (peer_CN)); X509_NAME_get_text_by_NID (X509_get_subject_name (cert), NID_commonName, peer_CN, sizeof (peer_CN)); if (osip_strcasecmp (cn, peer_CN) == 0) { break; } X509_free (cert); cert = NULL; } CertCloseStore (hStore, 0); if (cert == NULL) { hStore = CertOpenSystemStore (0, L"ROOT"); for (pCertCtx = CertEnumCertificatesInStore (hStore, NULL); pCertCtx != NULL; pCertCtx = CertEnumCertificatesInStore (hStore, pCertCtx)) { char peer_CN[65]; cert = d2i_X509 (NULL, (const unsigned char **) &pCertCtx->pbCertEncoded, pCertCtx->cbCertEncoded); if (cert == NULL) { continue; } memset (peer_CN, 0, sizeof (peer_CN)); X509_NAME_get_text_by_NID (X509_get_subject_name (cert), NID_commonName, peer_CN, sizeof (peer_CN)); if (osip_strcasecmp (cn, peer_CN) == 0) { break; } X509_free (cert); cert = NULL; } CertCloseStore (hStore, 0); } if (cert == NULL) { hStore = CertOpenSystemStore (0, L"MY"); for (pCertCtx = CertEnumCertificatesInStore (hStore, NULL); pCertCtx != NULL; pCertCtx = CertEnumCertificatesInStore (hStore, pCertCtx)) { char peer_CN[65]; cert = d2i_X509 (NULL, (const unsigned char **) &pCertCtx->pbCertEncoded, pCertCtx->cbCertEncoded); if (cert == NULL) { continue; } memset (peer_CN, 0, sizeof (peer_CN)); X509_NAME_get_text_by_NID (X509_get_subject_name (cert), NID_commonName, peer_CN, sizeof (peer_CN)); if (osip_strcasecmp (cn, peer_CN) == 0) { break; } X509_free (cert); cert = NULL; } CertCloseStore (hStore, 0); } if (cert == NULL) { hStore = CertOpenSystemStore (0, L"Trustedpublisher"); for (pCertCtx = CertEnumCertificatesInStore (hStore, NULL); pCertCtx != NULL; pCertCtx = CertEnumCertificatesInStore (hStore, pCertCtx)) { char peer_CN[65]; cert = d2i_X509 (NULL, (const unsigned char **) &pCertCtx->pbCertEncoded, pCertCtx->cbCertEncoded); if (cert == NULL) { continue; } memset (peer_CN, 0, sizeof (peer_CN)); X509_NAME_get_text_by_NID (X509_get_subject_name (cert), NID_commonName, peer_CN, sizeof (peer_CN)); if (osip_strcasecmp (cn, peer_CN) == 0) { break; } X509_free (cert); cert = NULL; } CertCloseStore (hStore, 0); } if (cert == NULL) return NULL; { RSA *rsa = NULL, *pub_rsa; struct rsa_ctx *priv; RSA_METHOD *rsa_meth; priv = osip_malloc (sizeof (*priv)); rsa_meth = osip_malloc (sizeof (*rsa_meth)); if (priv == NULL || rsa_meth == NULL) { CertFreeCertificateContext (pCertCtx); osip_free (priv); osip_free (rsa_meth); X509_free (cert); return NULL; } memset (priv, 0, sizeof (*priv)); memset (rsa_meth, 0, sizeof (*rsa_meth)); priv->cert = pCertCtx; if (CryptAcquireCertificatePrivateKey (pCertCtx, CRYPT_ACQUIRE_COMPARE_KEY_FLAG, NULL, &priv->crypt_prov, &priv->key_spec, &priv->free_crypt_prov) == 0) { CertFreeCertificateContext (priv->cert); osip_free (priv); osip_free (rsa_meth); X509_free (cert); return NULL; } if (!CryptGetUserKey (priv->crypt_prov, priv->key_spec, &priv->hCryptKey)) { CertFreeCertificateContext (priv->cert); if (priv->crypt_prov && priv->free_crypt_prov) CryptReleaseContext (priv->crypt_prov, 0); osip_free (priv); osip_free (rsa_meth); X509_free (cert); return NULL; } rsa_meth->name = "Microsoft CryptoAPI RSA Method"; rsa_meth->rsa_pub_enc = rsa_pub_enc; rsa_meth->rsa_pub_dec = rsa_pub_dec; rsa_meth->rsa_priv_enc = rsa_priv_enc; rsa_meth->rsa_priv_dec = rsa_priv_dec; rsa_meth->finish = rsa_finish; rsa_meth->flags = RSA_METHOD_FLAG_NO_CHECK; rsa_meth->app_data = (char *) priv; rsa = RSA_new (); if (rsa == NULL) { CertFreeCertificateContext (priv->cert); if (priv->crypt_prov && priv->free_crypt_prov) CryptReleaseContext (priv->crypt_prov, 0); osip_free (priv); osip_free (rsa_meth); X509_free (cert); RSA_free (rsa); return NULL; } if (!SSL_CTX_use_certificate (ctx, cert)) { CertFreeCertificateContext (priv->cert); if (priv->crypt_prov && priv->free_crypt_prov) CryptReleaseContext (priv->crypt_prov, 0); osip_free (priv); osip_free (rsa_meth); X509_free (cert); return NULL; } pub_rsa = cert->cert_info->key->pkey->pkey.rsa; rsa->n = BN_dup (pub_rsa->n); rsa->e = BN_dup (pub_rsa->e); if (!RSA_set_method (rsa, rsa_meth)) { CertFreeCertificateContext (priv->cert); if (priv->crypt_prov && priv->free_crypt_prov) CryptReleaseContext (priv->crypt_prov, 0); osip_free (priv); osip_free (rsa_meth); RSA_free (rsa); X509_free (cert); SSL_CTX_free (ctx); return NULL; } if (!SSL_CTX_use_RSAPrivateKey (ctx, rsa)) { RSA_free (rsa); X509_free (cert); SSL_CTX_free (ctx); return NULL; } RSA_free (rsa); return cert; } #endif return NULL; }
@@ -1971,7 +1971,8 @@ handle_messages (struct eXosip_t *excontext, struct _tls_stream *sockinfo) OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL, "socket %s:%i: message has no content-length: <%s>\n", sockinfo->remote_ip, sockinfo->remote_port, buf)); } clen = clen_header ? atoi (clen_header) : 0; - + if (clen<0) + return sockinfo->buflen; /* discard data */ /* undo our overwrite and advance end_headers */ *end_headers = END_HEADERS_STR[0]; end_headers += const_strlen (END_HEADERS_STR); @@ -2789,7 +2790,8 @@ tls_tl_send_message (struct eXosip_t *excontext, osip_transaction_t * tr, osip_m OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL, "reusing REQUEST connection (to dest=%s:%i)\n", reserved->socket_tab[pos].remote_ip, reserved->socket_tab[pos].remote_port)); if (MSG_IS_REGISTER (sip) && atoi(sip->cseq->number)!=1) { } else { - _tls_tl_update_local_target_use_ephemeral_port (excontext, sip, reserved->socket_tab[pos].ephemeral_port); + if (excontext->use_ephemeral_port==1) + _tls_tl_update_local_target_use_ephemeral_port (excontext, sip, reserved->socket_tab[pos].ephemeral_port); } if (excontext->tls_firewall_ip[0] != '\0' || excontext->auto_masquerade_contact > 0) _tls_tl_update_local_target (excontext, sip, reserved->socket_tab[pos].natted_ip, reserved->socket_tab[pos].natted_port); @@ -2832,7 +2834,8 @@ tls_tl_send_message (struct eXosip_t *excontext, osip_transaction_t * tr, osip_m ssl = reserved->socket_tab[pos].ssl_conn; if (MSG_IS_REGISTER (sip) && atoi(sip->cseq->number)!=1) { } else { - _tls_tl_update_local_target_use_ephemeral_port (excontext, sip, reserved->socket_tab[pos].ephemeral_port); + if (excontext->use_ephemeral_port==1) + _tls_tl_update_local_target_use_ephemeral_port (excontext, sip, reserved->socket_tab[pos].ephemeral_port); } if (excontext->tls_firewall_ip[0] != '\0' || excontext->auto_masquerade_contact > 0) _tls_tl_update_local_target (excontext, sip, reserved->socket_tab[pos].natted_ip, reserved->socket_tab[pos].natted_port);
CWE-189
null
null
13,862
_tls_tl_close_sockinfo (struct _tls_stream *sockinfo) { if (sockinfo->socket > 0) { if (sockinfo->ssl_conn != NULL) { SSL_shutdown (sockinfo->ssl_conn); SSL_shutdown (sockinfo->ssl_conn); SSL_free (sockinfo->ssl_conn); } if (sockinfo->ssl_ctx != NULL) SSL_CTX_free (sockinfo->ssl_ctx); closesocket (sockinfo->socket); } if (sockinfo->buf != NULL) osip_free (sockinfo->buf); if (sockinfo->sendbuf != NULL) osip_free (sockinfo->sendbuf); #ifdef MULTITASKING_ENABLED if (sockinfo->readStream != NULL) { CFReadStreamClose (sockinfo->readStream); CFRelease (sockinfo->readStream); } if (sockinfo->writeStream != NULL) { CFWriteStreamClose (sockinfo->writeStream); CFRelease (sockinfo->writeStream); } #endif memset (sockinfo, 0, sizeof (*sockinfo)); }
null
0
_tls_tl_close_sockinfo (struct _tls_stream *sockinfo) { if (sockinfo->socket > 0) { if (sockinfo->ssl_conn != NULL) { SSL_shutdown (sockinfo->ssl_conn); SSL_shutdown (sockinfo->ssl_conn); SSL_free (sockinfo->ssl_conn); } if (sockinfo->ssl_ctx != NULL) SSL_CTX_free (sockinfo->ssl_ctx); closesocket (sockinfo->socket); } if (sockinfo->buf != NULL) osip_free (sockinfo->buf); if (sockinfo->sendbuf != NULL) osip_free (sockinfo->sendbuf); #ifdef MULTITASKING_ENABLED if (sockinfo->readStream != NULL) { CFReadStreamClose (sockinfo->readStream); CFRelease (sockinfo->readStream); } if (sockinfo->writeStream != NULL) { CFWriteStreamClose (sockinfo->writeStream); CFRelease (sockinfo->writeStream); } #endif memset (sockinfo, 0, sizeof (*sockinfo)); }
@@ -1971,7 +1971,8 @@ handle_messages (struct eXosip_t *excontext, struct _tls_stream *sockinfo) OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL, "socket %s:%i: message has no content-length: <%s>\n", sockinfo->remote_ip, sockinfo->remote_port, buf)); } clen = clen_header ? atoi (clen_header) : 0; - + if (clen<0) + return sockinfo->buflen; /* discard data */ /* undo our overwrite and advance end_headers */ *end_headers = END_HEADERS_STR[0]; end_headers += const_strlen (END_HEADERS_STR); @@ -2789,7 +2790,8 @@ tls_tl_send_message (struct eXosip_t *excontext, osip_transaction_t * tr, osip_m OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL, "reusing REQUEST connection (to dest=%s:%i)\n", reserved->socket_tab[pos].remote_ip, reserved->socket_tab[pos].remote_port)); if (MSG_IS_REGISTER (sip) && atoi(sip->cseq->number)!=1) { } else { - _tls_tl_update_local_target_use_ephemeral_port (excontext, sip, reserved->socket_tab[pos].ephemeral_port); + if (excontext->use_ephemeral_port==1) + _tls_tl_update_local_target_use_ephemeral_port (excontext, sip, reserved->socket_tab[pos].ephemeral_port); } if (excontext->tls_firewall_ip[0] != '\0' || excontext->auto_masquerade_contact > 0) _tls_tl_update_local_target (excontext, sip, reserved->socket_tab[pos].natted_ip, reserved->socket_tab[pos].natted_port); @@ -2832,7 +2834,8 @@ tls_tl_send_message (struct eXosip_t *excontext, osip_transaction_t * tr, osip_m ssl = reserved->socket_tab[pos].ssl_conn; if (MSG_IS_REGISTER (sip) && atoi(sip->cseq->number)!=1) { } else { - _tls_tl_update_local_target_use_ephemeral_port (excontext, sip, reserved->socket_tab[pos].ephemeral_port); + if (excontext->use_ephemeral_port==1) + _tls_tl_update_local_target_use_ephemeral_port (excontext, sip, reserved->socket_tab[pos].ephemeral_port); } if (excontext->tls_firewall_ip[0] != '\0' || excontext->auto_masquerade_contact > 0) _tls_tl_update_local_target (excontext, sip, reserved->socket_tab[pos].natted_ip, reserved->socket_tab[pos].natted_port);
CWE-189
null
null
13,863
static uint64_t get_free_space_available(const char *path) { struct statvfs stat; if (statvfs(path, &stat) != 0) { syslog(LOG_WARNING, "file-xfer: failed to get free space, statvfs error: %s", strerror(errno)); return G_MAXUINT64; } return stat.f_bsize * stat.f_bavail; }
Exec Code
0
static uint64_t get_free_space_available(const char *path) { struct statvfs stat; if (statvfs(path, &stat) != 0) { syslog(LOG_WARNING, "file-xfer: failed to get free space, statvfs error: %s", strerror(errno)); return G_MAXUINT64; } return stat.f_bsize * stat.f_bavail; }
@@ -336,9 +336,16 @@ void vdagent_file_xfers_data(struct vdagent_file_xfers *xfers, if (xfers->open_save_dir && task->file_xfer_nr == task->file_xfer_total && g_hash_table_size(xfers->xfers) == 1) { - char buf[PATH_MAX]; - snprintf(buf, PATH_MAX, "xdg-open '%s'&", xfers->save_dir); - status = system(buf); + GError *error = NULL; + gchar *argv[] = { "xdg-open", xfers->save_dir, NULL }; + if (!g_spawn_async(NULL, argv, NULL, + G_SPAWN_SEARCH_PATH, + NULL, NULL, NULL, &error)) { + syslog(LOG_WARNING, + "file-xfer: failed to open save directory: %s", + error->message); + g_error_free(error); + } } status = VD_AGENT_FILE_XFER_STATUS_SUCCESS; } else {
CWE-78
null
null
13,864
static void vdagent_file_xfer_task_free(gpointer data) { AgentFileXferTask *task = data; g_return_if_fail(task != NULL); if (task->file_fd > 0) { syslog(LOG_ERR, "file-xfer: Removing task %u and file %s due to error", task->id, task->file_name); close(task->file_fd); unlink(task->file_name); } else if (task->debug) syslog(LOG_DEBUG, "file-xfer: Removing task %u %s", task->id, task->file_name); g_free(task->file_name); g_free(task); }
Exec Code
0
static void vdagent_file_xfer_task_free(gpointer data) { AgentFileXferTask *task = data; g_return_if_fail(task != NULL); if (task->file_fd > 0) { syslog(LOG_ERR, "file-xfer: Removing task %u and file %s due to error", task->id, task->file_name); close(task->file_fd); unlink(task->file_name); } else if (task->debug) syslog(LOG_DEBUG, "file-xfer: Removing task %u %s", task->id, task->file_name); g_free(task->file_name); g_free(task); }
@@ -336,9 +336,16 @@ void vdagent_file_xfers_data(struct vdagent_file_xfers *xfers, if (xfers->open_save_dir && task->file_xfer_nr == task->file_xfer_total && g_hash_table_size(xfers->xfers) == 1) { - char buf[PATH_MAX]; - snprintf(buf, PATH_MAX, "xdg-open '%s'&", xfers->save_dir); - status = system(buf); + GError *error = NULL; + gchar *argv[] = { "xdg-open", xfers->save_dir, NULL }; + if (!g_spawn_async(NULL, argv, NULL, + G_SPAWN_SEARCH_PATH, + NULL, NULL, NULL, &error)) { + syslog(LOG_WARNING, + "file-xfer: failed to open save directory: %s", + error->message); + g_error_free(error); + } } status = VD_AGENT_FILE_XFER_STATUS_SUCCESS; } else {
CWE-78
null
null
13,865
struct vdagent_file_xfers *vdagent_file_xfers_create( struct udscs_connection *vdagentd, const char *save_dir, int open_save_dir, int debug) { struct vdagent_file_xfers *xfers; xfers = g_malloc(sizeof(*xfers)); xfers->xfers = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, vdagent_file_xfer_task_free); xfers->vdagentd = vdagentd; xfers->save_dir = g_strdup(save_dir); xfers->open_save_dir = open_save_dir; xfers->debug = debug; return xfers; }
Exec Code
0
struct vdagent_file_xfers *vdagent_file_xfers_create( struct udscs_connection *vdagentd, const char *save_dir, int open_save_dir, int debug) { struct vdagent_file_xfers *xfers; xfers = g_malloc(sizeof(*xfers)); xfers->xfers = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, vdagent_file_xfer_task_free); xfers->vdagentd = vdagentd; xfers->save_dir = g_strdup(save_dir); xfers->open_save_dir = open_save_dir; xfers->debug = debug; return xfers; }
@@ -336,9 +336,16 @@ void vdagent_file_xfers_data(struct vdagent_file_xfers *xfers, if (xfers->open_save_dir && task->file_xfer_nr == task->file_xfer_total && g_hash_table_size(xfers->xfers) == 1) { - char buf[PATH_MAX]; - snprintf(buf, PATH_MAX, "xdg-open '%s'&", xfers->save_dir); - status = system(buf); + GError *error = NULL; + gchar *argv[] = { "xdg-open", xfers->save_dir, NULL }; + if (!g_spawn_async(NULL, argv, NULL, + G_SPAWN_SEARCH_PATH, + NULL, NULL, NULL, &error)) { + syslog(LOG_WARNING, + "file-xfer: failed to open save directory: %s", + error->message); + g_error_free(error); + } } status = VD_AGENT_FILE_XFER_STATUS_SUCCESS; } else {
CWE-78
null
null
13,866
internal_warning (const char *format, ...) #else internal_warning (format, va_alist) const char *format; va_dcl #endif { va_list args; error_prolog (1); fprintf (stderr, _("warning: ")); SH_VA_START (args, format); vfprintf (stderr, format, args); fprintf (stderr, "\n"); va_end (args); }
Exec Code Overflow
0
internal_warning (const char *format, ...) #else internal_warning (format, va_alist) const char *format; va_dcl #endif { va_list args; error_prolog (1); fprintf (stderr, _("warning: ")); SH_VA_START (args, format); vfprintf (stderr, format, args); fprintf (stderr, "\n"); va_end (args); }
@@ -200,7 +200,11 @@ report_error (format, va_alist) va_end (args); if (exit_immediately_on_error) - exit_shell (1); + { + if (last_command_exit_value == 0) + last_command_exit_value = 1; + exit_shell (last_command_exit_value); + } } void
CWE-119
null
null
13,867
itrace (const char *format, ...) #else itrace (format, va_alist) const char *format; va_dcl #endif { va_list args; fprintf(stderr, "TRACE: pid %ld: ", (long)getpid()); SH_VA_START (args, format); vfprintf (stderr, format, args); fprintf (stderr, "\n"); va_end (args); fflush(stderr); }
Exec Code Overflow
0
itrace (const char *format, ...) #else itrace (format, va_alist) const char *format; va_dcl #endif { va_list args; fprintf(stderr, "TRACE: pid %ld: ", (long)getpid()); SH_VA_START (args, format); vfprintf (stderr, format, args); fprintf (stderr, "\n"); va_end (args); fflush(stderr); }
@@ -200,7 +200,11 @@ report_error (format, va_alist) va_end (args); if (exit_immediately_on_error) - exit_shell (1); + { + if (last_command_exit_value == 0) + last_command_exit_value = 1; + exit_shell (last_command_exit_value); + } } void
CWE-119
null
null
13,868
parser_error (int lineno, const char *format, ...) #else parser_error (lineno, format, va_alist) int lineno; const char *format; va_dcl #endif { va_list args; char *ename, *iname; ename = get_name_for_error (); iname = yy_input_name (); if (interactive) fprintf (stderr, "%s: ", ename); else if (interactive_shell) fprintf (stderr, "%s: %s:%s%d: ", ename, iname, gnu_error_format ? "" : _(" line "), lineno); else if (STREQ (ename, iname)) fprintf (stderr, "%s:%s%d: ", ename, gnu_error_format ? "" : _(" line "), lineno); else fprintf (stderr, "%s: %s:%s%d: ", ename, iname, gnu_error_format ? "" : _(" line "), lineno); SH_VA_START (args, format); vfprintf (stderr, format, args); fprintf (stderr, "\n"); va_end (args); if (exit_immediately_on_error) exit_shell (last_command_exit_value = 2); }
Exec Code Overflow
0
parser_error (int lineno, const char *format, ...) #else parser_error (lineno, format, va_alist) int lineno; const char *format; va_dcl #endif { va_list args; char *ename, *iname; ename = get_name_for_error (); iname = yy_input_name (); if (interactive) fprintf (stderr, "%s: ", ename); else if (interactive_shell) fprintf (stderr, "%s: %s:%s%d: ", ename, iname, gnu_error_format ? "" : _(" line "), lineno); else if (STREQ (ename, iname)) fprintf (stderr, "%s:%s%d: ", ename, gnu_error_format ? "" : _(" line "), lineno); else fprintf (stderr, "%s: %s:%s%d: ", ename, iname, gnu_error_format ? "" : _(" line "), lineno); SH_VA_START (args, format); vfprintf (stderr, format, args); fprintf (stderr, "\n"); va_end (args); if (exit_immediately_on_error) exit_shell (last_command_exit_value = 2); }
@@ -200,7 +200,11 @@ report_error (format, va_alist) va_end (args); if (exit_immediately_on_error) - exit_shell (1); + { + if (last_command_exit_value == 0) + last_command_exit_value = 1; + exit_shell (last_command_exit_value); + } } void
CWE-119
null
null
13,869
programming_error (const char *format, ...) #else programming_error (format, va_alist) const char *format; va_dcl #endif { va_list args; char *h; #if defined (JOB_CONTROL) give_terminal_to (shell_pgrp, 0); #endif /* JOB_CONTROL */ SH_VA_START (args, format); vfprintf (stderr, format, args); fprintf (stderr, "\n"); va_end (args); #if defined (HISTORY) if (remember_on_history) { h = last_history_line (); fprintf (stderr, _("last command: %s\n"), h ? h : "(null)"); } #endif #if 0 fprintf (stderr, "Report this to %s\n", the_current_maintainer); #endif fprintf (stderr, _("Aborting...")); fflush (stderr); abort (); }
Exec Code Overflow
0
programming_error (const char *format, ...) #else programming_error (format, va_alist) const char *format; va_dcl #endif { va_list args; char *h; #if defined (JOB_CONTROL) give_terminal_to (shell_pgrp, 0); #endif /* JOB_CONTROL */ SH_VA_START (args, format); vfprintf (stderr, format, args); fprintf (stderr, "\n"); va_end (args); #if defined (HISTORY) if (remember_on_history) { h = last_history_line (); fprintf (stderr, _("last command: %s\n"), h ? h : "(null)"); } #endif #if 0 fprintf (stderr, "Report this to %s\n", the_current_maintainer); #endif fprintf (stderr, _("Aborting...")); fflush (stderr); abort (); }
@@ -200,7 +200,11 @@ report_error (format, va_alist) va_end (args); if (exit_immediately_on_error) - exit_shell (1); + { + if (last_command_exit_value == 0) + last_command_exit_value = 1; + exit_shell (last_command_exit_value); + } } void
CWE-119
null
null
13,870
sys_error (const char *format, ...) #else sys_error (format, va_alist) const char *format; va_dcl #endif { int e; va_list args; e = errno; error_prolog (0); SH_VA_START (args, format); vfprintf (stderr, format, args); fprintf (stderr, ": %s\n", strerror (e)); va_end (args); }
Exec Code Overflow
0
sys_error (const char *format, ...) #else sys_error (format, va_alist) const char *format; va_dcl #endif { int e; va_list args; e = errno; error_prolog (0); SH_VA_START (args, format); vfprintf (stderr, format, args); fprintf (stderr, ": %s\n", strerror (e)); va_end (args); }
@@ -200,7 +200,11 @@ report_error (format, va_alist) va_end (args); if (exit_immediately_on_error) - exit_shell (1); + { + if (last_command_exit_value == 0) + last_command_exit_value = 1; + exit_shell (last_command_exit_value); + } } void
CWE-119
null
null
13,871
trace (const char *format, ...) #else trace (format, va_alist) const char *format; va_dcl #endif { va_list args; static FILE *tracefp = (FILE *)NULL; if (tracefp == NULL) tracefp = fopen("/tmp/bash-trace.log", "a+"); if (tracefp == NULL) tracefp = stderr; else fcntl (fileno (tracefp), F_SETFD, 1); /* close-on-exec */ fprintf(tracefp, "TRACE: pid %ld: ", (long)getpid()); SH_VA_START (args, format); vfprintf (tracefp, format, args); fprintf (tracefp, "\n"); va_end (args); fflush(tracefp); }
Exec Code Overflow
0
trace (const char *format, ...) #else trace (format, va_alist) const char *format; va_dcl #endif { va_list args; static FILE *tracefp = (FILE *)NULL; if (tracefp == NULL) tracefp = fopen("/tmp/bash-trace.log", "a+"); if (tracefp == NULL) tracefp = stderr; else fcntl (fileno (tracefp), F_SETFD, 1); /* close-on-exec */ fprintf(tracefp, "TRACE: pid %ld: ", (long)getpid()); SH_VA_START (args, format); vfprintf (tracefp, format, args); fprintf (tracefp, "\n"); va_end (args); fflush(tracefp); }
@@ -200,7 +200,11 @@ report_error (format, va_alist) va_end (args); if (exit_immediately_on_error) - exit_shell (1); + { + if (last_command_exit_value == 0) + last_command_exit_value = 1; + exit_shell (last_command_exit_value); + } } void
CWE-119
null
null
13,872
close_all_files () { register int i, fd_table_size; fd_table_size = getdtablesize (); if (fd_table_size > 256) /* clamp to a reasonable value */ fd_table_size = 256; for (i = 3; i < fd_table_size; i++) close (i); }
Exec Code Overflow
0
close_all_files () { register int i, fd_table_size; fd_table_size = getdtablesize (); if (fd_table_size > 256) /* clamp to a reasonable value */ fd_table_size = 256; for (i = 3; i < fd_table_size; i++) close (i); }
@@ -2370,7 +2370,9 @@ execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close) unfreeze_jobs_list (); } +#if defined (JOB_CONTROL) discard_unwind_frame ("lastpipe-exec"); +#endif return (exec_result); }
CWE-119
null
null
13,873
coproc_closeall () { #if MULTIPLE_COPROCS cpl_closeall (); #else coproc_close (&sh_coproc); /* XXX - will require changes for multiple coprocs */ #endif }
Exec Code Overflow
0
coproc_closeall () { #if MULTIPLE_COPROCS cpl_closeall (); #else coproc_close (&sh_coproc); /* XXX - will require changes for multiple coprocs */ #endif }
@@ -2370,7 +2370,9 @@ execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close) unfreeze_jobs_list (); } +#if defined (JOB_CONTROL) discard_unwind_frame ("lastpipe-exec"); +#endif return (exec_result); }
CWE-119
null
null
13,874
coproc_flush () { #if MULTIPLE_COPROCS cpl_flush (); #else coproc_dispose (&sh_coproc); #endif }
Exec Code Overflow
0
coproc_flush () { #if MULTIPLE_COPROCS cpl_flush (); #else coproc_dispose (&sh_coproc); #endif }
@@ -2370,7 +2370,9 @@ execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close) unfreeze_jobs_list (); } +#if defined (JOB_CONTROL) discard_unwind_frame ("lastpipe-exec"); +#endif return (exec_result); }
CWE-119
null
null
13,875
coproc_reap () { #if MULTIPLE_COPROCS cpl_reap (); #else struct coproc *cp; cp = &sh_coproc; /* XXX - will require changes for multiple coprocs */ if (cp && (cp->c_flags & COPROC_DEAD)) coproc_dispose (cp); #endif }
Exec Code Overflow
0
coproc_reap () { #if MULTIPLE_COPROCS cpl_reap (); #else struct coproc *cp; cp = &sh_coproc; /* XXX - will require changes for multiple coprocs */ if (cp && (cp->c_flags & COPROC_DEAD)) coproc_dispose (cp); #endif }
@@ -2370,7 +2370,9 @@ execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close) unfreeze_jobs_list (); } +#if defined (JOB_CONTROL) discard_unwind_frame ("lastpipe-exec"); +#endif return (exec_result); }
CWE-119
null
null
13,876
cpl_closeall () { struct cpelement *cpe; for (cpe = coproc_list.head; cpe; cpe = cpe->next) coproc_close (cpe->coproc); }
Exec Code Overflow
0
cpl_closeall () { struct cpelement *cpe; for (cpe = coproc_list.head; cpe; cpe = cpe->next) coproc_close (cpe->coproc); }
@@ -2370,7 +2370,9 @@ execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close) unfreeze_jobs_list (); } +#if defined (JOB_CONTROL) discard_unwind_frame ("lastpipe-exec"); +#endif return (exec_result); }
CWE-119
null
null
13,877
cpl_flush () { struct cpelement *cpe, *p; for (cpe = coproc_list.head; cpe; ) { p = cpe; cpe = cpe->next; coproc_dispose (p->coproc); cpe_dispose (p); } coproc_list.head = coproc_list.tail = 0; coproc_list.ncoproc = 0; }
Exec Code Overflow
0
cpl_flush () { struct cpelement *cpe, *p; for (cpe = coproc_list.head; cpe; ) { p = cpe; cpe = cpe->next; coproc_dispose (p->coproc); cpe_dispose (p); } coproc_list.head = coproc_list.tail = 0; coproc_list.ncoproc = 0; }
@@ -2370,7 +2370,9 @@ execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close) unfreeze_jobs_list (); } +#if defined (JOB_CONTROL) discard_unwind_frame ("lastpipe-exec"); +#endif return (exec_result); }
CWE-119
null
null
13,878
cpl_reap () { struct cpelement *p, *next, *nh, *nt; /* Build a new list by removing dead coprocs and fix up the coproc_list pointers when done. */ nh = nt = next = (struct cpelement *)0; for (p = coproc_list.head; p; p = next) { next = p->next; if (p->coproc->c_flags & COPROC_DEAD) { coproc_list.ncoproc--; /* keep running count, fix up pointers later */ #if defined (DEBUG) itrace("cpl_reap: deleting %d", p->coproc->c_pid); #endif coproc_dispose (p->coproc); cpe_dispose (p); } else if (nh == 0) nh = nt = p; else { nt->next = p; nt = nt->next; } } if (coproc_list.ncoproc == 0) coproc_list.head = coproc_list.tail = 0; else { if (nt) nt->next = 0; coproc_list.head = nh; coproc_list.tail = nt; if (coproc_list.ncoproc == 1) coproc_list.tail = coproc_list.head; /* just to make sure */ } }
Exec Code Overflow
0
cpl_reap () { struct cpelement *p, *next, *nh, *nt; /* Build a new list by removing dead coprocs and fix up the coproc_list pointers when done. */ nh = nt = next = (struct cpelement *)0; for (p = coproc_list.head; p; p = next) { next = p->next; if (p->coproc->c_flags & COPROC_DEAD) { coproc_list.ncoproc--; /* keep running count, fix up pointers later */ #if defined (DEBUG) itrace("cpl_reap: deleting %d", p->coproc->c_pid); #endif coproc_dispose (p->coproc); cpe_dispose (p); } else if (nh == 0) nh = nt = p; else { nt->next = p; nt = nt->next; } } if (coproc_list.ncoproc == 0) coproc_list.head = coproc_list.tail = 0; else { if (nt) nt->next = 0; coproc_list.head = nh; coproc_list.tail = nt; if (coproc_list.ncoproc == 1) coproc_list.tail = coproc_list.head; /* just to make sure */ } }
@@ -2370,7 +2370,9 @@ execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close) unfreeze_jobs_list (); } +#if defined (JOB_CONTROL) discard_unwind_frame ("lastpipe-exec"); +#endif return (exec_result); }
CWE-119
null
null
13,879
dispose_exec_redirects () { if (exec_redirection_undo_list) { dispose_redirects (exec_redirection_undo_list); exec_redirection_undo_list = (REDIRECT *)NULL; } }
Exec Code Overflow
0
dispose_exec_redirects () { if (exec_redirection_undo_list) { dispose_redirects (exec_redirection_undo_list); exec_redirection_undo_list = (REDIRECT *)NULL; } }
@@ -2370,7 +2370,9 @@ execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close) unfreeze_jobs_list (); } +#if defined (JOB_CONTROL) discard_unwind_frame ("lastpipe-exec"); +#endif return (exec_result); }
CWE-119
null
null
13,880
executing_line_number () { if (executing && showing_function_line == 0 && (variable_context == 0 || interactive_shell == 0) && currently_executing_command) { #if defined (COND_COMMAND) if (currently_executing_command->type == cm_cond) return currently_executing_command->value.Cond->line; #endif #if defined (DPAREN_ARITHMETIC) else if (currently_executing_command->type == cm_arith) return currently_executing_command->value.Arith->line; #endif #if defined (ARITH_FOR_COMMAND) else if (currently_executing_command->type == cm_arith_for) return currently_executing_command->value.ArithFor->line; #endif return line_number; } else return line_number; }
Exec Code Overflow
0
executing_line_number () { if (executing && showing_function_line == 0 && (variable_context == 0 || interactive_shell == 0) && currently_executing_command) { #if defined (COND_COMMAND) if (currently_executing_command->type == cm_cond) return currently_executing_command->value.Cond->line; #endif #if defined (DPAREN_ARITHMETIC) else if (currently_executing_command->type == cm_arith) return currently_executing_command->value.Arith->line; #endif #if defined (ARITH_FOR_COMMAND) else if (currently_executing_command->type == cm_arith_for) return currently_executing_command->value.ArithFor->line; #endif return line_number; } else return line_number; }
@@ -2370,7 +2370,9 @@ execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close) unfreeze_jobs_list (); } +#if defined (JOB_CONTROL) discard_unwind_frame ("lastpipe-exec"); +#endif return (exec_result); }
CWE-119
null
null
13,881
initialize_subshell () { #if defined (ALIAS) /* Forget about any aliases that we knew of. We are in a subshell. */ delete_all_aliases (); #endif /* ALIAS */ #if defined (HISTORY) /* Forget about the history lines we have read. This is a non-interactive subshell. */ history_lines_this_session = 0; #endif #if defined (JOB_CONTROL) /* Forget about the way job control was working. We are in a subshell. */ without_job_control (); set_sigchld_handler (); init_job_stats (); #endif /* JOB_CONTROL */ /* Reset the values of the shell flags and options. */ reset_shell_flags (); reset_shell_options (); reset_shopt_options (); /* Zero out builtin_env, since this could be a shell script run from a sourced file with a temporary environment supplied to the `source/.' builtin. Such variables are not supposed to be exported (empirical testing with sh and ksh). Just throw it away; don't worry about a memory leak. */ if (vc_isbltnenv (shell_variables)) shell_variables = shell_variables->down; clear_unwind_protect_list (0); /* XXX -- are there other things we should be resetting here? */ parse_and_execute_level = 0; /* nothing left to restore it */ /* We're no longer inside a shell function. */ variable_context = return_catch_flag = funcnest = 0; executing_list = 0; /* XXX */ /* If we're not interactive, close the file descriptor from which we're reading the current shell script. */ if (interactive_shell == 0) unset_bash_input (0); }
Exec Code Overflow
0
initialize_subshell () { #if defined (ALIAS) /* Forget about any aliases that we knew of. We are in a subshell. */ delete_all_aliases (); #endif /* ALIAS */ #if defined (HISTORY) /* Forget about the history lines we have read. This is a non-interactive subshell. */ history_lines_this_session = 0; #endif #if defined (JOB_CONTROL) /* Forget about the way job control was working. We are in a subshell. */ without_job_control (); set_sigchld_handler (); init_job_stats (); #endif /* JOB_CONTROL */ /* Reset the values of the shell flags and options. */ reset_shell_flags (); reset_shell_options (); reset_shopt_options (); /* Zero out builtin_env, since this could be a shell script run from a sourced file with a temporary environment supplied to the `source/.' builtin. Such variables are not supposed to be exported (empirical testing with sh and ksh). Just throw it away; don't worry about a memory leak. */ if (vc_isbltnenv (shell_variables)) shell_variables = shell_variables->down; clear_unwind_protect_list (0); /* XXX -- are there other things we should be resetting here? */ parse_and_execute_level = 0; /* nothing left to restore it */ /* We're no longer inside a shell function. */ variable_context = return_catch_flag = funcnest = 0; executing_list = 0; /* XXX */ /* If we're not interactive, close the file descriptor from which we're reading the current shell script. */ if (interactive_shell == 0) unset_bash_input (0); }
@@ -2370,7 +2370,9 @@ execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close) unfreeze_jobs_list (); } +#if defined (JOB_CONTROL) discard_unwind_frame ("lastpipe-exec"); +#endif return (exec_result); }
CWE-119
null
null
13,882
open_files () { register int i; int f, fd_table_size; fd_table_size = getdtablesize (); fprintf (stderr, "pid %ld open files:", (long)getpid ()); for (i = 3; i < fd_table_size; i++) { if ((f = fcntl (i, F_GETFD, 0)) != -1) fprintf (stderr, " %d (%s)", i, f ? "close" : "open"); } fprintf (stderr, "\n"); }
Exec Code Overflow
0
open_files () { register int i; int f, fd_table_size; fd_table_size = getdtablesize (); fprintf (stderr, "pid %ld open files:", (long)getpid ()); for (i = 3; i < fd_table_size; i++) { if ((f = fcntl (i, F_GETFD, 0)) != -1) fprintf (stderr, " %d (%s)", i, f ? "close" : "open"); } fprintf (stderr, "\n"); }
@@ -2370,7 +2370,9 @@ execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close) unfreeze_jobs_list (); } +#if defined (JOB_CONTROL) discard_unwind_frame ("lastpipe-exec"); +#endif return (exec_result); }
CWE-119
null
null
13,883
setup_async_signals () { #if defined (__BEOS__) set_signal_handler (SIGHUP, SIG_IGN); /* they want csh-like behavior */ #endif #if defined (JOB_CONTROL) if (job_control == 0) #endif { set_signal_handler (SIGINT, SIG_IGN); set_signal_ignored (SIGINT); set_signal_handler (SIGQUIT, SIG_IGN); set_signal_ignored (SIGQUIT); } }
Exec Code Overflow
0
setup_async_signals () { #if defined (__BEOS__) set_signal_handler (SIGHUP, SIG_IGN); /* they want csh-like behavior */ #endif #if defined (JOB_CONTROL) if (job_control == 0) #endif { set_signal_handler (SIGINT, SIG_IGN); set_signal_ignored (SIGINT); set_signal_handler (SIGQUIT, SIG_IGN); set_signal_ignored (SIGQUIT); } }
@@ -2370,7 +2370,9 @@ execute_pipeline (command, asynchronous, pipe_in, pipe_out, fds_to_close) unfreeze_jobs_list (); } +#if defined (JOB_CONTROL) discard_unwind_frame ("lastpipe-exec"); +#endif return (exec_result); }
CWE-119
null
null
13,884
locale_setblanks () { int x; for (x = 0; x < sh_syntabsiz; x++) { if (isblank (x)) sh_syntaxtab[x] |= CSHBRK|CBLANK; else if (member (x, shell_break_chars)) { sh_syntaxtab[x] |= CSHBRK; sh_syntaxtab[x] &= ~CBLANK; } else sh_syntaxtab[x] &= ~(CSHBRK|CBLANK); } }
Exec Code Overflow
0
locale_setblanks () { int x; for (x = 0; x < sh_syntabsiz; x++) { if (isblank (x)) sh_syntaxtab[x] |= CSHBRK|CBLANK; else if (member (x, shell_break_chars)) { sh_syntaxtab[x] |= CSHBRK; sh_syntaxtab[x] &= ~CBLANK; } else sh_syntaxtab[x] &= ~(CSHBRK|CBLANK); } }
@@ -1,6 +1,6 @@ /* locale.c - Miscellaneous internationalization functions. */ -/* Copyright (C) 1996-2009 Free Software Foundation, Inc. +/* Copyright (C) 1996-2009,2012 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell.
CWE-119
null
null
13,885
reset_locale_vars () { char *t; #if defined (HAVE_SETLOCALE) if (lang == 0 || *lang == '\0') maybe_make_export_env (); /* trust that this will change environment for setlocale */ if (setlocale (LC_ALL, lang ? lang : "") == 0) return 0; # if defined (LC_CTYPE) t = setlocale (LC_CTYPE, get_locale_var ("LC_CTYPE")); # endif # if defined (LC_COLLATE) t = setlocale (LC_COLLATE, get_locale_var ("LC_COLLATE")); # endif # if defined (LC_MESSAGES) t = setlocale (LC_MESSAGES, get_locale_var ("LC_MESSAGES")); # endif # if defined (LC_NUMERIC) t = setlocale (LC_NUMERIC, get_locale_var ("LC_NUMERIC")); # endif # if defined (LC_TIME) t = setlocale (LC_TIME, get_locale_var ("LC_TIME")); # endif locale_setblanks (); locale_mb_cur_max = MB_CUR_MAX; u32reset (); #endif return 1; }
Exec Code Overflow
0
reset_locale_vars () { char *t; #if defined (HAVE_SETLOCALE) if (lang == 0 || *lang == '\0') maybe_make_export_env (); /* trust that this will change environment for setlocale */ if (setlocale (LC_ALL, lang ? lang : "") == 0) return 0; # if defined (LC_CTYPE) t = setlocale (LC_CTYPE, get_locale_var ("LC_CTYPE")); # endif # if defined (LC_COLLATE) t = setlocale (LC_COLLATE, get_locale_var ("LC_COLLATE")); # endif # if defined (LC_MESSAGES) t = setlocale (LC_MESSAGES, get_locale_var ("LC_MESSAGES")); # endif # if defined (LC_NUMERIC) t = setlocale (LC_NUMERIC, get_locale_var ("LC_NUMERIC")); # endif # if defined (LC_TIME) t = setlocale (LC_TIME, get_locale_var ("LC_TIME")); # endif locale_setblanks (); locale_mb_cur_max = MB_CUR_MAX; u32reset (); #endif return 1; }
@@ -1,6 +1,6 @@ /* locale.c - Miscellaneous internationalization functions. */ -/* Copyright (C) 1996-2009 Free Software Foundation, Inc. +/* Copyright (C) 1996-2009,2012 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell.
CWE-119
null
null
13,886
set_default_locale () { #if defined (HAVE_SETLOCALE) default_locale = setlocale (LC_ALL, ""); if (default_locale) default_locale = savestring (default_locale); #endif /* HAVE_SETLOCALE */ bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); locale_mb_cur_max = MB_CUR_MAX; }
Exec Code Overflow
0
set_default_locale () { #if defined (HAVE_SETLOCALE) default_locale = setlocale (LC_ALL, ""); if (default_locale) default_locale = savestring (default_locale); #endif /* HAVE_SETLOCALE */ bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); locale_mb_cur_max = MB_CUR_MAX; }
@@ -1,6 +1,6 @@ /* locale.c - Miscellaneous internationalization functions. */ -/* Copyright (C) 1996-2009 Free Software Foundation, Inc. +/* Copyright (C) 1996-2009,2012 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell.
CWE-119
null
null
13,887
set_default_locale_vars () { char *val; #if defined (HAVE_SETLOCALE) # if defined (LC_CTYPE) val = get_string_value ("LC_CTYPE"); if (val == 0 && lc_all && *lc_all) { setlocale (LC_CTYPE, lc_all); locale_setblanks (); locale_mb_cur_max = MB_CUR_MAX; u32reset (); } # endif # if defined (LC_COLLATE) val = get_string_value ("LC_COLLATE"); if (val == 0 && lc_all && *lc_all) setlocale (LC_COLLATE, lc_all); # endif /* LC_COLLATE */ # if defined (LC_MESSAGES) val = get_string_value ("LC_MESSAGES"); if (val == 0 && lc_all && *lc_all) setlocale (LC_MESSAGES, lc_all); # endif /* LC_MESSAGES */ # if defined (LC_NUMERIC) val = get_string_value ("LC_NUMERIC"); if (val == 0 && lc_all && *lc_all) setlocale (LC_NUMERIC, lc_all); # endif /* LC_NUMERIC */ # if defined (LC_TIME) val = get_string_value ("LC_TIME"); if (val == 0 && lc_all && *lc_all) setlocale (LC_TIME, lc_all); # endif /* LC_TIME */ #endif /* HAVE_SETLOCALE */ val = get_string_value ("TEXTDOMAIN"); if (val && *val) { FREE (default_domain); default_domain = savestring (val); #if 0 /* Don't want to override the shell's textdomain as the default */ textdomain (default_domain); #endif } val = get_string_value ("TEXTDOMAINDIR"); if (val && *val) { FREE (default_dir); default_dir = savestring (val); if (default_domain && *default_domain) bindtextdomain (default_domain, default_dir); } }
Exec Code Overflow
0
set_default_locale_vars () { char *val; #if defined (HAVE_SETLOCALE) # if defined (LC_CTYPE) val = get_string_value ("LC_CTYPE"); if (val == 0 && lc_all && *lc_all) { setlocale (LC_CTYPE, lc_all); locale_setblanks (); locale_mb_cur_max = MB_CUR_MAX; u32reset (); } # endif # if defined (LC_COLLATE) val = get_string_value ("LC_COLLATE"); if (val == 0 && lc_all && *lc_all) setlocale (LC_COLLATE, lc_all); # endif /* LC_COLLATE */ # if defined (LC_MESSAGES) val = get_string_value ("LC_MESSAGES"); if (val == 0 && lc_all && *lc_all) setlocale (LC_MESSAGES, lc_all); # endif /* LC_MESSAGES */ # if defined (LC_NUMERIC) val = get_string_value ("LC_NUMERIC"); if (val == 0 && lc_all && *lc_all) setlocale (LC_NUMERIC, lc_all); # endif /* LC_NUMERIC */ # if defined (LC_TIME) val = get_string_value ("LC_TIME"); if (val == 0 && lc_all && *lc_all) setlocale (LC_TIME, lc_all); # endif /* LC_TIME */ #endif /* HAVE_SETLOCALE */ val = get_string_value ("TEXTDOMAIN"); if (val && *val) { FREE (default_domain); default_domain = savestring (val); #if 0 /* Don't want to override the shell's textdomain as the default */ textdomain (default_domain); #endif } val = get_string_value ("TEXTDOMAINDIR"); if (val && *val) { FREE (default_dir); default_dir = savestring (val); if (default_domain && *default_domain) bindtextdomain (default_domain, default_dir); } }
@@ -1,6 +1,6 @@ /* locale.c - Miscellaneous internationalization functions. */ -/* Copyright (C) 1996-2009 Free Software Foundation, Inc. +/* Copyright (C) 1996-2009,2012 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell.
CWE-119
null
null
13,888
all_array_variables () { return (vapply (visible_array_vars)); }
Exec Code Overflow
0
all_array_variables () { return (vapply (visible_array_vars)); }
@@ -4666,12 +4666,18 @@ sv_locale (name) char *name; { char *v; + int r; v = get_string_value (name); if (name[0] == 'L' && name[1] == 'A') /* LANG */ - set_lang (name, v); + r = set_lang (name, v); else - set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */ + r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */ + +#if 1 + if (r == 0 && posixly_correct) + last_command_exit_value = 1; +#endif } #if defined (ARRAY_VARS)
CWE-119
null
null
13,889
all_exported_variables () { return (vapply (visible_and_exported)); }
Exec Code Overflow
0
all_exported_variables () { return (vapply (visible_and_exported)); }
@@ -4666,12 +4666,18 @@ sv_locale (name) char *name; { char *v; + int r; v = get_string_value (name); if (name[0] == 'L' && name[1] == 'A') /* LANG */ - set_lang (name, v); + r = set_lang (name, v); else - set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */ + r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */ + +#if 1 + if (r == 0 && posixly_correct) + last_command_exit_value = 1; +#endif } #if defined (ARRAY_VARS)
CWE-119
null
null
13,890
all_local_variables () { VARLIST *vlist; SHELL_VAR **ret; VAR_CONTEXT *vc; vc = shell_variables; for (vc = shell_variables; vc; vc = vc->down) if (vc_isfuncenv (vc) && vc->scope == variable_context) break; if (vc == 0) { internal_error (_("all_local_variables: no function context at current scope")); return (SHELL_VAR **)NULL; } if (vc->table == 0 || HASH_ENTRIES (vc->table) == 0 || vc_haslocals (vc) == 0) return (SHELL_VAR **)NULL; vlist = vlist_alloc (HASH_ENTRIES (vc->table)); flatten (vc->table, variable_in_context, vlist, 0); ret = vlist->list; free (vlist); if (ret) sort_variables (ret); return ret; }
Exec Code Overflow
0
all_local_variables () { VARLIST *vlist; SHELL_VAR **ret; VAR_CONTEXT *vc; vc = shell_variables; for (vc = shell_variables; vc; vc = vc->down) if (vc_isfuncenv (vc) && vc->scope == variable_context) break; if (vc == 0) { internal_error (_("all_local_variables: no function context at current scope")); return (SHELL_VAR **)NULL; } if (vc->table == 0 || HASH_ENTRIES (vc->table) == 0 || vc_haslocals (vc) == 0) return (SHELL_VAR **)NULL; vlist = vlist_alloc (HASH_ENTRIES (vc->table)); flatten (vc->table, variable_in_context, vlist, 0); ret = vlist->list; free (vlist); if (ret) sort_variables (ret); return ret; }
@@ -4666,12 +4666,18 @@ sv_locale (name) char *name; { char *v; + int r; v = get_string_value (name); if (name[0] == 'L' && name[1] == 'A') /* LANG */ - set_lang (name, v); + r = set_lang (name, v); else - set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */ + r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */ + +#if 1 + if (r == 0 && posixly_correct) + last_command_exit_value = 1; +#endif } #if defined (ARRAY_VARS)
CWE-119
null
null
13,891
all_shell_functions () { return (fapply ((sh_var_map_func_t *)NULL)); }
Exec Code Overflow
0
all_shell_functions () { return (fapply ((sh_var_map_func_t *)NULL)); }
@@ -4666,12 +4666,18 @@ sv_locale (name) char *name; { char *v; + int r; v = get_string_value (name); if (name[0] == 'L' && name[1] == 'A') /* LANG */ - set_lang (name, v); + r = set_lang (name, v); else - set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */ + r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */ + +#if 1 + if (r == 0 && posixly_correct) + last_command_exit_value = 1; +#endif } #if defined (ARRAY_VARS)
CWE-119
null
null
13,892
all_visible_functions () { return (fapply (visible_var)); }
Exec Code Overflow
0
all_visible_functions () { return (fapply (visible_var)); }
@@ -4666,12 +4666,18 @@ sv_locale (name) char *name; { char *v; + int r; v = get_string_value (name); if (name[0] == 'L' && name[1] == 'A') /* LANG */ - set_lang (name, v); + r = set_lang (name, v); else - set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */ + r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */ + +#if 1 + if (r == 0 && posixly_correct) + last_command_exit_value = 1; +#endif } #if defined (ARRAY_VARS)
CWE-119
null
null
13,893
brand () { /* From "Random number generators: good ones are hard to find", Park and Miller, Communications of the ACM, vol. 31, no. 10, October 1988, p. 1195. filtered through FreeBSD */ long h, l; /* Can't seed with 0. */ if (rseed == 0) rseed = 123459876; h = rseed / 127773; l = rseed % 127773; rseed = 16807 * l - 2836 * h; #if 0 if (rseed < 0) rseed += 0x7fffffff; #endif return ((unsigned int)(rseed & 32767)); /* was % 32768 */ }
Exec Code Overflow
0
brand () { /* From "Random number generators: good ones are hard to find", Park and Miller, Communications of the ACM, vol. 31, no. 10, October 1988, p. 1195. filtered through FreeBSD */ long h, l; /* Can't seed with 0. */ if (rseed == 0) rseed = 123459876; h = rseed / 127773; l = rseed % 127773; rseed = 16807 * l - 2836 * h; #if 0 if (rseed < 0) rseed += 0x7fffffff; #endif return ((unsigned int)(rseed & 32767)); /* was % 32768 */ }
@@ -4666,12 +4666,18 @@ sv_locale (name) char *name; { char *v; + int r; v = get_string_value (name); if (name[0] == 'L' && name[1] == 'A') /* LANG */ - set_lang (name, v); + r = set_lang (name, v); else - set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */ + r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */ + +#if 1 + if (r == 0 && posixly_correct) + last_command_exit_value = 1; +#endif } #if defined (ARRAY_VARS)
CWE-119
null
null
13,894
create_variable_tables () { if (shell_variables == 0) { shell_variables = global_variables = new_var_context ((char *)NULL, 0); shell_variables->scope = 0; shell_variables->table = hash_create (0); } if (shell_functions == 0) shell_functions = hash_create (0); #if defined (DEBUGGER) if (shell_function_defs == 0) shell_function_defs = hash_create (0); #endif }
Exec Code Overflow
0
create_variable_tables () { if (shell_variables == 0) { shell_variables = global_variables = new_var_context ((char *)NULL, 0); shell_variables->scope = 0; shell_variables->table = hash_create (0); } if (shell_functions == 0) shell_functions = hash_create (0); #if defined (DEBUGGER) if (shell_function_defs == 0) shell_function_defs = hash_create (0); #endif }
@@ -4666,12 +4666,18 @@ sv_locale (name) char *name; { char *v; + int r; v = get_string_value (name); if (name[0] == 'L' && name[1] == 'A') /* LANG */ - set_lang (name, v); + r = set_lang (name, v); else - set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */ + r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */ + +#if 1 + if (r == 0 && posixly_correct) + last_command_exit_value = 1; +#endif } #if defined (ARRAY_VARS)
CWE-119
null
null
13,895
dispose_saved_dollar_vars () { if (!dollar_arg_stack || dollar_arg_stack_index == 0) return; dispose_words (dollar_arg_stack[dollar_arg_stack_index]); dollar_arg_stack[dollar_arg_stack_index] = (WORD_LIST *)NULL; }
Exec Code Overflow
0
dispose_saved_dollar_vars () { if (!dollar_arg_stack || dollar_arg_stack_index == 0) return; dispose_words (dollar_arg_stack[dollar_arg_stack_index]); dollar_arg_stack[dollar_arg_stack_index] = (WORD_LIST *)NULL; }
@@ -4666,12 +4666,18 @@ sv_locale (name) char *name; { char *v; + int r; v = get_string_value (name); if (name[0] == 'L' && name[1] == 'A') /* LANG */ - set_lang (name, v); + r = set_lang (name, v); else - set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */ + r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */ + +#if 1 + if (r == 0 && posixly_correct) + last_command_exit_value = 1; +#endif } #if defined (ARRAY_VARS)
CWE-119
null
null
13,896
dispose_used_env_vars () { if (temporary_env) { dispose_temporary_env (propagate_temp_var); maybe_make_export_env (); } }
Exec Code Overflow
0
dispose_used_env_vars () { if (temporary_env) { dispose_temporary_env (propagate_temp_var); maybe_make_export_env (); } }
@@ -4666,12 +4666,18 @@ sv_locale (name) char *name; { char *v; + int r; v = get_string_value (name); if (name[0] == 'L' && name[1] == 'A') /* LANG */ - set_lang (name, v); + r = set_lang (name, v); else - set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */ + r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */ + +#if 1 + if (r == 0 && posixly_correct) + last_command_exit_value = 1; +#endif } #if defined (ARRAY_VARS)
CWE-119
null
null
13,897
get_bash_name () { char *name; if ((login_shell == 1) && RELPATH(shell_name)) { if (current_user.shell == 0) get_current_user_info (); name = savestring (current_user.shell); } else if (ABSPATH(shell_name)) name = savestring (shell_name); else if (shell_name[0] == '.' && shell_name[1] == '/') { /* Fast path for common case. */ char *cdir; int len; cdir = get_string_value ("PWD"); if (cdir) { len = strlen (cdir); name = (char *)xmalloc (len + strlen (shell_name) + 1); strcpy (name, cdir); strcpy (name + len, shell_name + 1); } else name = savestring (shell_name); } else { char *tname; int s; tname = find_user_command (shell_name); if (tname == 0) { /* Try the current directory. If there is not an executable there, just punt and use the login shell. */ s = file_status (shell_name); if (s & FS_EXECABLE) { tname = make_absolute (shell_name, get_string_value ("PWD")); if (*shell_name == '.') { name = sh_canonpath (tname, PATH_CHECKDOTDOT|PATH_CHECKEXISTS); if (name == 0) name = tname; else free (tname); } else name = tname; } else { if (current_user.shell == 0) get_current_user_info (); name = savestring (current_user.shell); } } else { name = full_pathname (tname); free (tname); } } return (name); }
Exec Code Overflow
0
get_bash_name () { char *name; if ((login_shell == 1) && RELPATH(shell_name)) { if (current_user.shell == 0) get_current_user_info (); name = savestring (current_user.shell); } else if (ABSPATH(shell_name)) name = savestring (shell_name); else if (shell_name[0] == '.' && shell_name[1] == '/') { /* Fast path for common case. */ char *cdir; int len; cdir = get_string_value ("PWD"); if (cdir) { len = strlen (cdir); name = (char *)xmalloc (len + strlen (shell_name) + 1); strcpy (name, cdir); strcpy (name + len, shell_name + 1); } else name = savestring (shell_name); } else { char *tname; int s; tname = find_user_command (shell_name); if (tname == 0) { /* Try the current directory. If there is not an executable there, just punt and use the login shell. */ s = file_status (shell_name); if (s & FS_EXECABLE) { tname = make_absolute (shell_name, get_string_value ("PWD")); if (*shell_name == '.') { name = sh_canonpath (tname, PATH_CHECKDOTDOT|PATH_CHECKEXISTS); if (name == 0) name = tname; else free (tname); } else name = tname; } else { if (current_user.shell == 0) get_current_user_info (); name = savestring (current_user.shell); } } else { name = full_pathname (tname); free (tname); } } return (name); }
@@ -4666,12 +4666,18 @@ sv_locale (name) char *name; { char *v; + int r; v = get_string_value (name); if (name[0] == 'L' && name[1] == 'A') /* LANG */ - set_lang (name, v); + r = set_lang (name, v); else - set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */ + r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */ + +#if 1 + if (r == 0 && posixly_correct) + last_command_exit_value = 1; +#endif } #if defined (ARRAY_VARS)
CWE-119
null
null
13,898
get_random_number () { int rv, pid; /* Reset for command and process substitution. */ pid = getpid (); if (subshell_environment && seeded_subshell != pid) { seedrand (); seeded_subshell = pid; } do rv = brand (); while (rv == last_random_value); return rv; }
Exec Code Overflow
0
get_random_number () { int rv, pid; /* Reset for command and process substitution. */ pid = getpid (); if (subshell_environment && seeded_subshell != pid) { seedrand (); seeded_subshell = pid; } do rv = brand (); while (rv == last_random_value); return rv; }
@@ -4666,12 +4666,18 @@ sv_locale (name) char *name; { char *v; + int r; v = get_string_value (name); if (name[0] == 'L' && name[1] == 'A') /* LANG */ - set_lang (name, v); + r = set_lang (name, v); else - set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */ + r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */ + +#if 1 + if (r == 0 && posixly_correct) + last_command_exit_value = 1; +#endif } #if defined (ARRAY_VARS)
CWE-119
null
null
13,899
init_funcname_var () { SHELL_VAR *v; v = find_variable ("FUNCNAME"); if (v) return v; #if defined (ARRAY_VARS) INIT_DYNAMIC_ARRAY_VAR ("FUNCNAME", get_funcname, null_array_assign); #else INIT_DYNAMIC_VAR ("FUNCNAME", (char *)NULL, get_funcname, null_assign); #endif VSETATTR (v, att_invisible|att_noassign); return v; }
Exec Code Overflow
0
init_funcname_var () { SHELL_VAR *v; v = find_variable ("FUNCNAME"); if (v) return v; #if defined (ARRAY_VARS) INIT_DYNAMIC_ARRAY_VAR ("FUNCNAME", get_funcname, null_array_assign); #else INIT_DYNAMIC_VAR ("FUNCNAME", (char *)NULL, get_funcname, null_assign); #endif VSETATTR (v, att_invisible|att_noassign); return v; }
@@ -4666,12 +4666,18 @@ sv_locale (name) char *name; { char *v; + int r; v = get_string_value (name); if (name[0] == 'L' && name[1] == 'A') /* LANG */ - set_lang (name, v); + r = set_lang (name, v); else - set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */ + r = set_locale_var (name, v); /* LC_*, TEXTDOMAIN* */ + +#if 1 + if (r == 0 && posixly_correct) + last_command_exit_value = 1; +#endif } #if defined (ARRAY_VARS)
CWE-119
null
null