diff options
Diffstat (limited to 'src/namecache/gnunet-service-namecache.c')
-rw-r--r-- | src/namecache/gnunet-service-namecache.c | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/src/namecache/gnunet-service-namecache.c b/src/namecache/gnunet-service-namecache.c index c08f2aef7..c852aaacc 100644 --- a/src/namecache/gnunet-service-namecache.c +++ b/src/namecache/gnunet-service-namecache.c | |||
@@ -2,20 +2,18 @@ | |||
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2012, 2013 GNUnet e.V. | 3 | Copyright (C) 2012, 2013 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software: you can redistribute it and/or modify it |
6 | it under the terms of the GNU General Public License as published | 6 | under the terms of the GNU Affero General Public License as published |
7 | by the Free Software Foundation; either version 3, or (at your | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with GNUnet; see the file COPYING. If not, write to the | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301, USA. | ||
19 | */ | 17 | */ |
20 | 18 | ||
21 | /** | 19 | /** |
@@ -150,7 +148,11 @@ struct LookupBlockContext | |||
150 | * Operation id for the name lookup | 148 | * Operation id for the name lookup |
151 | */ | 149 | */ |
152 | uint32_t request_id; | 150 | uint32_t request_id; |
153 | 151 | ||
152 | /** | ||
153 | * Lookup status | ||
154 | */ | ||
155 | int status; | ||
154 | }; | 156 | }; |
155 | 157 | ||
156 | 158 | ||
@@ -168,7 +170,17 @@ handle_lookup_block_it (void *cls, | |||
168 | struct GNUNET_MQ_Envelope *env; | 170 | struct GNUNET_MQ_Envelope *env; |
169 | struct LookupBlockResponseMessage *r; | 171 | struct LookupBlockResponseMessage *r; |
170 | size_t esize; | 172 | size_t esize; |
173 | size_t bsize; | ||
171 | 174 | ||
175 | bsize = ntohl (block->purpose.size); | ||
176 | if (bsize < | ||
177 | (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) + sizeof (struct GNUNET_TIME_AbsoluteNBO))) | ||
178 | { | ||
179 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
180 | "Malformed block."); | ||
181 | lnc->status = GNUNET_SYSERR; | ||
182 | return; | ||
183 | } | ||
172 | esize = ntohl (block->purpose.size) | 184 | esize = ntohl (block->purpose.size) |
173 | - sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) | 185 | - sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) |
174 | - sizeof (struct GNUNET_TIME_AbsoluteNBO); | 186 | - sizeof (struct GNUNET_TIME_AbsoluteNBO); |
@@ -211,6 +223,7 @@ handle_lookup_block (void *cls, | |||
211 | 223 | ||
212 | lnc.request_id = ntohl (ln_msg->gns_header.r_id); | 224 | lnc.request_id = ntohl (ln_msg->gns_header.r_id); |
213 | lnc.nc = nc; | 225 | lnc.nc = nc; |
226 | lnc.status = GNUNET_OK; | ||
214 | if (GNUNET_SYSERR == | 227 | if (GNUNET_SYSERR == |
215 | (ret = GSN_database->lookup_block (GSN_database->cls, | 228 | (ret = GSN_database->lookup_block (GSN_database->cls, |
216 | &ln_msg->query, | 229 | &ln_msg->query, |
@@ -224,7 +237,7 @@ handle_lookup_block (void *cls, | |||
224 | GNUNET_SERVICE_client_drop (nc->client); | 237 | GNUNET_SERVICE_client_drop (nc->client); |
225 | return; | 238 | return; |
226 | } | 239 | } |
227 | if (0 == ret) | 240 | if ((0 == ret) || (GNUNET_SYSERR == lnc.status)) |
228 | { | 241 | { |
229 | /* no records match at all, generate empty response */ | 242 | /* no records match at all, generate empty response */ |
230 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 243 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |