diff options
author | Thomas Bushnell <thomas@gnu.org> | 1999-03-15 20:05:35 +0000 |
---|---|---|
committer | Thomas Bushnell <thomas@gnu.org> | 1999-03-15 20:05:35 +0000 |
commit | d4e55aef9516d2426ade8d35421f12c2eb5ed793 (patch) | |
tree | e3bb152145ce2836984ef02b8c214beabc92ab62 /libtrivfs | |
parent | 98fba1729e7c80fa3b0c7b65d07495631ba213d1 (diff) |
Mon Mar 15 14:36:33 1999 Thomas Bushnell, BSG <tb@mit.edu>
* migsupport.c (trivfs_begin_using_protid): In first branch,
protect work against PI being null, and call ports_port_deref with
the proper value.
(trivfs_begin_using_control): Likewise.
Reported by Mark Kettenis (kettenis@wins.uva.nl).
Diffstat (limited to 'libtrivfs')
-rw-r--r-- | libtrivfs/ChangeLog | 8 | ||||
-rw-r--r-- | libtrivfs/migsupport.c | 42 |
2 files changed, 34 insertions, 16 deletions
diff --git a/libtrivfs/ChangeLog b/libtrivfs/ChangeLog index e2599b56..c2da695e 100644 --- a/libtrivfs/ChangeLog +++ b/libtrivfs/ChangeLog @@ -1,3 +1,11 @@ +Mon Mar 15 14:36:33 1999 Thomas Bushnell, BSG <tb@mit.edu> + + * migsupport.c (trivfs_begin_using_protid): In first branch, + protect work against PI being null, and call ports_port_deref with + the proper value. + (trivfs_begin_using_control): Likewise. + Reported by Mark Kettenis (kettenis@wins.uva.nl). + 1999-02-06 Mark Kettenis <kettenis@gnu.org> * trivfs.h (trivfs_check_access_hook): New variable. diff --git a/libtrivfs/migsupport.c b/libtrivfs/migsupport.c index 14825c18..b2d98e16 100644 --- a/libtrivfs/migsupport.c +++ b/libtrivfs/migsupport.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation + Copyright (C) 1994, 1995, 1996, 1997, 1999 Free Software Foundation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -20,17 +20,22 @@ struct trivfs_protid * trivfs_begin_using_protid (mach_port_t port) { - if (trivfs_protid_nportclasses + trivfs_num_dynamic_protid_port_classes> 1) + if (trivfs_protid_nportclasses + trivfs_num_dynamic_protid_port_classes > 1) { struct port_info *pi = ports_lookup_port (0, port, 0); int i; - for (i = 0; i < trivfs_protid_nportclasses; i++) - if (pi->class == trivfs_protid_portclasses[i]) - return (struct trivfs_protid *) pi; - for (i = 0; i < trivfs_num_dynamic_protid_port_classes; i++) - if (pi->class == trivfs_dynamic_protid_port_classes[i]) - return (struct trivfs_protid *) pi; - ports_port_deref ((void *)port); + + if (pi) + { + for (i = 0; i < trivfs_protid_nportclasses; i++) + if (pi->class == trivfs_protid_portclasses[i]) + return (struct trivfs_protid *) pi; + for (i = 0; i < trivfs_num_dynamic_protid_port_classes; i++) + if (pi->class == trivfs_dynamic_protid_port_classes[i]) + return (struct trivfs_protid *) pi; + ports_port_deref (pi); + } + return 0; } else if (trivfs_protid_nportclasses == 1) @@ -53,13 +58,18 @@ trivfs_begin_using_control (mach_port_t port) { struct port_info *pi = ports_lookup_port (0, port, 0); int i; - for (i = 0; i < trivfs_cntl_nportclasses; i++) - if (pi->class == trivfs_cntl_portclasses[i]) - return (struct trivfs_control *) pi; - for (i = 0; i < trivfs_num_dynamic_control_port_classes; i++) - if (pi->class == trivfs_dynamic_control_port_classes[i]) - return (struct trivfs_control *) pi; - ports_port_deref ((void *)port); + + if (pi) + { + for (i = 0; i < trivfs_cntl_nportclasses; i++) + if (pi->class == trivfs_cntl_portclasses[i]) + return (struct trivfs_control *) pi; + for (i = 0; i < trivfs_num_dynamic_control_port_classes; i++) + if (pi->class == trivfs_dynamic_control_port_classes[i]) + return (struct trivfs_control *) pi; + ports_port_deref (pi); + } + return 0; } else if (trivfs_cntl_nportclasses == 1) |