Commit 40751c84 authored by Havoc Pennington's avatar Havoc Pennington
Browse files

2003-10-11 Havoc Pennington <hp@pobox.com>

	* dbus/dbus-message.c (_dbus_message_test): add more test
	coverage, but #if 0 for now since they uncover a bug
	not fixed yet; I think in re_align_field_recurse()
	(re_align_field_recurse): add FIXME about broken assertion

	* dbus/dbus-sysdeps.c (_dbus_sysdeps_test): add more test coverage

	* bus/connection.c: share a couple code bits with expirelist.c

	* bus/expirelist.h, bus/expirelist.c: implement a generic
	expire-items-after-N-seconds facility, was going to share between
	expiring connections and replies, decided not to use for expiring
	connections for now.

	* bus/connection.c: add tracking of expected replies

	* COPYING: include AFL 2.0 (still need to change all the file headers)
parent c1f0e189
D-BUS is licensed to you under your choice of the Academic Free
License version 1.2, or the GNU General Public License version 2.
License version 2.0, or the GNU General Public License version 2.
Both licenses are included here. Some of the standalone binaries are
under the GPL only; in particular, but not limited to,
tools/dbus-cleanup-sockets.c and test/decode-gcov.c. Each source code
file is marked with the proper copyright information.
Academic Free License
Version 1.2
This Academic Free License applies to any original work of authorship
(the "Original Work") whose owner (the "Licensor") has placed the
following notice immediately following the copyright notice for the
Original Work:
Licensed under the Academic Free License version 1.2
Grant of License. Licensor hereby grants to any person obtaining a
copy of the Original Work ("You") a world-wide, royalty-free,
non-exclusive, perpetual, non-sublicenseable license (1) to use, copy,
modify, merge, publish, perform, distribute and/or sell copies of the
Original Work and derivative works thereof, and (2) under patent claims
owned or controlled by the Licensor that are embodied in the Original
Work as furnished by the Licensor, to make, use, sell and offer for
sale the Original Work and derivative works thereof, subject to the
following conditions.
Attribution Rights. You must retain, in the Source Code of any
Derivative Works that You create, all copyright, patent or trademark
notices from the Source Code of the Original Work, as well as any
notices of licensing and any descriptive text identified therein as an
"Attribution Notice." You must cause the Source Code for any Derivative
Works that You create to carry a prominent Attribution Notice reasonably
calculated to inform recipients that You have modified the Original Work.
Exclusions from License Grant. Neither the names of Licensor, nor the
names of any contributors to the Original Work, nor any of their
trademarks or service marks, may be used to endorse or promote products
derived from this Original Work without express prior written permission
of the Licensor.
Warranty and Disclaimer of Warranty. Licensor warrants that the copyright
in and to the Original Work is owned by the Licensor or that the Original
Work is distributed by Licensor under a valid current license from the
copyright owner. Except as expressly stated in the immediately proceeding
sentence, the Original Work is provided under this License on an "AS IS"
BASIS and WITHOUT WARRANTY, either express or implied, including, without
limitation, the warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL
WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part
of this License. No license to Original Work is granted hereunder except
under this disclaimer.
Limitation of Liability. Under no circumstances and under no legal theory,
whether in tort (including negligence), contract, or otherwise, shall the
Licensor be liable to any person for any direct, indirect, special,
incidental, or consequential damages of any character arising as a result
of this License or the use of the Original Work including, without
limitation, damages for loss of goodwill, work stoppage, computer failure
or malfunction, or any and all other commercial damages or losses. This
limitation of liability shall not apply to liability for death or personal
injury resulting from Licensor's negligence to the extent applicable law
prohibits such limitation. Some jurisdictions do not allow the exclusion or
limitation of incidental or consequential damages, so this exclusion and
limitation may not apply to You.
License to Source Code. The term "Source Code" means the preferred form of
the Original Work for making modifications to it and all available
documentation describing how to modify the Original Work. Licensor hereby
agrees to provide a machine-readable copy of the Source Code of the Original
Work along with each copy of the Original Work that Licensor distributes.
Licensor reserves the right to satisfy this obligation by placing a
machine-readable copy of the Source Code in an information repository
reasonably calculated to permit inexpensive and convenient access by You for
as long as Licensor continues to distribute the Original Work, and by
publishing the address of that information repository in a notice immediately
The Academic Free License
v. 2.0
This Academic Free License (the "License") applies to any original
work of authorship (the "Original Work") whose owner (the "Licensor")
has placed the following notice immediately following the copyright
notice for the Original Work:
Licensed under the Academic Free License version 2.0
1) Grant of Copyright License. Licensor hereby grants You a
world-wide, royalty-free, non-exclusive, perpetual, sublicenseable
license to do the following:
a) to reproduce the Original Work in copies;
b) to prepare derivative works ("Derivative Works") based upon the Original Work;
c) to distribute copies of the Original Work and Derivative Works to the public;
d) to perform the Original Work publicly; and
e) to display the Original Work publicly.
2) Grant of Patent License. Licensor hereby grants You a world-wide,
royalty-free, non-exclusive, perpetual, sublicenseable license, under
patent claims owned or controlled by the Licensor that are embodied in
the Original Work as furnished by the Licensor, to make, use, sell and
offer for sale the Original Work and Derivative Works.
3) Grant of Source Code License. The term "Source Code" means the
preferred form of the Original Work for making modifications to it and
all available documentation describing how to modify the Original
Work. Licensor hereby agrees to provide a machine-readable copy of
the Source Code of the Original Work along with each copy of the
Original Work that Licensor distributes. Licensor reserves the right
to satisfy this obligation by placing a machine-readable copy of the
Source Code in an information repository reasonably calculated to
permit inexpensive and convenient access by You for as long as
Licensor continues to distribute the Original Work, and by publishing
the address of that information repository in a notice immediately
following the copyright notice that applies to the Original Work.
Mutual Termination for Patent Action. This License shall terminate
automatically and You may no longer exercise any of the rights granted to You
by this License if You file a lawsuit in any court alleging that any OSI
Certified open source software that is licensed under any license containing
this "Mutual Termination for Patent Action" clause infringes any patent
claims that are essential to use that software.
Right to Use. You may use the Original Work in all ways not otherwise
restricted or conditioned by this License or by law, and Licensor promises
not to interfere with or be responsible for such uses by You.
This license is Copyright (C) 2002 Lawrence E. Rosen. All rights reserved.
Permission is hereby granted to copy and distribute this license without
modification. This license may not be modified without the express written
permission of its copyright owner.
4) Exclusions From License Grant. Neither the names of Licensor, nor
the names of any contributors to the Original Work, nor any of their
trademarks or service marks, may be used to endorse or promote
products derived from this Original Work without express prior written
permission of the Licensor. Nothing in this License shall be deemed
to grant any rights to trademarks, copyrights, patents, trade secrets
or any other intellectual property of Licensor except as expressly
stated herein. No patent license is granted to make, use, sell or
offer to sell embodiments of any patent claims other than the licensed
claims defined in Section 2. No right is granted to the trademarks of
Licensor even if such marks are included in the Original Work.
Nothing in this License shall be interpreted to prohibit Licensor from
licensing under different terms from this License any Original Work
that Licensor otherwise would have a right to license.
5) This section intentionally omitted.
6) Attribution Rights. You must retain, in the Source Code of any
Derivative Works that You create, all copyright, patent or trademark
notices from the Source Code of the Original Work, as well as any
notices of licensing and any descriptive text identified therein as an
"Attribution Notice." You must cause the Source Code for any
Derivative Works that You create to carry a prominent Attribution
Notice reasonably calculated to inform recipients that You have
modified the Original Work.
7) Warranty of Provenance and Disclaimer of Warranty. Licensor
warrants that the copyright in and to the Original Work and the patent
rights granted herein by Licensor are owned by the Licensor or are
sublicensed to You under the terms of this License with the permission
of the contributor(s) of those copyrights and patent rights. Except
as expressly stated in the immediately proceeding sentence, the
Original Work is provided under this License on an "AS IS" BASIS and
WITHOUT WARRANTY, either express or implied, including, without
limitation, the warranties of NON-INFRINGEMENT, MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY
OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY
constitutes an essential part of this License. No license to Original
Work is granted hereunder except under this disclaimer.
8) Limitation of Liability. Under no circumstances and under no legal
theory, whether in tort (including negligence), contract, or
otherwise, shall the Licensor be liable to any person for any direct,
indirect, special, incidental, or consequential damages of any
character arising as a result of this License or the use of the
Original Work including, without limitation, damages for loss of
goodwill, work stoppage, computer failure or malfunction, or any and
all other commercial damages or losses. This limitation of liability
shall not apply to liability for death or personal injury resulting
from Licensor's negligence to the extent applicable law prohibits such
limitation. Some jurisdictions do not allow the exclusion or
limitation of incidental or consequential damages, so this exclusion
and limitation may not apply to You.
9) Acceptance and Termination. If You distribute copies of the
Original Work or a Derivative Work, You must make a reasonable effort
under the circumstances to obtain the express assent of recipients to
the terms of this License. Nothing else but this License (or another
written agreement between Licensor and You) grants You permission to
create Derivative Works based upon the Original Work or to exercise
any of the rights granted in Section 1 herein, and any attempt to do
so except under the terms of this License (or another written
agreement between Licensor and You) is expressly prohibited by
U.S. copyright law, the equivalent laws of other countries, and by
international treaty. Therefore, by exercising any of the rights
granted to You in Section 1 herein, You indicate Your acceptance of
this License and all of its terms and conditions.
10) Termination for Patent Action. This License shall terminate
automatically and You may no longer exercise any of the rights granted
to You by this License as of the date You commence an action,
including a cross-claim or counterclaim, for patent infringement (i)
against Licensor with respect to a patent applicable to software or
(ii) against any entity with respect to a patent applicable to the
Original Work (but excluding combinations of the Original Work with
other software or hardware).
11) Jurisdiction, Venue and Governing Law. Any action or suit relating
to this License may be brought only in the courts of a jurisdiction
wherein the Licensor resides or in which Licensor conducts its primary
business, and under the laws of that jurisdiction excluding its
conflict-of-law provisions. The application of the United Nations
Convention on Contracts for the International Sale of Goods is
expressly excluded. Any use of the Original Work outside the scope of
this License or after its termination shall be subject to the
requirements and penalties of the U.S. Copyright Act, 17 U.S.C. \u00a4
101 et seq., the equivalent laws of other countries, and international
treaty. This section shall survive the termination of this License.
12) Attorneys Fees. In any action to enforce the terms of this License
or seeking damages relating thereto, the prevailing party shall be
entitled to recover its costs and expenses, including, without
limitation, reasonable attorneys' fees and costs incurred in
connection with such action, including any appeal of such action.
This section shall survive the termination of this License.
13) Miscellaneous. This License represents the complete agreement
concerning the subject matter hereof. If any provision of this
License is held to be unenforceable, such provision shall be reformed
only to the extent necessary to make it enforceable.
14) Definition of "You" in This License. "You" throughout this
License, whether in upper or lower case, means an individual or a
legal entity exercising rights under, and complying with all of the
terms of, this License. For legal entities, "You" includes any entity
that controls, is controlled by, or is under common control with you.
For purposes of this definition, "control" means (i) the power, direct
or indirect, to cause the direction or management of such entity,
whether by contract or otherwise, or (ii) ownership of fifty percent
(50%) or more of the outstanding shares, or (iii) beneficial ownership
of such entity.
15) Right to Use. You may use the Original Work in all ways not
otherwise restricted or conditioned by this License or by law, and
Licensor promises not to interfere with or be responsible for such
uses by You.
This license is Copyright (C) 2003 Lawrence E. Rosen. All rights
reserved. Permission is hereby granted to copy and distribute this
license without modification. This license may not be modified
without the express written permission of its copyright owner.
--
END OF ACADEMIC FREE LICENSE. The following is intended to describe the essential
......
2003-10-11 Havoc Pennington <hp@pobox.com>
* dbus/dbus-message.c (_dbus_message_test): add more test
coverage, but #if 0 for now since they uncover a bug
not fixed yet; I think in re_align_field_recurse()
(re_align_field_recurse): add FIXME about broken assertion
* dbus/dbus-sysdeps.c (_dbus_sysdeps_test): add more test coverage
* bus/connection.c: share a couple code bits with expirelist.c
* bus/expirelist.h, bus/expirelist.c: implement a generic
expire-items-after-N-seconds facility, was going to share between
expiring connections and replies, decided not to use for expiring
connections for now.
* bus/connection.c: add tracking of expected replies
* COPYING: include AFL 2.0 (still need to change all the file headers)
2003-10-09 Havoc Pennington <hp@redhat.com>
* configure.in: define DBUS_HAVE_GCC33_GCOV if we have
......
......@@ -40,6 +40,8 @@ BUS_SOURCES= \
dispatch.h \
driver.c \
driver.h \
expirelist.c \
expirelist.h \
policy.c \
policy.h \
services.c \
......
......@@ -26,6 +26,7 @@
#include "services.h"
#include "utils.h"
#include "signals.h"
#include "expirelist.h"
#include <dbus/dbus-list.h>
#include <dbus/dbus-hash.h>
#include <dbus/dbus-timeout.h>
......@@ -672,8 +673,9 @@ bus_connections_expire_incomplete (BusConnections *connections)
_dbus_assert (d != NULL);
elapsed = ((double) tv_sec - (double) d->connection_tv_sec) * 1000.0 +
((double) tv_usec - (double) d->connection_tv_usec) / 1000.0;
elapsed = ELAPSED_MILLISECONDS_SINCE (d->connection_tv_sec,
d->connection_tv_usec,
tv_sec, tv_usec);
if (elapsed >= (double) auth_timeout)
{
......@@ -693,25 +695,9 @@ bus_connections_expire_incomplete (BusConnections *connections)
link = next;
}
}
if (next_interval >= 0)
{
_dbus_timeout_set_interval (connections->expire_timeout,
next_interval);
_dbus_timeout_set_enabled (connections->expire_timeout, TRUE);
_dbus_verbose ("Enabled incomplete connections timeout with interval %d, %d incomplete connections\n",
next_interval, connections->n_incomplete);
}
else if (dbus_timeout_get_enabled (connections->expire_timeout))
{
_dbus_timeout_set_enabled (connections->expire_timeout, FALSE);
_dbus_verbose ("Disabled incomplete connections timeout, %d incomplete connections\n",
connections->n_incomplete);
}
else
_dbus_verbose ("No need to disable incomplete connections timeout\n");
bus_expire_timeout_set_interval (connections->expire_timeout,
next_interval);
}
static dbus_bool_t
......
......@@ -76,6 +76,12 @@ main (int argc, char **argv)
if (!_dbus_threads_init_debug ())
die ("initializing debug threads");
#endif
printf ("%s: Running expire list test\n", argv[0]);
if (!bus_expire_list_test (&test_data_dir))
die ("expire list");
check_memleaks (argv[0]);
printf ("%s: Running config file parser test\n", argv[0]);
if (!bus_config_parser_test (&test_data_dir))
......
......@@ -37,6 +37,7 @@ dbus_bool_t bus_dispatch_sha1_test (const DBusString *test_data_d
dbus_bool_t bus_policy_test (const DBusString *test_data_dir);
dbus_bool_t bus_config_parser_test (const DBusString *test_data_dir);
dbus_bool_t bus_signals_test (const DBusString *test_data_dir);
dbus_bool_t bus_expire_list_test (const DBusString *test_data_dir);
dbus_bool_t bus_setup_debug_client (DBusConnection *connection);
void bus_test_clients_foreach (BusConnectionForeachFunction function,
void *data);
......
......@@ -489,6 +489,9 @@ re_align_field_recurse (DBusMessage *message,
case DBUS_TYPE_NAMED:
case DBUS_TYPE_ARRAY:
case DBUS_TYPE_DICT:
/* FIXME This is no good; we have to handle undefined header fields
* also. SECURITY and spec compliance issue.
*/
_dbus_assert_not_reached ("no defined header fields may contain a named, array or dict value");
break;
case DBUS_TYPE_INVALID:
......@@ -540,7 +543,7 @@ re_align_field_recurse (DBusMessage *message,
/* this must succeed because it was allocated on function entry and
* DBusString doesn't ever realloc smaller
*/
_dbus_string_insert_bytes (&message->header, pos, -delta, 0);
_dbus_string_insert_bytes (&message->header, pos, -delta, 0);
}
return FALSE;
......@@ -729,7 +732,7 @@ set_string_field (DBusMessage *message,
len = strlen (old_value);
_dbus_string_init_const_len (&v, old_value,
len + 1); /* include nul */
len + 1); /* include nul */
if (!_dbus_marshal_set_string (&message->header,
message->byte_order,
offset, &v, len))
......@@ -741,7 +744,7 @@ set_string_field (DBusMessage *message,
}
dbus_free (old_value);
return TRUE;
failed:
......@@ -6553,12 +6556,16 @@ _dbus_message_test (const char *test_data_dir)
_dbus_assert (dbus_message_has_destination (message, "org.freedesktop.DBus.TestService"));
_dbus_assert (dbus_message_is_method_call (message, "Foo.TestInterface",
"TestMethod"));
_dbus_assert (strcmp (dbus_message_get_path (message),
"/org/freedesktop/TestPath") == 0);
_dbus_message_set_serial (message, 1234);
/* string length including nul byte not a multiple of 4 */
dbus_message_set_sender (message, "org.foo.bar1");
if (!dbus_message_set_sender (message, "org.foo.bar1"))
_dbus_assert_not_reached ("out of memory");
_dbus_assert (dbus_message_has_sender (message, "org.foo.bar1"));
dbus_message_set_reply_serial (message, 5678);
dbus_message_set_sender (message, NULL);
if (!dbus_message_set_sender (message, NULL))
_dbus_assert_not_reached ("out of memory");
_dbus_assert (!dbus_message_has_sender (message, "org.foo.bar1"));
_dbus_assert (dbus_message_get_serial (message) == 1234);
_dbus_assert (dbus_message_get_reply_serial (message) == 5678);
......@@ -6569,6 +6576,58 @@ _dbus_message_test (const char *test_data_dir)
_dbus_assert (dbus_message_get_no_reply (message) == TRUE);
dbus_message_set_no_reply (message, FALSE);
_dbus_assert (dbus_message_get_no_reply (message) == FALSE);
#if 0
/* Set/get some header fields */
if (!dbus_message_set_path (message, "/foo"))
_dbus_assert_not_reached ("out of memory");
_dbus_assert (strcmp (dbus_message_get_path (message),
"/foo") == 0);
if (!dbus_message_set_interface (message, "org.Foo"))
_dbus_assert_not_reached ("out of memory");
_dbus_assert (strcmp (dbus_message_get_interface (message),
"org.Foo") == 0);
if (!dbus_message_set_member (message, "Bar"))
_dbus_assert_not_reached ("out of memory");
_dbus_assert (strcmp (dbus_message_get_member (message),
"Bar") == 0);
/* Set/get them with longer values */
if (!dbus_message_set_path (message, "/foo/bar"))
_dbus_assert_not_reached ("out of memory");
_dbus_assert (strcmp (dbus_message_get_path (message),
"/foo/bar") == 0);
if (!dbus_message_set_interface (message, "org.Foo.Bar"))
_dbus_assert_not_reached ("out of memory");
_dbus_assert (strcmp (dbus_message_get_interface (message),
"org.Foo.Bar") == 0);
if (!dbus_message_set_member (message, "BarFoo"))
_dbus_assert_not_reached ("out of memory");
_dbus_assert (strcmp (dbus_message_get_member (message),
"BarFoo") == 0);
/* Realloc shorter again */
if (!dbus_message_set_path (message, "/foo"))
_dbus_assert_not_reached ("out of memory");
_dbus_assert (strcmp (dbus_message_get_path (message),
"/foo") == 0);
if (!dbus_message_set_interface (message, "org.Foo"))
_dbus_assert_not_reached ("out of memory");
_dbus_assert (strcmp (dbus_message_get_interface (message),
"org.Foo") == 0);
if (!dbus_message_set_member (message, "Bar"))
_dbus_assert_not_reached ("out of memory");
_dbus_assert (strcmp (dbus_message_get_member (message),
"Bar") == 0);
#endif
dbus_message_unref (message);
......
......@@ -3381,6 +3381,24 @@ _dbus_sysdeps_test (void)
exit (1);
}
_dbus_string_init_const (&str, "0xff");
if (!_dbus_string_parse_double (&str,
0, &val, &pos))
{
_dbus_warn ("Failed to parse double");
exit (1);
}
if (val != 0xff)
{
_dbus_warn ("Failed to parse 0xff correctly, got: %f", val);
exit (1);
}
if (pos != 4)
{
_dbus_warn ("_dbus_string_parse_double of \"0xff\" returned wrong position %d", pos);
exit (1);
}
check_path_absolute ("/", TRUE);
check_path_absolute ("/foo", TRUE);
check_path_absolute ("", FALSE);
......
- Message matching rules (so broadcasts can be filtered) need sorting
out.
- How we will handle DCOP needs sorting out. Among other things, we
need to check that service and service-ownership semantics map to DCOP
reasonably well.
......@@ -93,3 +90,6 @@
- add dbus_message_has_path(), maybe has_member/interface
- The OBJECT_PATH type is not documented in the spec.
- re_align_field_recurse() in dbus-message.c is broken because it
crashes on some types of header field values. security problem.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment