This file is part of GNUnet.
Copyright (C) 2001-2016 GNUnet e.V.
- GNUnet 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 3, or (at your
- option) any later version.
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
GNUnet 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.
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
- You should have received a copy of the GNU General Public License
- along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
+ SPDX-License-Identifier: AGPL3.0-or-later
*/
/**
{
unsigned int *cnt = cls;
+ (void) address;
+ (void) expiration;
(*cnt)++;
return GNUNET_OK;
}
const struct GNUNET_HELLO_Message *hello;
struct GNUNET_HELLO_Message *hello_clean;
size_t read_pos;
- int size_hello;
+ uint16_t size_hello;
r->friend_only_hello = NULL;
r->hello = NULL;
"Read %d bytes from `%s'\n",
(int) size_total,
fn);
- if (size_total < sizeof (struct GNUNET_MessageHeader))
+ if ( (size_total < 0) ||
+ (((size_t) size_total) < sizeof (struct GNUNET_MessageHeader)) )
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Failed to parse HELLO in file `%s': %s\n"),
}
read_pos = 0;
- while (read_pos < size_total)
+ while (read_pos < (size_t) size_total)
{
hello = (const struct GNUNET_HELLO_Message *) &buffer[read_pos];
size_hello = GNUNET_HELLO_size (hello);
if ( (0 == size_hello) ||
- (size_total - read_pos < size_hello) )
+ (((size_t) size_total) - read_pos < size_hello) )
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Failed to parse HELLO in file `%s'\n"),
if (GNUNET_OK !=
GNUNET_HELLO_get_id (r.friend_only_hello,
&id_friend))
+ {
if (GNUNET_YES == dsc->remove_files)
- {
remove_garbage (fullname);
- return GNUNET_OK;
- }
+ return GNUNET_OK;
+ }
id = id_friend;
}
if (NULL != r.hello)
if (GNUNET_OK !=
GNUNET_HELLO_get_id (r.hello,
&id_public))
+ {
if (GNUNET_YES == dsc->remove_files)
- {
remove_garbage (fullname);
- return GNUNET_OK;
- }
+ return GNUNET_OK;
+ }
id = id_public;
}
static unsigned int retries;
struct DirScanContext dsc;
+ (void) cls;
cron_scan = NULL;
if (GNUNET_SYSERR ==
GNUNET_DISK_directory_create (networkIdDirectory))
int friend_hello_type;
int store_hello;
int store_friend_hello;
- int pos;
+ unsigned int pos;
char *buffer;
host = GNUNET_CONTAINER_multipeermap_get (hostmap, peer);
if (GNUNET_YES == store_friend_hello)
{
GNUNET_memcpy (&buffer[pos],
- host->friend_only_hello,
- GNUNET_HELLO_size (host->friend_only_hello));
+ host->friend_only_hello,
+ GNUNET_HELLO_size (host->friend_only_hello));
pos += GNUNET_HELLO_size (host->friend_only_hello);
}
GNUNET_assert (pos == size);
int write_pos;
unsigned int cnt;
char *writebuffer;
+ uint64_t fsize;
+
+ if (GNUNET_OK !=
+ GNUNET_DISK_file_size (fn,
+ &fsize,
+ GNUNET_YES,
+ GNUNET_YES))
+ {
+ GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING |
+ GNUNET_ERROR_TYPE_BULK,
+ "fstat",
+ fn);
+ return GNUNET_OK;
+ }
+ read_size = GNUNET_DISK_fn_read (fn,
+ buffer,
+ sizeof (buffer));
- read_size = GNUNET_DISK_fn_read (fn, buffer, sizeof (buffer));
- if (read_size < (int) sizeof (struct GNUNET_MessageHeader))
+ if ( (read_size < (int) sizeof (struct GNUNET_MessageHeader)) ||
+ (fsize > GNUNET_MAX_MESSAGE_SIZE) )
{
if (0 != UNLINK (fn))
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING |
- GNUNET_ERROR_TYPE_BULK, "unlink", fn);
+ GNUNET_ERROR_TYPE_BULK,
+ "unlink",
+ fn);
return GNUNET_OK;
}
{
struct GNUNET_TIME_Absolute now;
+ (void) cls;
cron_clean = NULL;
now = GNUNET_TIME_absolute_get ();
GNUNET_log (GNUNET_ERROR_TYPE_INFO | GNUNET_ERROR_TYPE_BULK,
{
struct GNUNET_PeerIdentity pid;
+ (void) cls;
if (GNUNET_OK !=
GNUNET_HELLO_get_id (hello,
&pid))
struct GNUNET_SERVICE_Client *client = cls;
struct GNUNET_PeerIdentity pid;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "HELLO message received for peer `%s'\n",
- GNUNET_i2s (&pid));
GNUNET_assert (GNUNET_OK ==
GNUNET_HELLO_get_id (hello,
&pid));
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "HELLO message received for peer `%s'\n",
+ GNUNET_i2s (&pid));
add_host_to_known_hosts (&pid);
update_hello (&pid,
hello);
struct GNUNET_SERVICE_Client *client,
struct GNUNET_MQ_Handle *mq)
{
+ (void) cls;
+ (void) mq;
return client;
}
struct GNUNET_SERVICE_Client *client,
void *app_ctx)
{
+ (void) cls;
GNUNET_assert (app_ctx == client);
}
{
struct HostEntry *he = value;
+ (void) cls;
+ (void) key;
GNUNET_free_non_null (he->hello);
GNUNET_free_non_null (he->friend_only_hello);
GNUNET_free (he);
static void
shutdown_task (void *cls)
{
+ (void) cls;
GNUNET_notification_context_destroy (notify_list);
notify_list = NULL;
GNUNET_notification_context_destroy (notify_friend_only_list);
int noio;
int use_included;
+ (void) cls;
+ (void) service;
hostmap
= GNUNET_CONTAINER_multipeermap_create (1024,
GNUNET_YES);