X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Ffs%2Ffs_uri.c;h=c844bdd3141e25d0085eb174b50f5b5f5bfe68b6;hb=f9b7adcad3cc030a800cbc9a96709454c45ae06f;hp=5ddb48f2a1a52dea1edafb825ad6497057bbf1ef;hpb=5d27676deba6a3f404acf088d3bedc8a0e1d2b1b;p=oweals%2Fgnunet.git diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c index 5ddb48f2a..c844bdd31 100644 --- a/src/fs/fs_uri.c +++ b/src/fs/fs_uri.c @@ -4,7 +4,7 @@ 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 2, or (at your + by the Free Software Foundation; either version 3, or (at your option) any later version. GNUnet is distributed in the hope that it will be useful, but @@ -830,7 +830,7 @@ GNUNET_FS_uri_loc_get_uri (const struct GNUNET_FS_Uri *uri) */ struct GNUNET_FS_Uri * GNUNET_FS_uri_loc_create (const struct GNUNET_FS_Uri *baseUri, - struct GNUNET_CONFIGURATION_Handle *cfg, + const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_TIME_Absolute expiration_time) { struct GNUNET_FS_Uri *uri; @@ -927,7 +927,7 @@ canonicalize_keyword (const char *in) rpos = in; while ('\0' != *rpos) { - switch (tolower(*rpos)) + switch (tolower( (unsigned char) *rpos)) { case 'a': case 'e': @@ -962,7 +962,7 @@ canonicalize_keyword (const char *in) case 'y': case 'z': /* convert characters listed above to lower case */ - *wpos = tolower(*rpos); + *wpos = tolower( (unsigned char)*rpos); wpos++; case '!': case '.': @@ -1032,6 +1032,12 @@ GNUNET_FS_uri_ksk_merge (const struct GNUNET_FS_Uri *u1, const char *kp; char **kl; + if ( (u1 == NULL) && (u2 == NULL) ) + return NULL; + if (u1 == NULL) + return GNUNET_FS_uri_dup (u2); + if (u2 == NULL) + return GNUNET_FS_uri_dup (u1); if ( (u1->type != ksk) || (u2->type != ksk) ) { @@ -1085,8 +1091,14 @@ GNUNET_FS_uri_dup (const struct GNUNET_FS_Uri *uri) switch (ret->type) { case ksk: + if (ret->data.ksk.keywordCount >= GNUNET_MAX_MALLOC_CHECKED / sizeof (char*)) + { + GNUNET_break (0); + GNUNET_free (ret); + return NULL; + } if (ret->data.ksk.keywordCount > 0) - { + { ret->data.ksk.keywords = GNUNET_malloc (ret->data.ksk.keywordCount * sizeof (char *)); for (i = 0; i < ret->data.ksk.keywordCount; i++) @@ -1149,7 +1161,7 @@ GNUNET_FS_uri_ksk_create (const char *keywords, pos = searchString; while ('\0' != *pos) { - if ((saw_quote == 0) && (isspace (*pos))) + if ((saw_quote == 0) && (isspace ((unsigned char) *pos))) { inWord = 0; } @@ -1180,7 +1192,7 @@ GNUNET_FS_uri_ksk_create (const char *keywords, pos = searchString; while ('\0' != *pos) { - if ((saw_quote == 0) && (isspace (*pos))) + if ((saw_quote == 0) && (isspace ( (unsigned char) *pos))) { inWord = 0; *pos = '\0'; @@ -1573,7 +1585,7 @@ GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_CONTAINER_MetaData static int needs_percent (char c) { - return (!((isalnum (c)) || + return (!((isalnum ( (unsigned char) c)) || (c == '-') || (c == '_') || (c == '.') || (c == '~'))); } @@ -1750,7 +1762,7 @@ bin2enc (const void *data, size_t size) } } if (hbits > 0) - ret[len++] = tbl[bits & 63]; + ret[len] = tbl[bits & 63]; return ret; }