]> granicus.if.org Git - php/commitdiff
Secure versions of string functions don't exist for VC6
authorElizabeth Marie Smith <auroraeosrose@php.net>
Mon, 28 Jul 2008 16:48:38 +0000 (16:48 +0000)
committerElizabeth Marie Smith <auroraeosrose@php.net>
Mon, 28 Jul 2008 16:48:38 +0000 (16:48 +0000)
ext/standard/php_crypt_r.c

index 6efce8b8f3ba7d17522ac78b4098e2d4f142b986..7f8676a54b0ed2fa83a19e34afc9323faf63e614 100644 (file)
@@ -204,10 +204,18 @@ char * php_md5_crypt_r(const char *pw, const char *salt, char *out) {
 
        memcpy(passwd, MD5_MAGIC, MD5_MAGIC_LEN);
 
-       if (strncpy_s(passwd + MD5_MAGIC_LEN, MD5_HASH_MAX_LEN - MD5_MAGIC_LEN, sp, sl + 1) != 0) {
+#ifdef strncpy_s
+       if (strncpy_s(passwd + MD5_MAGIC_LEN, MD5_HASH_MAX_LEN - MD5_MAGIC_LEN, sp, sl + 1) != 0) {
+               goto _destroyCtx1;
+       }
+       strcat_s(passwd, MD5_HASH_MAX_LEN, "$");
+#else
+       /* VC6 version doesn't have strcat_s or strncpy_s */
+       if (strncpy(passwd + MD5_MAGIC_LEN, sp, sl + 1) != 0) {
                goto _destroyCtx1;
        }
-       strcat_s(passwd, MD5_HASH_MAX_LEN, "$");
+       strcat(passwd, "$");
+#endif
 
        dwHashLen = 16;