mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-18 03:28:07 +00:00
Some invalid read fixes
This commit is contained in:
parent
dbdbeaa46f
commit
1024c1942b
3 changed files with 12 additions and 6 deletions
|
|
@ -122,7 +122,7 @@ const char * linphone_content_get_name(const LinphoneContent *content) {
|
|||
const LinphonePrivate::FileContent *fc = static_cast<const LinphonePrivate::FileContent *>(c);
|
||||
if (content->name) ms_free(content->name);
|
||||
content->name = ms_strdup(L_STRING_TO_C(fc->getFileName()));
|
||||
} else if (c->getContentType() == LinphonePrivate::ContentType::FileTransfer) {
|
||||
} else if (c->isFileTransfer()) {
|
||||
const LinphonePrivate::FileTransferContent *ftc = static_cast<const LinphonePrivate::FileTransferContent *>(c);
|
||||
if (content->name) ms_free(content->name);
|
||||
content->name = ms_strdup(L_STRING_TO_C(ftc->getFileName()));
|
||||
|
|
@ -135,7 +135,7 @@ void linphone_content_set_name(LinphoneContent *content, const char *name) {
|
|||
if (c->isFile()) {
|
||||
LinphonePrivate::FileContent *fc = static_cast<LinphonePrivate::FileContent *>(c);
|
||||
fc->setFileName(L_C_TO_STRING(name));
|
||||
} else if (c->getContentType() == LinphonePrivate::ContentType::FileTransfer) {
|
||||
} else if (c->isFileTransfer()) {
|
||||
LinphonePrivate::FileTransferContent *ftc = static_cast<LinphonePrivate::FileTransferContent *>(c);
|
||||
ftc->setFileName(L_C_TO_STRING(name));
|
||||
}
|
||||
|
|
@ -166,7 +166,7 @@ const char * linphone_content_get_custom_header(const LinphoneContent *content,
|
|||
|
||||
const char *linphone_content_get_key(const LinphoneContent *content) {
|
||||
const LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content);
|
||||
if (c->getContentType() == LinphonePrivate::ContentType::FileTransfer) {
|
||||
if (c->isFileTransfer()) {
|
||||
const LinphonePrivate::FileTransferContent *ftc = static_cast<const LinphonePrivate::FileTransferContent *>(c);
|
||||
return ftc->getFileKeyAsString();
|
||||
}
|
||||
|
|
@ -175,16 +175,16 @@ const char *linphone_content_get_key(const LinphoneContent *content) {
|
|||
|
||||
size_t linphone_content_get_key_size(const LinphoneContent *content) {
|
||||
const LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content);
|
||||
if (c->getContentType() == LinphonePrivate::ContentType::FileTransfer) {
|
||||
if (c->isFileTransfer()) {
|
||||
const LinphonePrivate::FileTransferContent *ftc = static_cast<const LinphonePrivate::FileTransferContent *>(c);
|
||||
return ftc->getFileKey().size();
|
||||
return ftc->getFileKeySize();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void linphone_content_set_key(LinphoneContent *content, const char *key, const size_t keyLength) {
|
||||
LinphonePrivate::Content *c = L_GET_CPP_PTR_FROM_C_OBJECT(content);
|
||||
if (c->getContentType() == LinphonePrivate::ContentType::FileTransfer) {
|
||||
if (c->isFileTransfer()) {
|
||||
LinphonePrivate::FileTransferContent *ftc = static_cast<LinphonePrivate::FileTransferContent *>(c);
|
||||
ftc->setFileKey(key, keyLength);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -166,6 +166,11 @@ const char *FileTransferContent::getFileKeyAsString() const {
|
|||
return d->fileKey.data();
|
||||
}
|
||||
|
||||
size_t FileTransferContent::getFileKeySize() const {
|
||||
L_D();
|
||||
return d->fileKey.size();
|
||||
}
|
||||
|
||||
bool FileTransferContent::isFile () const {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ public:
|
|||
void setFileKey (const char *key, size_t size);
|
||||
const std::vector<char> &getFileKey () const;
|
||||
const char *getFileKeyAsString () const;
|
||||
size_t getFileKeySize() const;
|
||||
|
||||
bool isFile () const override;
|
||||
bool isFileTransfer () const override;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue