After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 668090 - Prevent an endless loop when browsing faulty servers
Prevent an endless loop when browsing faulty servers
Status: RESOLVED FIXED
Product: gupnp-tools
Classification: Other
Component: General
unspecified
Other All
: Normal normal
: ---
Assigned To: GUPnP Maintainers
GUPnP Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-01-17 13:45 UTC by Jens Georg
Modified: 2019-02-22 05:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
av-cp: Don't create an enless loop (1.57 KB, patch)
2012-01-17 13:45 UTC, Jens Georg
accepted-commit_now Details | Review
av-cp: Don't create an enless loop (3.52 KB, patch)
2012-02-10 13:36 UTC, Jens Georg
none Details | Review

Description Jens Georg 2012-01-17 13:45:48 UTC
If the server reports a total_count > 0 but smaller than the returned
children so far, av-cp would enter an endless loop since the unsigned
integer substraction ended up in a rather large remaining number of
items to be fetched.
Comment 1 Jens Georg 2012-01-17 13:45:50 UTC
Created attachment 205442 [details] [review]
av-cp: Don't create an enless loop
Comment 2 Zeeshan Ali 2012-01-17 13:52:21 UTC
Review of attachment 205442 [details] [review]:

ACK!
Comment 3 Jens Georg 2012-01-18 10:13:41 UTC
Hm, wait. That breaks the "TotalMatches = 0" case. Back to drawing board.
Comment 4 Jens Georg 2012-02-10 08:48:20 UTC
Actually it looks like av-cp doesn't really handle the "TotalMatches = 0" case properly at all.
Comment 5 Jens Georg 2012-02-10 13:36:40 UTC
Created attachment 207245 [details] [review]
av-cp: Don't create an enless loop

If the server reports a total_count > 0 but smaller than the returned
children so far, av-cp would enter an endless loop since the unsigned
integer substraction ended up in a rather large remaining number of
items to be fetched.
Comment 6 Jens Georg 2012-02-24 14:53:01 UTC
Still behaves weird :-/
Comment 7 Andrzej Bieniek 2012-11-25 22:14:33 UTC
What should be a correct behaviour when TotalMatches=0 ?
Looks like it is allowed by the spec.

There are couple of conditions with TotalMatches=0:
a) RequestedCount = NumberReturned -> possible more items
b) RequestedCount > NumberReturned -> no more items
c) RequestedCount < NumberReturned -> broken server

My thinking is that for b and c CP doesn't call Browse any more.
For a, cp should Browse again until NumberReturned = 0.

---
ContentDirectory:4 Date: December 31, 2010
Service Template Version 1.01 section 2.5.7.2 Arguments, says:

If the ContentDirectory service implementation cannot timely compute the value of TotalMatches,
but there are matching objects that have been found by the ContentDirectory service
implementation, then the Browse() action MUST successfully return with the TotalMatches
argument set to zero and the NumberReturned argument indicating the number of returned objects.
If the ContentDirectory service implementation cannot timely compute the value of TotalMatches,
and there are no matching objects found, then the Browse() action MUST return error code 720.
Comment 8 Jens Georg 2012-12-12 16:05:00 UTC
The way I'm doing it in Helium seems to work quite well: 

https://github.com/phako/Helium/blob/master/upnp/browsemodel_p.cpp#L423
Comment 9 Jens Georg 2013-01-18 07:42:14 UTC
Patch commited and I can't reproduce the weird issues anymore (actually it's already released in 0.8.5)