Skip to content

Commit f644d13

Browse files
Clear otp after each run
Rework 52148b7 to clear the otp just after it is used. Also, clear it completely with memset().
1 parent fa560c9 commit f644d13

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/http.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ static int try_otp_auth(struct tunnel *tunnel, const char *buffer,
474474
const char *s = buffer;
475475
char *d = data;
476476
const char *p = NULL;
477+
int ret;
477478
/* Length-check for destination buffer */
478479
#define SPACE_AVAILABLE(sz) (sizeof(data) - (d - data) >= (sz))
479480
/* Get the form action */
@@ -616,7 +617,9 @@ static int try_otp_auth(struct tunnel *tunnel, const char *buffer,
616617
if (!SPACE_AVAILABLE(1))
617618
return -1;
618619
*d++ = '\0';
619-
return http_request(tunnel, "POST", path, data, res, response_size);
620+
ret = http_request(tunnel, "POST", path, data, res, response_size);
621+
memset(tunnel->config->otp, '\0', OTP_SIZE + 1); // clear OTP for next run
622+
return ret;
620623
#undef SPACE_AVAILABLE
621624
}
622625

src/main.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,6 @@ int main(int argc, char *argv[])
781781
ret = EXIT_SUCCESS;
782782
if ((cfg.persistent > 0) && (get_sig_received() == 0))
783783
sleep(cfg.persistent);
784-
cfg.otp[0] = '\0'; // clear OTP for next run
785784
} while ((get_sig_received() == 0) && (cfg.persistent != 0));
786785

787786
goto exit;

0 commit comments

Comments
 (0)