diff options
Diffstat (limited to 'src/gnsrecord/gnsrecord_serialization.c')
-rw-r--r-- | src/gnsrecord/gnsrecord_serialization.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/gnsrecord/gnsrecord_serialization.c b/src/gnsrecord/gnsrecord_serialization.c index 56521945d..1db27464f 100644 --- a/src/gnsrecord/gnsrecord_serialization.c +++ b/src/gnsrecord/gnsrecord_serialization.c | |||
@@ -127,17 +127,38 @@ GNUNET_GNSRECORD_records_serialize (unsigned int rd_count, | |||
127 | rec.record_type = htonl (rd[i].record_type); | 127 | rec.record_type = htonl (rd[i].record_type); |
128 | rec.flags = htonl (rd[i].flags); | 128 | rec.flags = htonl (rd[i].flags); |
129 | if (off + sizeof (rec) > dest_size) | 129 | if (off + sizeof (rec) > dest_size) |
130 | { | ||
131 | GNUNET_break (0); | ||
130 | return -1; | 132 | return -1; |
133 | } | ||
131 | GNUNET_memcpy (&dest[off], | 134 | GNUNET_memcpy (&dest[off], |
132 | &rec, | 135 | &rec, |
133 | sizeof (rec)); | 136 | sizeof (rec)); |
134 | off += sizeof (rec); | 137 | off += sizeof (rec); |
135 | if (off + rd[i].data_size > dest_size) | 138 | if (off + rd[i].data_size > dest_size) |
139 | { | ||
140 | GNUNET_break (0); | ||
136 | return -1; | 141 | return -1; |
142 | } | ||
137 | GNUNET_memcpy (&dest[off], | 143 | GNUNET_memcpy (&dest[off], |
138 | rd[i].data, | 144 | rd[i].data, |
139 | rd[i].data_size); | 145 | rd[i].data_size); |
140 | off += rd[i].data_size; | 146 | off += rd[i].data_size; |
147 | #if GNUNET_EXTRA_LOGGING | ||
148 | { | ||
149 | char *str; | ||
150 | |||
151 | str = GNUNET_GNSRECORD_value_to_string (rd[i].record_type, | ||
152 | rd[i].data, | ||
153 | rd[i].data_size); | ||
154 | if (NULL == str) | ||
155 | { | ||
156 | GNUNET_break_op (0); | ||
157 | return GNUNET_SYSERR; | ||
158 | } | ||
159 | GNUNET_free (str); | ||
160 | } | ||
161 | #endif | ||
141 | } | 162 | } |
142 | return off; | 163 | return off; |
143 | } | 164 | } |
@@ -165,7 +186,10 @@ GNUNET_GNSRECORD_records_deserialize (size_t len, | |||
165 | for (unsigned int i=0;i<rd_count;i++) | 186 | for (unsigned int i=0;i<rd_count;i++) |
166 | { | 187 | { |
167 | if (off + sizeof (rec) > len) | 188 | if (off + sizeof (rec) > len) |
189 | { | ||
190 | GNUNET_break_op (0); | ||
168 | return GNUNET_SYSERR; | 191 | return GNUNET_SYSERR; |
192 | } | ||
169 | GNUNET_memcpy (&rec, | 193 | GNUNET_memcpy (&rec, |
170 | &src[off], | 194 | &src[off], |
171 | sizeof (rec)); | 195 | sizeof (rec)); |
@@ -175,9 +199,27 @@ GNUNET_GNSRECORD_records_deserialize (size_t len, | |||
175 | dest[i].flags = ntohl (rec.flags); | 199 | dest[i].flags = ntohl (rec.flags); |
176 | off += sizeof (rec); | 200 | off += sizeof (rec); |
177 | if (off + dest[i].data_size > len) | 201 | if (off + dest[i].data_size > len) |
202 | { | ||
203 | GNUNET_break_op (0); | ||
178 | return GNUNET_SYSERR; | 204 | return GNUNET_SYSERR; |
205 | } | ||
179 | dest[i].data = &src[off]; | 206 | dest[i].data = &src[off]; |
180 | off += dest[i].data_size; | 207 | off += dest[i].data_size; |
208 | #if GNUNET_EXTRA_LOGGING | ||
209 | { | ||
210 | char *str; | ||
211 | |||
212 | str = GNUNET_GNSRECORD_value_to_string (dest[i].record_type, | ||
213 | dest[i].data, | ||
214 | dest[i].data_size); | ||
215 | if (NULL == str) | ||
216 | { | ||
217 | GNUNET_break_op (0); | ||
218 | return GNUNET_SYSERR; | ||
219 | } | ||
220 | GNUNET_free (str); | ||
221 | } | ||
222 | #endif | ||
181 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 223 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
182 | "Deserialized record %u with flags %d and expiration time %llu\n", | 224 | "Deserialized record %u with flags %d and expiration time %llu\n", |
183 | i, | 225 | i, |