Refuse dbus message paths longer than BUS_PATH_SIZE_MAX limit.

Even though the dbus specification does not enforce any length limit on the
path of a dbus message, having to analyze too long strings in PID1 may be
time-consuming and it may have security impacts.

In any case, the limit is set so high that real-life applications should not
have a problem with it.
This commit is contained in:
Riccardo Schirone
2019-02-18 20:07:45 +01:00
committed by Lennart Poettering
parent 5f06ba8018
commit 61397a60d9
2 changed files with 5 additions and 1 deletions
+1 -1
View File
@@ -43,7 +43,7 @@ bool object_path_is_valid(const char *p) {
if (slash)
return false;
return true;
return (q - p) <= BUS_PATH_SIZE_MAX;
}
char* object_path_startswith(const char *a, const char *b) {
+4
View File
@@ -332,6 +332,10 @@ struct sd_bus {
#define BUS_MESSAGE_SIZE_MAX (128*1024*1024)
#define BUS_AUTH_SIZE_MAX (64*1024)
/* Note that the D-Bus specification states that bus paths shall have no size limit. We enforce here one
* anyway, since truly unbounded strings are a security problem. The limit we pick is relatively large however,
* to not clash unnecessarily with real-life applications. */
#define BUS_PATH_SIZE_MAX (64*1024)
#define BUS_CONTAINER_DEPTH 128