diff options
author | irungentoo <irungentoo@gmail.com> | 2015-03-12 13:11:28 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2015-03-12 13:11:28 -0400 |
commit | 28d707662b11c120e21697c3f1b208cdf7c6d0b2 (patch) | |
tree | d8444bc65270c4cca650e10ccc798ffd95b21caf | |
parent | 7afab000f70c8a9d8070492fb42fb57bede4a75c (diff) |
Fixed tox_new issue.
-rw-r--r-- | toxcore/tox.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/toxcore/tox.c b/toxcore/tox.c index cc507a65..e99f7a75 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c | |||
@@ -99,6 +99,11 @@ Tox *tox_new(const struct Tox_Options *options, const uint8_t *data, size_t leng | |||
99 | } | 99 | } |
100 | 100 | ||
101 | if (data) { | 101 | if (data) { |
102 | if (length < TOX_ENC_SAVE_MAGIC_LENGTH) { | ||
103 | SET_ERROR_PARAMETER(error, TOX_ERR_NEW_LOAD_BAD_FORMAT); | ||
104 | return NULL; | ||
105 | } | ||
106 | |||
102 | if (memcmp(data, TOX_ENC_SAVE_MAGIC_NUMBER, TOX_ENC_SAVE_MAGIC_LENGTH) == 0) { | 107 | if (memcmp(data, TOX_ENC_SAVE_MAGIC_NUMBER, TOX_ENC_SAVE_MAGIC_LENGTH) == 0) { |
103 | SET_ERROR_PARAMETER(error, TOX_ERR_NEW_LOAD_ENCRYPTED); | 108 | SET_ERROR_PARAMETER(error, TOX_ERR_NEW_LOAD_ENCRYPTED); |
104 | return NULL; | 109 | return NULL; |
@@ -169,7 +174,7 @@ Tox *tox_new(const struct Tox_Options *options, const uint8_t *data, size_t leng | |||
169 | return NULL; | 174 | return NULL; |
170 | } | 175 | } |
171 | 176 | ||
172 | if (messenger_load(m, data, length) == -1) { | 177 | if (data && length && messenger_load(m, data, length) == -1) { |
173 | SET_ERROR_PARAMETER(error, TOX_ERR_NEW_LOAD_BAD_FORMAT); | 178 | SET_ERROR_PARAMETER(error, TOX_ERR_NEW_LOAD_BAD_FORMAT); |
174 | } else { | 179 | } else { |
175 | SET_ERROR_PARAMETER(error, TOX_ERR_NEW_OK); | 180 | SET_ERROR_PARAMETER(error, TOX_ERR_NEW_OK); |