Changeset: 9bb4b9029baf for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9bb4b9029baf Added Files: common/utils/ChangeLog.Mar2018 Modified Files: common/utils/mcrypt.c common/utils/mcrypt.h monetdb5/modules/mal/mal_mapi.c tools/merovingian/daemon/client.c Branch: Mar2018 Log Message:
The function mcrypt_getHashAlgorithms now returns a static, constant string. diffs (247 lines): diff --git a/common/utils/ChangeLog.Mar2018 b/common/utils/ChangeLog.Mar2018 new file mode 100644 --- /dev/null +++ b/common/utils/ChangeLog.Mar2018 @@ -0,0 +1,7 @@ +# ChangeLog file for utils +# This file is updated with Maddlog + +* Thu Mar 8 2018 Sjoerd Mullender <sjo...@acm.org> +- The function mcrypt_getHashAlgorithms now returns a static, constant + string, so the result should not be modified or freed. + diff --git a/common/utils/mcrypt.c b/common/utils/mcrypt.c --- a/common/utils/mcrypt.c +++ b/common/utils/mcrypt.c @@ -30,7 +30,7 @@ * (in char size) hashes. * The returned string is malloced and should be freed. */ -char * +const char * mcrypt_getHashAlgorithms(void) { /* Currently, four "hashes" are available, RIPEMD160, SHA-2, SHA-1 @@ -40,7 +40,7 @@ mcrypt_getHashAlgorithms(void) * Better/stronger/faster algorithms can be added in the future upon * desire. */ - const char *algorithms = + static const char *algorithms = "PROT10" #ifdef HAVE_RIPEMD160_UPDATE ",RIPEMD160" @@ -61,7 +61,7 @@ mcrypt_getHashAlgorithms(void) ",COMPRESSION_LZ4" #endif ; - return strdup(algorithms); + return algorithms; } /** diff --git a/common/utils/mcrypt.h b/common/utils/mcrypt.h --- a/common/utils/mcrypt.h +++ b/common/utils/mcrypt.h @@ -9,7 +9,7 @@ #ifndef _SEEN_MCRYPT_H #define _SEEN_MCRYPT_H 1 -char *mcrypt_getHashAlgorithms(void); +const char *mcrypt_getHashAlgorithms(void); char *mcrypt_MD5Sum(const char *string, size_t len); char *mcrypt_SHA1Sum(const char *string, size_t len); char *mcrypt_SHA224Sum(const char *string, size_t len); diff --git a/monetdb5/modules/mal/mal_mapi.c b/monetdb5/modules/mal/mal_mapi.c --- a/monetdb5/modules/mal/mal_mapi.c +++ b/monetdb5/modules/mal/mal_mapi.c @@ -133,7 +133,6 @@ doChallenge(void *data) #endif char *buf = (char *) GDKmalloc(BLOCK + 1); char challenge[13]; - char *algos; stream *fdin = ((struct challengedata *) data)->in; stream *fdout = ((struct challengedata *) data)->out; @@ -156,20 +155,11 @@ doChallenge(void *data) /* generate the challenge string */ generateChallenge(challenge, 8, 12); - algos = mcrypt_getHashAlgorithms(); - if(!algos) { - mnstr_printf(fdout, "!allocation failure in the server\n"); - GDKsyserror("SERVERlisten:"MAL_MALLOC_FAIL); - close_stream(fdin); - close_stream(fdout); - GDKfree(buf); - return; - } // send the challenge over the block stream mnstr_printf(fdout, "%s:mserver:9:%s:%s:%s:", challenge, - algos, + mcrypt_getHashAlgorithms(), #ifdef WORDS_BIGENDIAN "BIG", #else @@ -177,7 +167,6 @@ doChallenge(void *data) #endif MONETDB5_PASSWDHASH ); - free(algos); mnstr_flush(fdout); /* get response */ if ((len = mnstr_read_block(fdin, buf, 1, BLOCK)) < 0) { diff --git a/tools/merovingian/daemon/client.c b/tools/merovingian/daemon/client.c --- a/tools/merovingian/daemon/client.c +++ b/tools/merovingian/daemon/client.c @@ -69,7 +69,6 @@ handleClient(void *data) char mydoproxy; sabdb redirs[24]; /* do we need more? */ int r = 0; - char *algos; int sock; char isusock; struct threads *self; @@ -118,19 +117,9 @@ handleClient(void *data) /* note: since Jan2012 we speak proto 9 for control connections */ chal[31] = '\0'; generateSalt(chal, 31); - algos = mcrypt_getHashAlgorithms(); - if(!algos) { - e = newErr("Allocation failure"); - mnstr_printf(fout, "!monetdbd: allocation failure\n"); - mnstr_flush(fout); - close_stream(fout); - close_stream(fdin); - self->dead = 1; - return(e); - } mnstr_printf(fout, "%s:merovingian:9:%s:%s:%s:", chal, - algos, + mcrypt_getHashAlgorithms(), #ifdef WORDS_BIGENDIAN "BIG", #else @@ -151,7 +140,6 @@ handleClient(void *data) mnstr_flush(fout); close_stream(fout); close_stream(fdin); - free(algos); self->dead = 1; return(e); } @@ -173,7 +161,6 @@ handleClient(void *data) mnstr_flush(fout); close_stream(fout); close_stream(fdin); - free(algos); self->dead = 1; return(e); } @@ -190,7 +177,6 @@ handleClient(void *data) mnstr_flush(fout); close_stream(fout); close_stream(fdin); - free(algos); self->dead = 1; return(e); } @@ -202,7 +188,6 @@ handleClient(void *data) mnstr_flush(fout); close_stream(fout); close_stream(fdin); - free(algos); self->dead = 1; return(e); } @@ -214,7 +199,6 @@ handleClient(void *data) mnstr_flush(fout); close_stream(fout); close_stream(fdin); - free(algos); self->dead = 1; return(e); } @@ -230,7 +214,6 @@ handleClient(void *data) mnstr_flush(fout); close_stream(fout); close_stream(fdin); - free(algos); self->dead = 1; return(e); } @@ -249,7 +232,6 @@ handleClient(void *data) mnstr_flush(fout); close_stream(fout); close_stream(fdin); - free(algos); self->dead = 1; return(e); } else { @@ -264,7 +246,6 @@ handleClient(void *data) mnstr_flush(fout); close_stream(fout); close_stream(fdin); - free(algos); self->dead = 1; return(newErr("client %s specified no database", host)); } @@ -275,7 +256,6 @@ handleClient(void *data) control_handleclient(host, sock, fdin, fout); close_stream(fout); close_stream(fdin); - free(algos); self->dead = 1; return(NO_ERR); } @@ -306,7 +286,6 @@ handleClient(void *data) mnstr_flush(fout); close_stream(fout); close_stream(fdin); - free(algos); self->dead = 1; return(e); } @@ -319,7 +298,6 @@ handleClient(void *data) { multiplexAddClient(top->dbname, sock, fout, fdin, host); msab_freeStatus(&top); - free(algos); self->dead = 1; return(NO_ERR); } @@ -349,7 +327,6 @@ handleClient(void *data) close_stream(fout); close_stream(fdin); msab_freeStatus(&top); - free(algos); self->dead = 1; return(e); } @@ -411,7 +388,7 @@ handleClient(void *data) /* we need to let the client login in order not to violate * the protocol */ mnstr_printf(fout, "void:merovingian:9:%s:BIG:%s:", - algos, MONETDB5_PASSWDHASH); + mcrypt_getHashAlgorithms(), MONETDB5_PASSWDHASH); mnstr_flush(fout); mnstr_read_block(fdin, buf, 8095, 1); /* eat away client response */ mnstr_printf(fout, "!monetdbd: an internal error has occurred '%s', refer to the logs for details, please try again later\n",e); @@ -421,14 +398,12 @@ handleClient(void *data) close_stream(fdin); Mfprintf(stdout, "starting a proxy failed: %s\n", e); msab_freeStatus(&top); - free(algos); self->dead = 1; return(e); } } msab_freeStatus(&top); - free(algos); self->dead = 1; return(NO_ERR); } _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list