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 752428 - dashdemux: replace sscanf with strtoul
dashdemux: replace sscanf with strtoul
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal enhancement
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-07-15 15:58 UTC by Florin Apostol
Modified: 2018-11-03 13:37 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Florin Apostol 2015-07-15 15:58:13 UTC
gstmpdparser.c file uses sscanf(..., "%u", ...) to read numbers from the xml file. sscanf is unable to indicate the fact that the input string was completely parsed or not. For example, for the input "123xyz" the sscanf function will return 1 (it successfully read an integer).

A better function is strtol (and strtoul, etc). This has the ability to provide a pointer to the next unparsed character in string. Using this, we can detect if the original string was valid or not.

The question is how restrictive the parser should be? Where a number is expected in an xml attribute and a "123xyz" is provided, should the parser read and use 123 or it should signal an error? Currently it reads just 123 and no error or warnings are issued (provided it does not need to parse the attribute further than the number).

So, should we make the parser more restrictive or not?
Comment 1 Olivier Crête 2015-07-15 16:20:58 UTC
I'd make the parser less strict instead of more, in the worse case, it's not going to work anyway.
Comment 2 Florin Apostol 2015-07-15 16:45:36 UTC
A restrictive parser will at least detect the 123xyz situations and:
1) will issue a warning about suspicious values (very useful when debugging, especially if we are talking about durations, ranges, etc)
2) could either return 123 (as it currently does) or the default value for that attribute.

I started this ticket because I feel the default value might be a better solution than returning a suspicious value. But indeed, for mandatory attributes that means a failure to play.
Comment 3 Jan Schmidt 2016-05-15 15:38:43 UTC
We could use the %n format specifier in sscanf to verify the consumed character count.
Comment 4 GStreamer system administrator 2018-11-03 13:37:42 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/274.