TEST(TEST_NAME, strcpy_chk_max_int_size) { char buf[10]; char* res = __strcpy_chk(buf, "012345678", (size_t)-1); ASSERT_EQ(buf, res); ASSERT_EQ('0', buf[0]); ASSERT_EQ('1', buf[1]); ASSERT_EQ('2', buf[2]); ASSERT_EQ('3', buf[3]); ASSERT_EQ('4', buf[4]); ASSERT_EQ('5', buf[5]); ASSERT_EQ('6', buf[6]); ASSERT_EQ('7', buf[7]); ASSERT_EQ('8', buf[8]); ASSERT_EQ('\0', buf[9]); }
void start_tcp_server() { struct sockaddr_un un, peer_addr; int optval; optval = 1; bExit = 0; if ( hservSocket > 0 ) { if ( btif_trace_level > iLevelMessages ) LogMsg(1283, "[GPS] tcp service is already up\n"); hservSocket = socket(AF_UNIX, SOCK_STREAM, 0); int opt = setsockopt(hservSocket, 1, 2, &optval, 4); if ( btif_trace_level > iLevelMessages ) LogMsg(1283, "[GPS] start unix listening socket %d, set opt = %d\n", hservSocket, opt); un.sun_family = AF_UNIX; __strcpy_chk(un.sun_path, getUnixSocketPath(), 108, optval); unlink(un.sun_path); int ret = bind(hservSocket, (struct sockaddr *)&un, sizeof(struct sockaddr_un)); if (ret != -1 ) { int Result = chown(getUnixSocketPath(), 0xFFFFFFFF, 0xBC0u); if ( btif_trace_level > iLevelMessages ) LogMsg(1283, "[GPS] chown %d\n", Result); Result = chmod(getUnixSocketPath(), 0x1F8u); if ( btif_trace_level > iLevelMessages ) LogMsg(1283, "[GPS] chmod %d\n", Result); if ( socketpair(1, 1, 0, &sockets) < 0 && btif_trace_level > iLevelMessages ) LogMsg(1283, "%s failed", "initCtrlSocekt"); pthread_create(&ServThreadID, NULL, wait_4_command_thread, NULL); if ( btif_trace_level > iLevelMessages ) LogMsg(1283, "tcp listening thread id = %ld\n", ServThreadID); BTM_RegisterForVSEvents(bta_gps_rcv_vse_cback, true); } else if ( btif_trace_level > iLevelMessages ) LogMsg(1283, "tcp bind socket failed \n"); } }