summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authormichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>2013-06-10 19:34:23 +0000
committermichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>2013-06-10 19:34:23 +0000
commit0ec4c137fef91be1314db295af065bbed5871621 (patch)
tree94f77ae8ba3b1d315ff466b17cd790463b842ac1 /tools
parentefb0bc5730df991cc3a1625f8f31e469a4f4c98e (diff)
- mkpasswd.c: replace all sprintf() with snprintf()
git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/branches/8.1.x@2223 82007160-df01-0410-b94d-b575c5fd34c7
Diffstat (limited to 'tools')
-rw-r--r--tools/mkpasswd.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/tools/mkpasswd.c b/tools/mkpasswd.c
index c4234d5..81eb95a 100644
--- a/tools/mkpasswd.c
+++ b/tools/mkpasswd.c
@@ -266,7 +266,7 @@ make_ext_salt_para(int rounds, const char *saltpara)
{
static char salt[10];
- sprintf(salt, "_%s%s", int_to_base64(rounds), saltpara);
+ snprintf(salt, sizeof(salt), "_%s%s", int_to_base64(rounds), saltpara);
return salt;
}
@@ -277,11 +277,7 @@ make_sha256_salt_para(const char *saltpara)
if (saltpara && (strlen(saltpara) <= 16))
{
- /*
- * sprintf used because of portability requirements, the length
- * is checked above, so it should not be too much of a concern
- */
- sprintf(salt, "$5$%s$", saltpara);
+ snprintf(salt, sizeof(salt), "$5$%s$", saltpara);
return salt;
}
@@ -322,11 +318,7 @@ make_sha512_salt_para(const char *saltpara)
if (saltpara && (strlen(saltpara) <= 16))
{
- /*
- * sprintf used because of portability requirements, the length
- * is checked above, so it should not be too much of a concern
- */
- sprintf(salt, "$6$%s$", saltpara);
+ snprintf(salt, sizeof(salt), "$6$%s$", saltpara);
return salt;
}
@@ -367,11 +359,7 @@ make_md5_salt_para(const char *saltpara)
if (saltpara && (strlen(saltpara) <= 16))
{
- /*
- * sprintf used because of portability requirements, the length
- * is checked above, so it should not be too much of a concern
- */
- sprintf(salt, "$1$%s$", saltpara);
+ snprintf(salt, sizeof(salt), "$1$%s$", saltpara);
return salt;
}
@@ -413,12 +401,8 @@ make_bf_salt_para(int rounds, const char *saltpara)
if (saltpara && (strlen(saltpara) <= 22))
{
- /*
- * sprintf used because of portability requirements, the length
- * is checked above, so it should not be too much of a concern
- */
- sprintf(tbuf, "%02d", rounds);
- sprintf(salt, "$2a$%s$%s$", tbuf, saltpara);
+ snprintf(tbuf, sizeof(tbuf), "%02d", rounds);
+ snprintf(salt, sizeof(salt), "$2a$%s$%s$", tbuf, saltpara);
return salt;
}
@@ -441,8 +425,8 @@ make_bf_salt(int rounds, int length)
exit(0);
}
- sprintf(tbuf, "%02d", rounds);
- sprintf(salt, "$2a$%s$", tbuf);
+ snprintf(tbuf, sizeof(tbuf), "%02d", rounds);
+ snprintf(salt, sizeof(salt), "$2a$%s$", tbuf);
generate_random_salt(&salt[7], length);