Commit Graph

118 Commits

Author SHA1 Message Date
David Zeuthen
79d32c2fc1 GDBusMessage: Fix bug when deserializing a message
See https://bugzilla.gnome.org/show_bug.cgi?id=621838 for the whole
story. The problem was that we ended up reading data from arrays of
arrays when we were just supposed to be aligning the buffers.

Also add a host of debug infrastructure that was needed to find the
root cause. For now it can be turned on only via defining
DEBUG_SERIALIZER. In the future we might want to make it work via
G_DBUS_DEBUG. In a nutshell, the added debug info looks like this

Parsing blob (blob_len = 0x0084 bytes)
  0000: 6c 01 00 01  3c 00 00 00  41 00 00 00  37 00 00 00    l...<...A...7...
  0010: 08 01 67 00  08 61 61 79  61 7b 73 76  7d 00 00 00    ..g..aaya{sv}...
  0020: 01 01 6f 00  08 00 00 00  2f 66 6f 6f  2f 62 61 72    ..o...../foo/bar
  0030: 00 00 00 00  00 00 00 00  03 01 73 00  06 00 00 00    ..........s.....
  0040: 4d 65 6d 62  65 72 00 00  00 00 00 00  34 00 00 00    Member......4...
  0050: 03 00 00 00  63 77 64 00  01 73 00 00  23 00 00 00    ....cwd..s..#...
  0060: 2f 68 6f 6d  65 2f 64 61  76 69 64 7a  2f 48 61 63    /home/davidz/Hac
  0070: 6b 69 6e 67  2f 67 6c 69  62 2f 67 69  6f 2f 74 65    king/glib/gio/te
  0080: 73 74 73 00                                           sts.

Parsing headers (blob_len = 0x0084 bytes)
  Reading type a{yv} from offset 0x000c: array spans 0x0037 bytes
    Reading type {yv} from offset 0x0010
      Reading type y from offset 0x0010: 0x08 '
      Reading type v from offset 0x0011
        Reading type g from offset 0x0014: 'aaya{sv}'
    Reading type {yv} from offset 0x001e
      Reading type y from offset 0x0020: 0x01 ''
      Reading type v from offset 0x0021
        Reading type o from offset 0x0024: '/foo/bar'
    Reading type {yv} from offset 0x0031
      Reading type y from offset 0x0038: 0x03 ''
      Reading type v from offset 0x0039
        Reading type s from offset 0x003c: 'Member'
Parsing body (blob_len = 0x0084 bytes)
  Reading type (aaya{sv}) from offset 0x0047
    Reading type aay from offset 0x0048: array spans 0x0000 bytes
    Reading type a{sv} from offset 0x004c: array spans 0x0034 bytes
      Reading type {sv} from offset 0x0050
        Reading type s from offset 0x0050: 'cwd'
        Reading type v from offset 0x0058
          Reading type s from offset 0x005b: '/home/davidz/Hacking/glib/gio/tests'
OK

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-06-17 18:01:32 -04:00
David Zeuthen
57dff1e060 GDBusMessage: Properly check error and bail if set
Otherwise we may set a GError on top of it.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-06-17 16:12:46 -04:00
Christian Persch
87ee5f3641 Don't do an extra strlen when g_variant_get_string() returns it already 2010-06-06 16:32:04 -04:00
David Zeuthen
eec66b2f94 GDBus: Big-endian fixes
Tested this on my Powerbook G4 12", 867MHz PowerPC G4 running Fedora
11ish.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-05-25 12:03:27 -04:00
Christian Persch
c7f0f2c437 Use stack-allocated GVariantBuilders
This saves a few allocations.
Also simplify the code a bit in gdbusconnection.

Bug #618616.
2010-05-20 21:17:14 +02:00
David Zeuthen
366b3ffcde Bug 619142 – Build fixes
- Fix various #include issues

 - Change #error to #warning for the EXTERNAL authentication mechanism.
   It is not clear if this should work on Win32 at all.

 - Call close() before unlink() for the SHA1 keyring

 - Change #error to #warning so we don't forget to do
   permission checking of the .dbus-keyrings directory

 - Use Win32 SID for the SHA1 auth mech

 - Apparently we can't use word 'interface' as an identifier

 - Implement a _g_dbus_win32_get_user_sid() function. For now it's
   private. Don't know if it should be public somewhere. Maybe in
   a future GCredentials support for Win32? I don't know.

 - GFileDescriptorBased is not available on Win32. So avoid using
   it in GLocalFile stuff. Now, Win32 still uses GLocalFile + friends
   (which works with file descriptors) so expose a private function
   to get the fd for an OutputStream so things still work.

 - Fixup gio.symbols

 - Fixup tests/gdbus-peer.c so it builds

With this, at least things compile and the gdbus-peer.exe test case
passes. Which is a great start. I've tested this by cross-compiling on
a x86_64 Fedora 13 host using mingw32 and running the code on a 32-bit
Windows 7 box.

https://bugzilla.gnome.org/show_bug.cgi?id=619142

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-05-20 10:53:08 -04:00
Christian Persch
5b2c7f10bd Plug mem leaks in parse_value_from_blob
The result of read_string() was leaked.

Bug #618615.
2010-05-15 00:12:17 +02:00
David Zeuthen
bb6530eb34 GDBus: Fix serialization of empty arrays
It turns out that we didn't observe padding (neither when reading nor
writing) for empty arrays which (apparently) is needed according to
the D-Bus spec and reference implementation. A simple test case to
provoke this behavior is as follows (notice the lack of 4 bytes worth
of padding at position 0x0064):

 Error calling dbus_message_demarshal() on this blob: org.freedesktop.DBus.Error.InvalidArgs: Message is corrupted (Alignment padding not null)
 0000: 6c 01 00 01  2e 00 00 00  41 00 00 00  37 00 00 00    l.......A...7...
 0010: 08 01 67 00  08 73 61 7b  73 76 7d 61  73 00 00 00    ..g..sa{sv}as...
 0020: 01 01 6f 00  08 00 00 00  2f 66 6f 6f  2f 62 61 72    ..o...../foo/bar
 0030: 00 00 00 00  00 00 00 00  03 01 73 00  06 00 00 00    ..........s.....
 0040: 4d 65 6d 62  65 72 00 00  11 00 00 00  30 31 32 33    Member......0123
 0050: 34 35 36 37  38 39 30 31  32 33 34 35  36 00 00 00    4567890123456...
 0060: 00 00 00 00  0e 00 00 00  09 00 00 00  53 6f 6d 65    ............Some
 0070: 74 68 69 6e  67 00                                    thing.

 The blob was generated from the following GVariant value:
 ('01234567890123456', @a{sv} {}, ['Something'])

 If the blob was encoded using DBusMessageIter, the payload would have been:

 0000: 6c 01 00 01  32 00 00 00  41 00 00 00  36 00 00 00    l...2...A...6...
 0010: 01 01 6f 00  08 00 00 00  2f 66 6f 6f  2f 62 61 72    ..o...../foo/bar
 0020: 00 00 00 00  00 00 00 00  03 01 73 00  06 00 00 00    ..........s.....
 0030: 4d 65 6d 62  65 72 00 00  08 01 67 00  08 73 61 7b    Member....g..sa{
 0040: 73 76 7d 61  73 00 00 00  11 00 00 00  30 31 32 33    sv}as.......0123
 0050: 34 35 36 37  38 39 30 31  32 33 34 35  36 00 00 00    4567890123456...
 0060: 00 00 00 00  00 00 00 00  0e 00 00 00  09 00 00 00    ................
 0070: 53 6f 6d 65  74 68 69 6e  67 00                       Something.
 ** ERROR:gdbus-serialization.c:547:check_serialization: code should not be reached
 Aborted

and this is now in the libdbus-1-using serialization test case.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-05-14 12:56:09 -04:00
Matthias Clasen
1d22b64843 Cleanups
Sort #includes a bit better, and don't include platform-specific
headers in gio.h.
2010-05-14 08:38:07 -04:00
Matthias Clasen
8f89b63930 Clean up platform-specific includes
The problem was pointed out in bug 618029. To solve it, we moved
the GUnixFDList typedef to giotypes.h.
2010-05-13 20:29:04 -04:00
Christian Persch
4ad4c306c3 Plug some mem leaks
g_variant_get (v, "s", &str) returns a string copy; use "&s" instead.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-05-13 16:43:41 -04:00
David Zeuthen
33952347ff GDBus: Make message serialization routines take capabilities param
This is needed to e.g. allow encoding maybe types (once we add
G_DBUS_CAPABILITY_FLAGS_MAYBE_TYPES) if, and only if, that capability
has been negotiated with the peer (via authentication).
2010-05-13 14:03:58 -04:00
Matthias Clasen
0cf467c2ca Update copyright years to include 2010 2010-05-09 13:14:55 -04:00
David Zeuthen
46ce134d51 GDBus: Add new symbols to gio.symbols 2010-05-06 17:31:51 -04:00
David Zeuthen
fb1b4599a0 GDBus: Fix up i18n 2010-05-06 16:34:23 -04:00
David Zeuthen
0fd6498cd8 Add "Since: 2.26" to all new GDBus API 2010-05-06 16:02:08 -04:00
David Zeuthen
c490c14f4e Set up gtk-doc for GDBus
Also move send_credentials() and receive_credentials() to
GUnixConnection. This code might change, discussion is still ongoing
in

 https://bugzilla.gnome.org/show_bug.cgi?id=617483.
2010-05-06 15:31:45 -04:00
David Zeuthen
d0a14469d0 Initial GDBus code-drop from GDBus-standalone repo
Things compile and the test-suite passes. Still need to hook up
gio.symbols and docs. There are still a bunch of TODOs left in the
sources that needs to be addressed.

Signed-off-by: David Zeuthen <davidz@redhat.com>
2010-05-06 14:21:32 -04:00