|
| 1 | +/* |
| 2 | + * Copyright (C) 2020 The Android Open Source Project |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +#undef NDEBUG |
| 18 | + |
| 19 | +#include <assert.h> |
| 20 | +#include <log/log.h> |
| 21 | +#include <stdlib.h> |
| 22 | +#include <trusty/fuzz/utils.h> |
| 23 | +#include <unistd.h> |
| 24 | + |
| 25 | +using android::trusty::fuzz::TrustyApp; |
| 26 | + |
| 27 | +#define TIPC_DEV "/dev/trusty-ipc-dev0" |
| 28 | +#define CONFIRMATIONUI_PORT "com.android.trusty.confirmationui" |
| 29 | + |
| 30 | +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { |
| 31 | + static uint8_t buf[TIPC_MAX_MSG_SIZE]; |
| 32 | + |
| 33 | + TrustyApp ta(TIPC_DEV, CONFIRMATIONUI_PORT); |
| 34 | + auto ret = ta.Connect(); |
| 35 | + if (!ret.ok()) { |
| 36 | + android::trusty::fuzz::Abort(); |
| 37 | + } |
| 38 | + |
| 39 | + /* Send message to confirmationui server */ |
| 40 | + ret = ta.Write(data, size); |
| 41 | + if (!ret.ok()) { |
| 42 | + return -1; |
| 43 | + } |
| 44 | + |
| 45 | + /* Read message from confirmationui server */ |
| 46 | + ret = ta.Read(&buf, sizeof(buf)); |
| 47 | + if (!ret.ok()) { |
| 48 | + return -1; |
| 49 | + } |
| 50 | + |
| 51 | + return 0; |
| 52 | +} |
0 commit comments