out->number_of_parameter = 1;
out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
+ if (out->array_of_parameter == NULL) {
+ D("failed to allocate memory for the parameter\n");
+ return PLUGIN_CMD_FAIL;
+ }
out->array_of_parameter[0].type = type_int32;
out->array_of_parameter[0].v_int32 = PLUGIN_RET_INVALID;
out->number_of_parameter = 1;
out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
+ if (out->array_of_parameter == NULL) {
+ D("failed to allocate memory for the parameter\n");
+ return PLUGIN_CMD_FAIL;
+ }
capability = in->array_of_parameter[0].v_int32;
out->number_of_parameter = 1;
out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
+ if (out->array_of_parameter == NULL) {
+ D("failed to allocate memory for the parameter\n");
+ return PLUGIN_CMD_FAIL;
+ }
out->array_of_parameter[0].type = type_int32;
out->array_of_parameter[0].v_int32 = PLUGIN_RET_VALID;
out->number_of_parameter = 1;
out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
+ if (out->array_of_parameter == NULL) {
+ D("failed to allocate memory for the parameter\n");
+ return PLUGIN_CMD_FAIL;
+ }
make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", in->array_of_parameter[0].v_string.data );
return PLUGIN_CMD_SUCCESS;
out->number_of_parameter = 1;
out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
+ if (out->array_of_parameter == NULL) {
+ D("failed to allocate memory for the parameter\n");
+ return PLUGIN_CMD_FAIL;
+ }
out->array_of_parameter[0].type = type_int32;
out->array_of_parameter[0].v_int32 = PLUGIN_RET_VALID;
out->number_of_parameter = 1;
out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
+ if (out->array_of_parameter == NULL) {
+ D("failed to allocate memory for the parameter\n");
+ return PLUGIN_CMD_FAIL;
+ }
out->array_of_parameter[0].type = type_int32;
out->array_of_parameter[0].v_int32 = PLUGIN_RET_VALID;
out->number_of_parameter = 1;
out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
+ if (out->array_of_parameter == NULL) {
+ D("failed to allocate memory for the parameter\n");
+ return PLUGIN_CMD_FAIL;
+ }
out->array_of_parameter[0].type = type_int32;
if ( verify_root_commands ( in->array_of_parameter[0].v_string.data ) ) {
out->number_of_parameter = 1;
out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
+ if (out->array_of_parameter == NULL) {
+ D("failed to allocate memory for the parameter\n");
+ return PLUGIN_CMD_FAIL;
+ }
make_string_parameter ( & ( out->array_of_parameter[0] ), "%s", "" );
return PLUGIN_CMD_SUCCESS;
out->number_of_parameter = 1;
out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
+ if (out->array_of_parameter == NULL) {
+ out->number_of_parameter = 0;
+ PLUGIN_LOG("failed to allocate memory for the parameter\n");
+ return PLUGIN_CMD_FAIL;
+ }
out->array_of_parameter[0].type = type_int32;
out->array_of_parameter[0].v_int32 = ( plugin_pwlocked() == 1 ) ? PLUGIN_RET_ON : PLUGIN_RET_OFF;
int pwlocked = plugin_pwlocked();
parameters* out = ( parameters* ) malloc ( sizeof ( parameters ) );
+ if (out == NULL) {
+ PLUGIN_LOG("failed to allocate memory for the parameter\n");
+ return;
+ }
out->number_of_parameter = 1;
out->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
+ if (out->array_of_parameter == NULL) {
+ PLUGIN_LOG("failed to allocate memory for the parameter\n");
+ free(out);
+ return;
+ }
out->array_of_parameter[0].type = type_int32;
out->array_of_parameter[0].v_int32 = ( pwlocked == 1 ) ? PLUGIN_RET_ON : PLUGIN_RET_OFF;
ret = default_plugin_async_proc ( cmd, in, out_fd );
}
- release_parameters ( in );
- if ( in != NULL ) {
- free( in );
- }
sdb_close(out_fd);
}
in.number_of_parameter = 1;
in.array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
+ if (in.array_of_parameter == NULL) {
+ D("failed to allocate memory for the parameter\n");
+ return success;
+ }
in.array_of_parameter[0].type = type_int32;
in.array_of_parameter[0].v_int32 = cap;
if ( in_buf != NULL ) {
in.number_of_parameter = 1;
in.array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
+ if (in.array_of_parameter == NULL) {
+ D("failed to allocate memory for the parameter\n");
+ return success;
+ }
in.array_of_parameter[0].type = type_string;
in.array_of_parameter[0].v_string.length = strlen ( in_buf );
in.array_of_parameter[0].v_string.data = strdup ( in_buf );
if ( in_buf != NULL ) {
in.number_of_parameter = 1;
in.array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
+ if (in.array_of_parameter == NULL) {
+ D("failed to allocate memory for the parameter\n");
+ return success;
+ }
in.array_of_parameter[0].type = type_string;
in.array_of_parameter[0].v_string.length = strlen ( in_buf );
in.array_of_parameter[0].v_string.data = strdup ( in_buf );
in.number_of_parameter = 1;
in.array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
+ if (in.array_of_parameter == NULL) {
+ D("failed to allocate memory for the parameter\n");
+ return result;
+ }
in.array_of_parameter[0].type = type_int32;
in.array_of_parameter[0].v_int32 = lock_type;
// return -1 if failed to create async proc thread
int request_appcmd_to_plugin ( const char* in_buf )
{
- parameters* in;
+ parameters in;
int fd;
- in = ( parameters* ) malloc ( sizeof ( parameters ) );
if ( in_buf != NULL ) {
- in->number_of_parameter = 1;
- in->array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
- in->array_of_parameter[0].type = type_string;
- in->array_of_parameter[0].v_string.length = strlen ( in_buf );
- in->array_of_parameter[0].v_string.data = strdup ( in_buf );
+ in.number_of_parameter = 1;
+ in.array_of_parameter = ( parameter* ) malloc ( sizeof ( parameter ) );
+ if (in.array_of_parameter == NULL) {
+ D("failed to allocate memory for the parameter\n");
+ return -1;
+ }
+ in.array_of_parameter[0].type = type_string;
+ in.array_of_parameter[0].v_string.length = strlen ( in_buf );
+ in.array_of_parameter[0].v_string.data = strdup ( in_buf );
} else {
- in->number_of_parameter = 0;
- in->array_of_parameter = NULL;
+ in.number_of_parameter = 0;
+ in.array_of_parameter = NULL;
}
- fd = create_async_proc_thread( PLUGIN_ASYNC_CMD_APPCMD_SERVICE, in );
+ fd = create_async_proc_thread( PLUGIN_ASYNC_CMD_APPCMD_SERVICE, &in );
+ release_parameters ( &in );
return fd;
}
if (pUserID == NULL) {
in.number_of_parameter = 1;
in.array_of_parameter = ( parameter* ) malloc ( sizeof (parameter) );
+ if (in.array_of_parameter == NULL) {
+ D("failed to allocate memory for the parameter\n");
+ return success;
+ }
in.array_of_parameter[0].type = type_int32;
in.array_of_parameter[0].v_int32 = nSessionID;
} else {
in.number_of_parameter = 2;
in.array_of_parameter = ( parameter* ) malloc ( sizeof (parameter) * in.number_of_parameter );
+ if (in.array_of_parameter == NULL) {
+ D("failed to allocate memory for the parameter\n");
+ return success;
+ }
in.array_of_parameter[0].type = type_int32;
in.array_of_parameter[0].v_int32 = nSessionID;
in.array_of_parameter[1].type = type_string;
in.number_of_parameter = 1;
in.array_of_parameter = ( parameter* ) malloc ( sizeof (parameter) );
+ if (in.array_of_parameter == NULL) {
+ D("failed to allocate memory for the parameter\n");
+ return success;
+ }
in.array_of_parameter[0].type = type_int32;
in.array_of_parameter[0].v_int32 = nSessionID;
in.number_of_parameter = 2;
in.array_of_parameter = ( parameter* ) malloc ( sizeof (parameter) * in.number_of_parameter );
+ if (in.array_of_parameter == NULL) {
+ D("failed to allocate memory for the parameter\n");
+ return success;
+ }
in.array_of_parameter[0].type = type_int32;
in.array_of_parameter[0].v_int32 = nSessionID;
in.array_of_parameter[1].type = type_chunk;
in.number_of_parameter = 1;
in.array_of_parameter = ( parameter* ) malloc ( sizeof (parameter) );
+ if (in.array_of_parameter == NULL) {
+ D("failed to allocate memory for the parameter\n");
+ return success;
+ }
in.array_of_parameter[0].type = type_int32;
in.array_of_parameter[0].v_int32 = nSessionID;
in.number_of_parameter = 2;
in.array_of_parameter = ( parameter* ) malloc ( sizeof (parameter) * in.number_of_parameter );
+ if (in.array_of_parameter == NULL) {
+ D("failed to allocate memory for the parameter\n");
+ return success;
+ }
in.array_of_parameter[0].type = type_int32;
in.array_of_parameter[0].v_int32 = nSessionID;
in.array_of_parameter[1].type = type_chunk;
in.number_of_parameter = 1;
in.array_of_parameter = ( parameter* ) malloc ( sizeof (parameter) );
+ if (in.array_of_parameter == NULL) {
+ D("failed to allocate memory for the parameter\n");
+ return success;
+ }
in.array_of_parameter[0].type = type_int32;
in.array_of_parameter[0].v_int32 = nSessionID;
in.number_of_parameter = 2;
in.array_of_parameter = ( parameter* ) malloc ( sizeof (parameter) * in.number_of_parameter );
+ if (in.array_of_parameter == NULL) {
+ D("failed to allocate memory for the parameter\n");
+ return success;
+ }
in.array_of_parameter[0].type = type_int32;
in.array_of_parameter[0].v_int32 = nSessionID;
in.array_of_parameter[1].type = type_chunk;
in.number_of_parameter = 2;
in.array_of_parameter = ( parameter* ) malloc ( sizeof (parameter) * in.number_of_parameter );
+ if (in.array_of_parameter == NULL) {
+ D("failed to allocate memory for the parameter\n");
+ return success;
+ }
in.array_of_parameter[0].type = type_int32;
in.array_of_parameter[0].v_int32 = nSessionID;
in.array_of_parameter[1].type = type_chunk;
D("[ usb_init - using FunctionFS ]\n");
h = calloc(1, sizeof(usb_handle));
+ if (h == NULL) {
+ perror("[ failed to allocate memory for usb FunctionFS bulk device ]\n");
+ return;
+ }
if (autoconfig(h) < 0) {
perror("[ can't recognize usb FunctionFS bulk device ]\n");
free(h);