/* * This file is part of libsamsung-ipc. * * Copyright (C) 2011 Simon Busch * Copyright (C) 2014 Paul Kocialkowski * * libsamsung-ipc is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * libsamsung-ipc is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with libsamsung-ipc. If not, see . */ #include #include #include char *ipc_misc_me_imsi_imsi_extract(const void *data, size_t size) { struct ipc_misc_me_imsi_header *header; char *imsi; size_t imsi_length; if (data == NULL || size < sizeof(struct ipc_misc_me_imsi_header)) return NULL; header = (struct ipc_misc_me_imsi_header *) data; // header->length doesn't count the final null character imsi_length = header->length + sizeof(char); imsi = (char *) calloc(1, imsi_length); strncpy(imsi, (char *) data + sizeof(struct ipc_misc_me_imsi_header), header->length); imsi[header->length] = '\0'; return imsi; } // vim:ts=4:sw=4:expandtab