diff options
| author | LuK1337 <priv.luk@gmail.com> | 2018-03-24 02:01:25 +0100 |
|---|---|---|
| committer | LuK1337 <priv.luk@gmail.com> | 2018-03-24 02:09:50 +0100 |
| commit | 577c65b63cfad793cf1bb9124e43f4731d762d77 (patch) | |
| tree | 3670dc965b51be76da1dcae5420939aac8f8e4a3 | |
| parent | a80c2a5c578f5954d31dce064fe261bb259d2df8 (diff) | |
Fix potential null pointer dereference when dlopen or dlsym fails
| -rw-r--r-- | macaddrsetup.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/macaddrsetup.c b/macaddrsetup.c index 31e9278..0e95f50 100644 --- a/macaddrsetup.c +++ b/macaddrsetup.c @@ -40,11 +40,31 @@ int main(int argc, char **argv) ta_handle = dlopen(LIB_TA, RTLD_NOW); if (!ta_handle) { ALOGE("%s: DLOPEN failed for %s", __func__, LIB_TA); - } else { - ta_open = dlsym(ta_handle, "ta_open"); - ta_close = dlsym(ta_handle, "ta_close"); - ta_getsize = dlsym(ta_handle, "ta_getsize"); - ta_read = dlsym(ta_handle, "ta_read"); + exit(1); + } + + ta_open = dlsym(ta_handle, "ta_open"); + if (!ta_open) { + ALOGE("%s: DLSYM failed for ta_open", __func__); + exit(1); + } + + ta_close = dlsym(ta_handle, "ta_close"); + if (!ta_close) { + ALOGE("%s: DLSYM failed for ta_close", __func__); + exit(1); + } + + ta_getsize = dlsym(ta_handle, "ta_getsize"); + if (!ta_open) { + ALOGE("%s: DLSYM failed for ta_getsize", __func__); + exit(1); + } + + ta_read = dlsym(ta_handle, "ta_read"); + if (!ta_read) { + ALOGE("%s: DLSYM failed for ta_read", __func__); + exit(1); } for (;;) { |
