X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=version2%2Fsrc%2FC%2FCloudComm.cc;fp=version2%2Fsrc%2FC%2FCloudComm.cc;h=8fe0ceeb256eddc802a076f3e6289798f0e5a90d;hb=0173578905303681df8ea5f3c35b3ead109c8ba8;hp=c229259140501fa1384cb74eb1fa49824b58a5c9;hpb=b7ed1849727b50e226f3b9d1c432d3071d739368;p=iotcloud.git diff --git a/version2/src/C/CloudComm.cc b/version2/src/C/CloudComm.cc index c229259..8fe0cee 100644 --- a/version2/src/C/CloudComm.cc +++ b/version2/src/C/CloudComm.cc @@ -46,7 +46,7 @@ void *threadWrapper(void *cloud) { * Constructor for actual use. Takes in the url and password. */ CloudComm::CloudComm(Table *_table, IoTString *_baseurl, IoTString *_password, int _listeningPort) : - baseurl(_baseurl), + baseurl(new IoTString(_baseurl)), key(NULL), mac(NULL), password(new IoTString(_password)), @@ -74,6 +74,10 @@ CloudComm::~CloudComm() { delete random; if (baseurl) delete baseurl; + if (mac) + delete mac; + if (key) + delete key; } /** @@ -135,6 +139,7 @@ IoTString *CloudComm::buildRequest(bool isput, int64_t sequencenumber, int64_t m if (maxentries != 0) sprintf(&buffer[offset], "&max=%" PRId64, maxentries); IoTString *urlstr = new IoTString(buffer); + free(buffer); return urlstr; } @@ -225,6 +230,7 @@ WebConnection openURL(IoTString *url) { /* send the request */ int total = strlen(message); loopWrite(sockfd, message, total); + free(message); return (WebConnection) {sockfd, -1}; } @@ -411,6 +417,7 @@ void CloudComm::setSalt() { timer->startTime(); wc = openURL(urlstr); + delete urlstr; writeURLDataAndClose(&wc, saltTmp); int responsecode = getResponseCode(&wc); @@ -554,11 +561,14 @@ Array *CloudComm::putSlot(Slot *slot, int max) { int64_t sequencenumber = slot->getSequenceNumber(); Array *slotBytes = slot->encode(mac); - Array *chars = encryptSlotAndPrependIV(slotBytes, slot->getSlotCryptIV()); + Array * ivBytes = slot->getSlotCryptIV(); + Array *chars = encryptSlotAndPrependIV(slotBytes, ivBytes); + delete ivBytes; delete slotBytes; IoTString *url = buildRequest(true, sequencenumber, max); timer->startTime(); wc = openURL(url); + delete url; writeURLDataAndClose(&wc, chars); delete chars; timer->endTime(); @@ -625,6 +635,7 @@ Array *CloudComm::getSlots(int64_t sequencenumber) { IoTString *url = buildRequest(false, sequencenumber, 0); timer->startTime(); wc = openURL(url); + delete url; closeURLReq(&wc); timer->endTime(); } catch (SocketTimeoutException *e) {