summaryrefslogtreecommitdiffstats
path: root/adb/adb.c
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2010-08-27 14:35:07 -0700
committerNick Kralevich <nnk@google.com>2010-08-27 14:37:11 -0700
commit44db990d3a4ce0edbdd16fa7ac20693ef601b723 (patch)
tree09fb30b7baa139c643ca2aaee503beebbf2ac6ef /adb/adb.c
parent65e461c478b000246ef81c3ca5fdd2dbb819d7ad (diff)
downloadsystem_core-44db990d3a4ce0edbdd16fa7ac20693ef601b723.zip
system_core-44db990d3a4ce0edbdd16fa7ac20693ef601b723.tar.gz
system_core-44db990d3a4ce0edbdd16fa7ac20693ef601b723.tar.bz2
Fix bug 2950316. Check return values.
Change-Id: I687bb5fb8195d4c1fc863e32a5e233a8b9e74196
Diffstat (limited to 'adb/adb.c')
-rw-r--r--adb/adb.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/adb/adb.c b/adb/adb.c
index 95dc001..d9f96df 100644
--- a/adb/adb.c
+++ b/adb/adb.c
@@ -891,7 +891,9 @@ int adb_main(int is_daemon, int server_port)
struct __user_cap_header_struct header;
struct __user_cap_data_struct cap;
- prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0);
+ if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) != 0) {
+ exit(1);
+ }
/* add extra groups:
** AID_ADB to access the USB driver
@@ -905,11 +907,17 @@ int adb_main(int is_daemon, int server_port)
*/
gid_t groups[] = { AID_ADB, AID_LOG, AID_INPUT, AID_INET, AID_GRAPHICS,
AID_NET_BT, AID_NET_BT_ADMIN, AID_SDCARD_RW, AID_MOUNT };
- setgroups(sizeof(groups)/sizeof(groups[0]), groups);
+ if (setgroups(sizeof(groups)/sizeof(groups[0]), groups) != 0) {
+ exit(1);
+ }
/* then switch user and group to "shell" */
- setgid(AID_SHELL);
- setuid(AID_SHELL);
+ if (setgid(AID_SHELL) != 0) {
+ exit(1);
+ }
+ if (setuid(AID_SHELL) != 0) {
+ exit(1);
+ }
/* set CAP_SYS_BOOT capability, so "adb reboot" will succeed */
header.version = _LINUX_CAPABILITY_VERSION;