summaryrefslogtreecommitdiff
path: root/debian/patches/random-fixes0009-trans-proxy-defpager-convert-to-trivfs-dynamic-class.patch
blob: 72054805019da549bb12d80203d8573660ff55dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
From fcf89e5bb006f71ecf5c46b7248216c3dee7e4b8 Mon Sep 17 00:00:00 2001
From: Justus Winter <4winter@informatik.uni-hamburg.de>
Date: Sun, 27 Sep 2015 17:23:13 +0200
Subject: [PATCH hurd 09/11] trans/proxy-defpager: convert to trivfs dynamic
 classes and buckets

libtrivfs contains two ways of managing more than one port class and
bucket.  There is the old way of using a statically allocated array
with explicit length, and the new way with dynamically allocated
vectors.

Converting all users to the new way of handling multiple classes
and/or buckets, we can simplify the code in libtrivfs.  In many cases,
the code will be simpler and more expressive for the user.

This also fixes a severe bug.  As no classes are given to
`trivfs_startup', they are created and inserted into the dynamic
vector of classes.  The helper function `allowed', however, used the
first item of the previously used static array, which is NULL.  This
circumvented the typecheck, allowing the default pager protocol to be
spoken over control ports, likely resulting in a crash.

* trans/proxy-defpager.c: Convert to dynamic classes and buckets.
---
 trans/proxy-defpager.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/trans/proxy-defpager.c b/trans/proxy-defpager.c
index 5fe8ffd..662f269 100644
--- a/trans/proxy-defpager.c
+++ b/trans/proxy-defpager.c
@@ -30,11 +30,14 @@
 
 static mach_port_t real_defpager, dev_master;
 
+/* Our port class.  */
+struct port_class *trivfs_protid_class;
+
 static error_t
 allowed (mach_port_t port, int mode)
 {
-  struct trivfs_protid *cred = ports_lookup_port
-    (0, port, trivfs_protid_portclasses[0]);
+  struct trivfs_protid *cred
+    = ports_lookup_port (0, port, trivfs_protid_class);
   if (!cred)
     return MIG_BAD_ID;
   error_t result = (cred->po->openmodes & mode) ? 0 : EACCES;
@@ -266,8 +269,12 @@ main (int argc, char **argv)
 
   trivfs_fsid = getpid ();
 
+  err = trivfs_add_protid_port_class (&trivfs_protid_class);
+  if (err)
+    error (1, 0, "error creating protid port class");
+
   /* Reply to our parent.  */
-  err = trivfs_startup (bootstrap, 0, 0, 0, 0, 0, &fsys);
+  err = trivfs_startup (bootstrap, 0, 0, 0, trivfs_protid_class, 0, &fsys);
   mach_port_deallocate (mach_task_self (), bootstrap);
   if (err)
     error (4, err, "Contacting parent");
-- 
2.1.4