diff options
author | onefang | 2020-05-14 20:23:23 +1000 |
---|---|---|
committer | onefang | 2020-05-14 20:23:23 +1000 |
commit | 228df6a08a83ac4cd7910670b367feaceb417be4 (patch) | |
tree | d219a919402fb60c44be367139d60dda3e4634b8 | |
parent | Comments++ (diff) | |
download | opensim-SC-228df6a08a83ac4cd7910670b367feaceb417be4.zip opensim-SC-228df6a08a83ac4cd7910670b367feaceb417be4.tar.gz opensim-SC-228df6a08a83ac4cd7910670b367feaceb417be4.tar.bz2 opensim-SC-228df6a08a83ac4cd7910670b367feaceb417be4.tar.xz |
Leakies +/-
Diffstat (limited to '')
-rw-r--r-- | src/sledjchisl/sledjchisl.c | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index f3411d8..5a06fa2 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c | |||
@@ -2329,10 +2329,9 @@ cookie *setCookie(reqData *Rd, char *cki, char *value) | |||
2329 | } | 2329 | } |
2330 | l = strlen(value); | 2330 | l = strlen(value); |
2331 | if (0 != l) | 2331 | if (0 != l) |
2332 | ret->value = qurl_encode(value, l); | 2332 | ret->value = qurl_encode(value, l); // LEAKY |
2333 | else | 2333 | else |
2334 | // TODO - I'm doing something crazy again, this isn't crashing when I try to free it. Sometimes. Heisenbug? | 2334 | ret->value = xstrdup(""); // LEAKY |
2335 | ret->value = ""; | ||
2336 | ret->httpOnly = TRUE; | 2335 | ret->httpOnly = TRUE; |
2337 | ret->site = CS_STRICT; | 2336 | ret->site = CS_STRICT; |
2338 | ret->secure = TRUE; | 2337 | ret->secure = TRUE; |
@@ -2345,6 +2344,16 @@ cookie *setCookie(reqData *Rd, char *cki, char *value) | |||
2345 | return ret; | 2344 | return ret; |
2346 | } | 2345 | } |
2347 | 2346 | ||
2347 | void freeCookie(reqData *Rd, char *cki) | ||
2348 | { | ||
2349 | cookie *ck0 = Rd->cookies->get(Rd->cookies, cki, NULL, false); | ||
2350 | |||
2351 | // TODO - Crash or leak, there is no free. | ||
2352 | // if ((NULL != ck0) && (NULL != ck0->value)) | ||
2353 | // free(ck0->value); | ||
2354 | Rd->cookies->remove(Rd->cookies, cki); | ||
2355 | } | ||
2356 | |||
2348 | char *getCookie(qhashtbl_t *cookies, char *cki) | 2357 | char *getCookie(qhashtbl_t *cookies, char *cki) |
2349 | { | 2358 | { |
2350 | char *ret = NULL; | 2359 | char *ret = NULL; |
@@ -3374,9 +3383,8 @@ T("free sesh %s %s", linky ? "linky" : "session", wipe ? "wipe" : "delete"); | |||
3374 | 3383 | ||
3375 | Rd->body-> remove(Rd->body, "munchie"); | 3384 | Rd->body-> remove(Rd->body, "munchie"); |
3376 | 3385 | ||
3377 | Rd->cookies->remove(Rd->cookies, "toke_n_munchie"); | 3386 | freeCookie(Rd, "toke_n_munchie"); |
3378 | Rd->cookies->remove(Rd->cookies, "hashish"); | 3387 | freeCookie(Rd, "hashish"); |
3379 | |||
3380 | cookie *ck = setCookie(Rd, "toke_n_munchie", ""); | 3388 | cookie *ck = setCookie(Rd, "toke_n_munchie", ""); |
3381 | cookie *ckh = setCookie(Rd, "hashish", ""); | 3389 | cookie *ckh = setCookie(Rd, "hashish", ""); |
3382 | ck->maxAge = -1; // Should expire immediately. | 3390 | ck->maxAge = -1; // Should expire immediately. |
@@ -4567,7 +4575,7 @@ static int nameValidate(reqData *Rd, inputForm *iF, inputValue *iV) | |||
4567 | Rd->stuff->putstrf(Rd->stuff, "name", "%s %s", name, s); | 4575 | Rd->stuff->putstrf(Rd->stuff, "name", "%s %s", name, s); |
4568 | // TODO - fix this, so we don't show "You are user" when we are not, but everything else still works. | 4576 | // TODO - fix this, so we don't show "You are user" when we are not, but everything else still works. |
4569 | // if ('\0' != getStrH(Rd->queries, "user")[0]) | 4577 | // if ('\0' != getStrH(Rd->queries, "user")[0]) |
4570 | Rd->shs.name = Rd->stuff->getstr(Rd->stuff, "name", true); | 4578 | Rd->shs.name = Rd->stuff->getstr(Rd->stuff, "name", true); // LEAKY |
4571 | } | 4579 | } |
4572 | } | 4580 | } |
4573 | } | 4581 | } |
@@ -5024,8 +5032,6 @@ static void accountViewWeb(reqData *Rd, inputForm *oF, inputValue *oV) | |||
5024 | HTMLtextArea(Rd->reply, "aboutMe", "About", 7, 50, 4, 16384, "", "off", "true", "soft", about, FALSE, TRUE); | 5032 | HTMLtextArea(Rd->reply, "aboutMe", "About", 7, 50, 4, 16384, "", "off", "true", "soft", about, FALSE, TRUE); |
5025 | accountWebSubs(Rd, oF); | 5033 | accountWebSubs(Rd, oF); |
5026 | accountWebFooter(Rd, oF); | 5034 | accountWebFooter(Rd, oF); |
5027 | free(about); free(voucher); free(email); | ||
5028 | |||
5029 | } | 5035 | } |
5030 | 5036 | ||
5031 | static void accountEditWeb(reqData *Rd, inputForm *oF, inputValue *oV) | 5037 | static void accountEditWeb(reqData *Rd, inputForm *oF, inputValue *oV) |
@@ -5490,8 +5496,8 @@ d("Sub accountViewSub() %s %s %s", uuid, first, last); | |||
5490 | else | 5496 | else |
5491 | { | 5497 | { |
5492 | Rd->shs.level = atoi(getStrH(Rd->database, "UserAccounts.UserLevel")); | 5498 | Rd->shs.level = atoi(getStrH(Rd->database, "UserAccounts.UserLevel")); |
5493 | Rd->shs.name = Rd->database->getstr(Rd->database, "Lua.name", true); | 5499 | Rd->shs.name = Rd->database->getstr(Rd->database, "Lua.name", true); // LEAKY |
5494 | Rd->shs.UUID = Rd->database->getstr(Rd->database, "UserAccounts.PrincipalID", true); | 5500 | Rd->shs.UUID = Rd->database->getstr(Rd->database, "UserAccounts.PrincipalID", true); // LEAKY |
5495 | free(h); | 5501 | free(h); |
5496 | I("Logged on %s %s Level %d %s", Rd->shs.UUID, Rd->shs.name, Rd->shs.level, getLevel(Rd->shs.level)); | 5502 | I("Logged on %s %s Level %d %s", Rd->shs.UUID, Rd->shs.name, Rd->shs.level, getLevel(Rd->shs.level)); |
5497 | Rd->shs.status = SHS_LOGIN; | 5503 | Rd->shs.status = SHS_LOGIN; |
@@ -5570,14 +5576,14 @@ static int accountFilterValidated(struct dirtree *node) | |||
5570 | struct stat st; | 5576 | struct stat st; |
5571 | struct timespec now; | 5577 | struct timespec now; |
5572 | RdAndListTbl *rdl = (RdAndListTbl *) node->parent->extra; | 5578 | RdAndListTbl *rdl = (RdAndListTbl *) node->parent->extra; |
5573 | qhashtbl_t *tnm = qhashtbl(0, 0); // LEAKY! | 5579 | qhashtbl_t *tnm = qhashtbl(0, 0); |
5574 | char *name = node->name; | 5580 | char *name = node->name; |
5575 | char *where = xmprintf("%s/users/%s", scData, node->name); | 5581 | char *where = xmprintf("%s/users/%s", scData, node->name); |
5576 | int rt = LuaToHash(rdl->Rd, where, "user", tnm, 0, &st, &now, "user"); | 5582 | int rt = LuaToHash(rdl->Rd, where, "user", tnm, 0, &st, &now, "user"); |
5577 | 5583 | ||
5578 | t("accountFilterValidatedVoucher %s (%s) -> %s -> %s", name, getStrH(tnm, "level"), getStrH(tnm, "name"), getStrH(tnm, "voucher")); | 5584 | t("accountFilterValidatedVoucher %s (%s) -> %s -> %s", name, getStrH(tnm, "level"), getStrH(tnm, "name"), getStrH(tnm, "voucher")); |
5579 | if ((0 == rt) && (strcmp("-100", getStrH(tnm, "level")) == 0)) | 5585 | if ((0 == rt) && (strcmp("-100", getStrH(tnm, "level")) == 0)) |
5580 | rdl->list->put(rdl->list, getStrH(tnm, "name"), tnm, sizeof(*tnm)); | 5586 | rdl->list->put(rdl->list, getStrH(tnm, "name"), &tnm, sizeof(qhashtbl_t *)); |
5581 | else | 5587 | else |
5582 | tnm->free(tnm); | 5588 | tnm->free(tnm); |
5583 | free(where); | 5589 | free(where); |
@@ -5601,7 +5607,6 @@ qlisttbl_t *getAccounts(reqData *Rd) | |||
5601 | static void accountExploreValidatedVouchersWeb(reqData *Rd, inputForm *oF, inputValue *oV) | 5607 | static void accountExploreValidatedVouchersWeb(reqData *Rd, inputForm *oF, inputValue *oV) |
5602 | { | 5608 | { |
5603 | qlisttbl_t *list =getAccounts(Rd); | 5609 | qlisttbl_t *list =getAccounts(Rd); |
5604 | // char *name = getStrH(Rd->stuff, "name"); | ||
5605 | 5610 | ||
5606 | if (NULL != Rd->shs.name) free(Rd->shs.name); | 5611 | if (NULL != Rd->shs.name) free(Rd->shs.name); |
5607 | Rd->shs.name = NULL; | 5612 | Rd->shs.name = NULL; |
@@ -5625,16 +5630,15 @@ static void accountExploreValidatedVouchersWeb(reqData *Rd, inputForm *oF, input | |||
5625 | list->lock(list); | 5630 | list->lock(list); |
5626 | while(list->getnext(list, &obj, NULL, false) == true) | 5631 | while(list->getnext(list, &obj, NULL, false) == true) |
5627 | { | 5632 | { |
5628 | qhashtbl_t *tnm = (qhashtbl_t *) obj.data; | 5633 | qhashtbl_t *tnm = *((qhashtbl_t **) obj.data); |
5629 | char *nm = qstrreplace("tr", xstrdup(obj.name), " ", "+"); | 5634 | char *nm = qstrreplace("tr", xstrdup(obj.name), " ", "+"); |
5630 | 5635 | ||
5631 | Rd->reply->addstrf(Rd->reply, "<tr><td><a href='https://%s%s?user=%s'>%s</a></td>", Rd->Host, Rd->RUri, nm, obj.name); | 5636 | Rd->reply->addstrf(Rd->reply, "<tr><td><a href='https://%s%s?user=%s'>%s</a></td>", Rd->Host, Rd->RUri, nm, obj.name); |
5632 | Rd->reply->addstrf(Rd->reply, "<td>%s</td><td>%s</td><td>%s</td></tr>", getStrH(tnm, "voucher"), getStrH(tnm, "level"), getStrH(tnm, "title")); | 5637 | Rd->reply->addstrf(Rd->reply, "<td>%s</td><td>%s</td><td>%s</td></tr>", getStrH(tnm, "voucher"), getStrH(tnm, "level"), getStrH(tnm, "title")); |
5633 | free(nm); | 5638 | free(nm); |
5634 | tnm->clear(tnm); | 5639 | tnm->clear(tnm); |
5635 | // TODO - crazy time again, either it frees twice, or not at all. | 5640 | list->removeobj(list, &obj); |
5636 | // list->removeobj(list, &obj); | 5641 | tnm->free(tnm); |
5637 | // tnm->free(tnm); | ||
5638 | } | 5642 | } |
5639 | list->unlock(list); | 5643 | list->unlock(list); |
5640 | Rd->reply->addstr(Rd->reply, "</table>"); | 5644 | Rd->reply->addstr(Rd->reply, "</table>"); |
@@ -6349,7 +6353,7 @@ static void cleanup(void) | |||
6349 | 6353 | ||
6350 | memset((void*)&obj, 0, sizeof(obj)); | 6354 | memset((void*)&obj, 0, sizeof(obj)); |
6351 | accountPages->lock(accountPages); | 6355 | accountPages->lock(accountPages); |
6352 | while(accountPages->getnext(accountPages, &obj, true) == true) | 6356 | while(accountPages->getnext(accountPages, &obj, false) == true) |
6353 | { | 6357 | { |
6354 | inputForm *f = (inputForm *) obj.data; | 6358 | inputForm *f = (inputForm *) obj.data; |
6355 | 6359 | ||
@@ -6372,7 +6376,7 @@ static void cleanup(void) | |||
6372 | 6376 | ||
6373 | memset((void*)&obj, 0, sizeof(obj)); | 6377 | memset((void*)&obj, 0, sizeof(obj)); |
6374 | HTMLfileCache->lock(HTMLfileCache); | 6378 | HTMLfileCache->lock(HTMLfileCache); |
6375 | while(HTMLfileCache->getnext(HTMLfileCache, &obj, true) == true) | 6379 | while(HTMLfileCache->getnext(HTMLfileCache, &obj, false) == true) |
6376 | { | 6380 | { |
6377 | HTMLfile *f = (HTMLfile *) obj.data; | 6381 | HTMLfile *f = (HTMLfile *) obj.data; |
6378 | 6382 | ||
@@ -7068,6 +7072,7 @@ sendReply: | |||
7068 | if (CS_NONE == ck->site) FCGI_printf("; SameSite=None"); | 7072 | if (CS_NONE == ck->site) FCGI_printf("; SameSite=None"); |
7069 | FCGI_printf("\r\n"); | 7073 | FCGI_printf("\r\n"); |
7070 | free(ck->value); | 7074 | free(ck->value); |
7075 | ck->value = NULL; | ||
7071 | } | 7076 | } |
7072 | FCGI_printf("\r\n"); | 7077 | FCGI_printf("\r\n"); |
7073 | Rd->cookies->unlock(Rd->cookies); | 7078 | Rd->cookies->unlock(Rd->cookies); |