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 683088 - gdbus-codegen: fix error when wrong interface name is provided to --annotate
gdbus-codegen: fix error when wrong interface name is provided to --annotate
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gdbus
2.33.x
Other Linux
: Normal normal
: ---
Assigned To: David Zeuthen (not reading bugmail)
gtkdev
Depends on:
Blocks:
 
 
Reported: 2012-08-31 09:49 UTC by Aleksander Morgado
Modified: 2012-09-01 16:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch for the issue (1.58 KB, patch)
2012-08-31 09:52 UTC, Aleksander Morgado
none Details | Review
gdbus-codegen: avoid error when wrong interface is provided to --annotate (1.56 KB, patch)
2012-09-01 16:01 UTC, Matthias Clasen
committed Details | Review

Description Aleksander Morgado 2012-08-31 09:49:18 UTC
When a wrong interface name is provided to --annotate, e.g.:

  --annotate "something.wrong" org.gtk.GDBus.C.ForceGVariant True

gdbus-codegen crashes with:

    Traceback (most recent call last):
  • File "/usr/bin/gdbus-codegen", line 41 in <module>
    sys.exit(codegen_main.codegen_main())
  • File "/usr/lib64/gdbus-2.0/codegen/codegen_main.py", line 175 in codegen_main
    apply_annotations(all_ifaces, opts.annotate)
  • File "/usr/lib64/gdbus-2.0/codegen/codegen_main.py", line 146 in apply_annotations
    apply_annotation(iface_list, iface, None, None, None, None, key, value)
  • File "/usr/lib64/gdbus-2.0/codegen/codegen_main.py", line 64 in apply_annotation
    if iface_obj == None:     UnboundLocalError: local variable 'iface_obj' referenced before assignment

Comment 1 Aleksander Morgado 2012-08-31 09:52:18 UTC
Created attachment 223031 [details] [review]
Patch for the issue

Just initialize the iface_obj variable before the loop.

Now the error is the expected one:

Traceback (most recent call last):
  • File "/usr/bin/gdbus-codegen", line 41 in <module>
    sys.exit(codegen_main.codegen_main())
  • File "/usr/lib64/gdbus-2.0/codegen/codegen_main.py", line 176 in codegen_main
    apply_annotations(all_ifaces, opts.annotate)
  • File "/usr/lib64/gdbus-2.0/codegen/codegen_main.py", line 147 in apply_annotations
    apply_annotation(iface_list, iface, None, None, None, None, key, value)
  • File "/usr/lib64/gdbus-2.0/codegen/codegen_main.py", line 66 in apply_annotation
    raise RuntimeError('No interface %s'%iface)
RuntimeError: No interface something.wrong

Comment 2 Matthias Clasen 2012-09-01 16:00:59 UTC
The following fix has been pushed:
724c8a1 gdbus-codegen: avoid error when wrong interface is provided to --annotate
Comment 3 Matthias Clasen 2012-09-01 16:01:02 UTC
Created attachment 223149 [details] [review]
gdbus-codegen: avoid error when wrong interface is provided to --annotate

If the interface given cannot be matched, `iface_obj' was left uninitialized and
the iface_obj == None check would end up crashing:

Traceback (most recent call last):
  • File "/usr/bin/gdbus-codegen", line 41 in <module>
    sys.exit(codegen_main.codegen_main())
  • File "/usr/lib64/gdbus-2.0/codegen/codegen_main.py", line 175 in codegen_main
    apply_annotations(all_ifaces, opts.annotate)
  • File "/usr/lib64/gdbus-2.0/codegen/codegen_main.py", line 146 in apply_annotations
    apply_annotation(iface_list, iface, None, None, None, None, key, value)
  • File "/usr/lib64/gdbus-2.0/codegen/codegen_main.py", line 64 in apply_annotation
    if iface_obj == None:
UnboundLocalError: local variable 'iface_obj' referenced before assignment

Fixes