aboutsummaryrefslogtreecommitdiffstats
path: root/gasroot-setuid.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--gasroot-setuid.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/gasroot-setuid.c b/gasroot-setuid.c
index ca0b6c6..b970e19 100644
--- a/gasroot-setuid.c
+++ b/gasroot-setuid.c
@@ -204,6 +204,17 @@ recvtext(int fd, char **bufp, size_t *sizep)
}
+static int
+consttime_streq(const char *a, const char *b)
+{
+ size_t i;
+ int ret = 1;
+ for (i = 0; a[i] && b[i]; i++)
+ ret &= a[i] == b[i];
+ return ret & !a[i] && !b[i];
+}
+
+
int
main(int argc, char *argv[])
{
@@ -230,7 +241,7 @@ main(int argc, char *argv[])
sendtext(fd, "HELLO");
for (;;) {
recvtext(fd, &passphrase, &passphrase_size);
- if (!strcmp(crypt(passphrase, expected), expected))
+ if (consttime_streq(crypt(passphrase, expected), expected))
break;
wipe(passphrase);
#if RETRY_SLEEP > 0