Xbmc: [Addons] Crash when updating addon with private repo in manifest

Created on 3 Nov 2020  路  12Comments  路  Source: xbmc/xbmc


Bug report

Describe the bug

Here is a clear and concise description of what the problem is:

When manually updating an addon that has a private repository in its manifest, Kodi will crash. The source of the problem appears to be with changes made between Matrix Alpha 1 and Alpha 2:

https://github.com/xbmc/xbmc/blob/f60adf0651984f8f5227b6fbdb57478d932d6cb2/xbmc/addons/AddonInstaller.cpp#L678-L684

The call to CheckForUpdates is casting an object that is not a CRepository into one, which bypasses construction, but more specifically the CRepository::m_dirs member variable isn't really a vector<>, causing the crash when m_dirs is attempted to be iterated here:

https://github.com/xbmc/xbmc/blob/36962a8b9a3591dc245d442423c0bef94820ca31/xbmc/addons/Repository.cpp#L234-L237

The vector<> iterators are garbage, so it enters the loop and blows up calling dir.checksum.empty().

Expected Behavior

Here is a clear and concise description of what was expected to happen:

Expected to not crash, I suppose?

Actual Behavior

Please see description above.

Possible Fix

Construct a new instance of CRepository and use that instead? That doesn't appear to be trivial with the information on-hand in that function and might need multiple changes to support it, so I didn't bother trying a PR for this one, leaving it to the pros.

To Reproduce

Steps to reproduce the behavior:

  1. Install an addon that has a private repository in its manifest
  2. Attempt to update that addon manually via an external .zip file
  3. After the addon is installed, Kodi will crash

Debuglog

The debuglog can be found here:
https://paste.kodi.tv/resavetori.kodi

Screenshots

Here are some links or screenshots to help explain the problem:
N/A

Additional context or screenshots (if appropriate)

N/A

Your Environment

Used Operating system:

  • [ ] Android
  • [ ] iOS
  • [ ] tvOS
  • [ ] Linux
  • [ ] OSX
  • [X] Windows
  • [ ] Windows UWP
  • Operating system version/name:
  • Kodi version: (19.0-ALPHA3 (18.9.730) Git:20201031-bb0699db41). Platform: Windows NT x86 64-bit


note: Once the issue is made we require you to update it with new information or Kodi versions should that be required.
Team Kodi will consider your problem report however, we will not make any promises the problem will be solved.

Add-ons Confirmed

All 12 comments

How could it be that an addon instance with type ADDON_REPOSITORY is not a CRepository?

It appears to start life via AddonBuilder::Generate() as ADDON_UNKNOWN and therefore just a CAddon instance, but I didn't really dig in that far. Just telling you what I found :)

bool CAddonInfo::HasType(TYPE type, bool mainOnly /*= false*/) const
{
  return (m_mainType == type || ProvidesSubContent(type, mainOnly ? m_mainType : ADDON_UNKNOWN));
}

Seems we need to call HasType(true) in this case... @AlwinEsch what do you say?

Is the addon you attempted to install something you can share?

Certainly: https://github.com/djp952/pvr.hdhomerundvr/releases/tag/matrix-3.3.3a

This would be the only version I have compatible with master/Alpha 3.

Seems we need to call HasType(true) in this case

@phunkyfish I'm pretty sure this is the correct fix.

Seems we need to call HasType(true) in this case

@phunkyfish I'm pretty sure this is the correct fix.

I鈥檓 not disputing that. Was just curious to see what structure the repo being installed had.

@howie-f can you pick up this change?

@howie-f can you pick up this change?

sure, ..else if (m_addon->HasType(ADDON_REPOSITORY, true)) separate PR or the pending one?

@djp952 could you please check if this https://github.com/howie-f/xbmc/commit/19b92db2768e85148e5b23824bcf6853c3430522 fixes your issue? if it does i'll polish it up. thanks

@howie-f - looks great from here! Thank you very much!

edit: This wasn't a static analysis I did make the proposed changes and rebuilt from master branch. By "looks great" I mean I did legitimately build and test it and it worked just fine for me...

I just wanted to thank @howie-f for all the work that went into this on my account. It is sincerely appreciated! 馃憤 馃憤 馃憤

Was this page helpful?
0 / 5 - 0 ratings