{
const char *pos = (const char *) &lres[1];
uint16_t rcount = ntohs (lres->count);
- uint16_t msize = ntohs (lres->arm_msg.header.size);
+ uint16_t msize = ntohs (lres->arm_msg.header.size) - sizeof (*lres);
uint16_t size_check;
size_check = 0;
uint16_t rcount = ntohs (lres->count);
const char *list[rcount];
const char *pos = (const char *) &lres[1];
- uint16_t msize = ntohs (lres->arm_msg.header.size);
+ uint16_t msize = ntohs (lres->arm_msg.header.size) - sizeof (*lres);
struct GNUNET_ARM_Operation *op;
uint16_t size_check;
uint64_t id;
}
else
{
- mlt->total_throughput_send = 0;
+ mlt->total_throughput_recv = 0;
//mlt->total_throughput_recv = prev_log_mlt->total_throughput_recv; /* no msgs received */
}
}
return e;
}
+
static void
free_experiment (struct Experiment *e)
{
GNUNET_free (e);
}
+
static int
-load_episode (struct Experiment *e, struct Episode *cur,
- struct GNUNET_CONFIGURATION_Handle *cfg)
+load_episode (struct Experiment *e,
+ struct Episode *cur,
+ struct GNUNET_CONFIGURATION_Handle *cfg)
{
struct GNUNET_ATS_TEST_Operation *o;
char *sec_name;
}
if (o->dest_id > (e->num_slaves - 1))
{
- fprintf (stderr, "Invalid destination %llu in operation %u `%s' in episode %u\n",
- o->dest_id, op_counter, op, cur->id);
+ fprintf (stderr,
+ "Invalid destination %llu in operation %u `%s' in episode %u\n",
+ o->dest_id,
+ op_counter,
+ op,
+ cur->id);
GNUNET_free (op);
GNUNET_free (op_name);
GNUNET_free (sec_name);
GNUNET_free (op_name);
GNUNET_asprintf(&op_name, "op-%u-type", op_counter);
- if ( (GNUNET_SYSERR != GNUNET_CONFIGURATION_get_value_string(cfg,
- sec_name, op_name, &type)) &&
- ((STOP_SEND != o->type) || (STOP_PREFERENCE != o->type)))
+ if ( (GNUNET_SYSERR !=
+ GNUNET_CONFIGURATION_get_value_string(cfg,
+ sec_name,
+ op_name,
+ &type)) &&
+ (STOP_SEND != o->type) &&
+ (STOP_PREFERENCE != o->type) )
{
/* Load arguments for set_rate, start_send, set_preference */
if (0 == strcmp (type, "constant"))
/* Get max rate */
GNUNET_asprintf(&op_name, "op-%u-max-rate", op_counter);
- if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg,
- sec_name, op_name, &o->max_rate))
+ if (GNUNET_SYSERR ==
+ GNUNET_CONFIGURATION_get_value_number (cfg,
+ sec_name,
+ op_name,
+ &o->max_rate))
{
if ((GNUNET_ATS_TEST_TG_LINEAR == o->gen_type) ||
(GNUNET_ATS_TEST_TG_RANDOM == o->gen_type) ||
if (GNUNET_YES == ipv6_enabled)
{
+ ipv6addr = NULL;
if ( (GNUNET_SYSERR ==
- GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV6ADDR",
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ "exit",
+ "IPV6ADDR",
&ipv6addr) ||
(1 != inet_pton (AF_INET6, ipv6addr, &exit_ipv6addr))) )
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "EXIT", "IPV6ADDR");
GNUNET_SCHEDULER_shutdown ();
+ GNUNET_free_non_null (ipv6addr);
return;
}
exit_argv[3] = ipv6addr;
}
if (GNUNET_YES == ipv4_enabled)
{
+ ipv4addr = NULL;
if ( (GNUNET_SYSERR ==
GNUNET_CONFIGURATION_get_value_string (cfg, "exit", "IPV4ADDR",
&ipv4addr) ||
{
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, "EXIT", "IPV4ADDR");
GNUNET_SCHEDULER_shutdown ();
+ GNUNET_free_non_null (ipv4addr);
return;
}
exit_argv[5] = ipv4addr;
SOCKS5_SOCKET_WITH_MHD,
/**
- * We've finished receiving upload data from MHD.
+ * We've started receiving upload data from MHD.
*/
SOCKS5_SOCKET_UPLOAD_STARTED,
"Completed CURL UPLOAD\n");
return 0; /* upload finished, can now download */
}
- if ( (SOCKS5_SOCKET_UPLOAD_STARTED != s5r->state) ||
+ if ( (SOCKS5_SOCKET_UPLOAD_STARTED != s5r->state) &&
(SOCKS5_SOCKET_UPLOAD_DONE != s5r->state) )
{
GNUNET_break (0);
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("Error converting GNS response to DNS response!\n"));
+ if (GNUNET_NO == ret)
+ GNUNET_free (buf);
}
else
{
/* expand authority chain */
ac = GNUNET_new (struct AuthorityChain);
ac->rh = rh;
+ GNUNET_assert (strlen (rh->g2dc->ns) <= GNUNET_DNSPARSER_MAX_NAME_LENGTH);
strcpy (ac->authority_info.dns_authority.name,
rh->g2dc->ns);
memcpy (&ac->authority_info.dns_authority.dns_ip,
/* We have a shadow record */
if (0 != (rd[c2].flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
{
- rt_shadow.rel_value_us = rd[2].expiration_time;
+ rt_shadow.rel_value_us = rd[c2].expiration_time;
at_shadow = GNUNET_TIME_relative_to_absolute (rt_shadow);
}
else
/**
* Extract results from a query result according to the given specification.
- * If colums are NULL, the destination is not modified, and #GNUNET_NO
- * is returned.
*
* @param result result to process
* @param[in,out] rs result specification to extract for
* @param row row from the result to extract
* @return
* #GNUNET_YES if all results could be extracted
- * #GNUNET_NO if at least one result was NULL
* #GNUNET_SYSERR if a result was invalid (non-existing field)
*/
int
sqlite3_finalize (plugin->iterate_all_zones);
if (NULL != plugin->zone_to_name)
sqlite3_finalize (plugin->zone_to_name);
- if (NULL != plugin->zone_to_name)
+ if (NULL != plugin->lookup_label)
sqlite3_finalize (plugin->lookup_label);
result = sqlite3_close (plugin->dbh);
if (result == SQLITE_BUSY)
char *hostkey_file;
GNUNET_assert (nsh == cls);
- if (NULL != zone)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Expected empty zone but received zone private key\n"));
+ if (NULL != zone)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Expected empty zone but received zone private key\n"));
GNUNET_break (0);
if (endbadly_task != NULL)
- GNUNET_SCHEDULER_cancel (endbadly_task);
+ GNUNET_SCHEDULER_cancel (endbadly_task);
endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
return;
- }
- if ((NULL != label) || (NULL != rd) || (0 != rd))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- _("Expected no zone content but received data\n"));
+ }
+ if ((NULL != label) || (NULL != rd) || (0 != rd_count))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Expected no zone content but received data\n"));
GNUNET_break (0);
if (endbadly_task != NULL)
- GNUNET_SCHEDULER_cancel (endbadly_task);
+ GNUNET_SCHEDULER_cancel (endbadly_task);
endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
return;
- }
-
+ }
zi = NULL;
GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR,
GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start),
GNUNET_YES));
GAUGER ("NSE", "Proof-of-work hashing",
- 1024 / (1 +
+ 1024LL / (1LL +
GNUNET_TIME_absolute_get_duration
(start).rel_value_us / 1000LL), "hashes/ms");
return 0;
struct ReadHostFileContext *r)
{
char buffer[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1] GNUNET_ALIGN;
- unsigned int size_total;
+ ssize_t size_total;
struct GNUNET_TIME_Absolute now;
unsigned int left;
const struct GNUNET_HELLO_Message *hello;
struct GNUNET_HELLO_Message *hello_clean;
- unsigned read_pos;
+ size_t read_pos;
int size_hello;
r->friend_only_hello = NULL;
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING |
GNUNET_ERROR_TYPE_BULK,
"unlink", fn);
+ GNUNET_free (writebuffer);
return GNUNET_OK;
}
new_hello = GNUNET_HELLO_iterate_addresses (hello,
if (0 < write_pos)
{
- GNUNET_DISK_fn_write (fn, writebuffer,write_pos,
- GNUNET_DISK_PERM_USER_READ |
- GNUNET_DISK_PERM_USER_WRITE |
- GNUNET_DISK_PERM_GROUP_READ |
- GNUNET_DISK_PERM_OTHER_READ);
+ GNUNET_DISK_fn_write (fn,
+ writebuffer,
+ write_pos,
+ GNUNET_DISK_PERM_USER_READ |
+ GNUNET_DISK_PERM_USER_WRITE |
+ GNUNET_DISK_PERM_GROUP_READ |
+ GNUNET_DISK_PERM_OTHER_READ);
}
else if (0 != UNLINK (fn))
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING |
/**
* Extract results from a query result according to the given
- * specification. If colums are NULL, the destination is not
- * modified, and #GNUNET_NO is returned.
+ * specification.
*
* @param result result to process
* @param[in,out] rs result specification to extract for
* @param row row from the result to extract
* @return
* #GNUNET_YES if all results could be extracted
- * #GNUNET_NO if at least one result was NULL
* #GNUNET_SYSERR if a result was invalid (non-existing field)
*/
int
int row)
{
unsigned int i;
- int had_null = GNUNET_NO;
int ret;
for (i=0; NULL != rs[i].conv; i++)
spec->fname,
&spec->dst_size,
spec->dst);
- if (GNUNET_SYSERR == ret)
+ if (GNUNET_OK != ret)
{
GNUNET_PQ_cleanup_result (rs);
return GNUNET_SYSERR;
if (NULL != spec->result_size)
*spec->result_size = spec->dst_size;
}
- if (GNUNET_YES == had_null)
- return GNUNET_NO;
return GNUNET_OK;
}
"Could not find search strings file %s\n", filename);
return GNUNET_SYSERR;
}
- if (GNUNET_OK != GNUNET_DISK_file_size (filename, &filesize, GNUNET_YES, GNUNET_YES))
+ if (GNUNET_OK !=
+ GNUNET_DISK_file_size (filename,
+ &filesize,
+ GNUNET_YES,
+ GNUNET_YES))
filesize = 0;
if (0 == filesize)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Search strings file %s is empty.\n", filename);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Search strings file %s is empty.\n",
+ filename);
return GNUNET_SYSERR;
}
- data = GNUNET_malloc (filesize);
- if (filesize != GNUNET_DISK_fn_read (filename, data, filesize))
+ data = GNUNET_malloc (filesize + 1);
+ if (filesize != GNUNET_DISK_fn_read (filename,
+ data,
+ filesize))
{
GNUNET_free (data);
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Could not read search strings file %s.\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Could not read search strings file %s.\n",
filename);
return GNUNET_SYSERR;
}
buf = data;
offset = 0;
str_cnt = 0;
- while (offset < (filesize - 1) && str_cnt < limit)
+ while ( (offset < (filesize - 1)) && (str_cnt < limit) )
{
offset++;
- if (((data[offset] == '\n')) && (buf != &data[offset]))
+ if ( ((data[offset] == '\n')) &&
+ (buf != &data[offset]) )
{
data[offset] = '\0';
str_cnt++;
buf = &data[offset + 1];
}
- else if ((data[offset] == '\n') || (data[offset] == '\0'))
+ else if ( (data[offset] == '\n') ||
+ (data[offset] == '\0') )
buf = &data[offset + 1];
}
*strings = GNUNET_malloc (sizeof (char *) * str_cnt);
offset = 0;
for (i = 0; i < str_cnt; i++)
{
- GNUNET_asprintf (&(*strings)[i], "%s%s", regex_prefix, &data[offset]);
+ GNUNET_asprintf (&(*strings)[i],
+ "%s%s",
+ regex_prefix,
+ &data[offset]);
offset += strlen (&data[offset]) + 1;
}
GNUNET_free (data);
/* same edge, but targets definitively different, so we're different
as well */
if (t1->to_state->marked > t2->to_state->marked)
- idx1 = t1->to_state->marked * state_cnt + t2->to_state->marked;
+ idx1 = (unsigned long long) t1->to_state->marked * state_cnt + t2->to_state->marked;
else
- idx1 = t2->to_state->marked * state_cnt + t1->to_state->marked;
+ idx1 = (unsigned long long) t2->to_state->marked * state_cnt + t1->to_state->marked;
if (0 != (table[idx1 / 32] & (1 << (idx1 % 32))))
{
table[idx / 32] |= (1 << (idx % 32));
for (s2 = a->states_head; NULL != s2 && s1 != s2; s2 = s2_next)
{
s2_next = s2->next;
- idx = s1->marked * state_cnt + s2->marked;
+ idx = (unsigned long long) s1->marked * state_cnt + s2->marked;
if (0 == (table[idx / 32] & (1 << (idx % 32))))
automaton_merge_states (ctx, a, s1, s2);
}
gcry_mpi_point_release (s->prod_g_i_b_i);
s->prod_g_i_b_i = NULL;
}
- if (NULL != s->prod_g_i_b_i)
+ if (NULL != s->prod_h_i_b_i)
{
gcry_mpi_point_release (s->prod_h_i_b_i);
s->prod_h_i_b_i = NULL;
500000LL) / 1000000LL;
current_consumption = av->consumption_since_last_update__ - delta_avail;
/* negative current_consumption means that we have savings */
- max_carry = av->available_bytes_per_s__ * av->max_carry_s__;
+ max_carry = (uint64_t) av->available_bytes_per_s__ * av->max_carry_s__;
if (max_carry < GNUNET_SERVER_MAX_MESSAGE_SIZE)
max_carry = GNUNET_SERVER_MAX_MESSAGE_SIZE;
left_bytes = max_carry + current_consumption;
GNUNET_DISK_mkdtemp (const char *t)
{
char *fn;
+ mode_t omask;
+ omask = umask (S_IWGRP | S_IWOTH | SIRGRP | S_IROTH);
fn = mktemp_name (t);
if (fn != mkdtemp (fn))
{
- LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "mkstemp", fn);
+ LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "mkdtemp", fn);
GNUNET_free (fn);
+ umask (omask);
return NULL;
}
+ umask (omask);
return fn;
}
{
int fd;
char *fn;
+ mode_t omask;
+ omask = umask (S_IWGRP | S_IWOTH | SIRGRP | S_IROTH);
fn = mktemp_name (t);
if (-1 == (fd = mkstemp (fn)))
{
LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "mkstemp", fn);
GNUNET_free (fn);
+ umask (omask);
return NULL;
}
+ umask (omask);
if (0 != CLOSE (fd))
LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "close", fn);
return fn;
int ret;
s = socket (AF_UNIX, SOCK_STREAM, 0);
+ if (-1 == s)
+ {
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
+ "Failed to open AF_UNIX socket");
+ return;
+ }
ret = connect (s,
(struct sockaddr *) un,
sizeof (struct sockaddr_un));
GNUNET_MQ_handler_end ()
};
-
sap[0] = (struct sockaddr *) &sa;
slens[0] = sizeof (sa);
sap[1] = NULL;