comparison src/cipher.c @ 12388:4e045668b9d0

[gaim-migrate @ 14694] Smashing the stack is neither fun nor profitable! Having room for the NUL terminator is a good idea. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Wed, 07 Dec 2005 10:38:52 +0000
parents cfc808463763
children e024601d45c7
comparison
equal deleted inserted replaced
12387:1112a9ef2cc6 12388:4e045668b9d0
1633 g_return_val_if_fail(digest_s, FALSE); 1633 g_return_val_if_fail(digest_s, FALSE);
1634 1634
1635 if(!gaim_cipher_context_digest(context, sizeof(digest), digest, &dlen)) 1635 if(!gaim_cipher_context_digest(context, sizeof(digest), digest, &dlen))
1636 return FALSE; 1636 return FALSE;
1637 1637
1638 if(in_len < dlen * 2) 1638 /* in_len must be greater than dlen * 2 so we have room for the NUL. */
1639 if(in_len <= dlen * 2)
1639 return FALSE; 1640 return FALSE;
1640 1641
1641 for(n = 0; n < dlen; n++) 1642 for(n = 0; n < dlen; n++)
1642 sprintf(digest_s + (n * 2), "%02x", digest[n]); 1643 sprintf(digest_s + (n * 2), "%02x", digest[n]);
1643 1644
1789 const gchar *nonce, 1790 const gchar *nonce,
1790 const gchar *client_nonce) 1791 const gchar *client_nonce)
1791 { 1792 {
1792 GaimCipher *cipher; 1793 GaimCipher *cipher;
1793 GaimCipherContext *context; 1794 GaimCipherContext *context;
1794 gchar hash[32]; /* We only support MD5. */ 1795 gchar hash[33]; /* We only support MD5. */
1795 1796
1796 g_return_val_if_fail(username != NULL, NULL); 1797 g_return_val_if_fail(username != NULL, NULL);
1797 g_return_val_if_fail(realm != NULL, NULL); 1798 g_return_val_if_fail(realm != NULL, NULL);
1798 g_return_val_if_fail(password != NULL, NULL); 1799 g_return_val_if_fail(password != NULL, NULL);
1799 g_return_val_if_fail(nonce != NULL, NULL); 1800 g_return_val_if_fail(nonce != NULL, NULL);
1855 const gchar *client_nonce, 1856 const gchar *client_nonce,
1856 const gchar *session_key) 1857 const gchar *session_key)
1857 { 1858 {
1858 GaimCipher *cipher; 1859 GaimCipher *cipher;
1859 GaimCipherContext *context; 1860 GaimCipherContext *context;
1860 gchar hash2[32]; /* We only support MD5. */ 1861 static gchar hash2[33]; /* We only support MD5. */
1861 1862
1862 g_return_val_if_fail(method != NULL, NULL); 1863 g_return_val_if_fail(method != NULL, NULL);
1863 g_return_val_if_fail(digest_uri != NULL, NULL); 1864 g_return_val_if_fail(digest_uri != NULL, NULL);
1864 g_return_val_if_fail(nonce != NULL, NULL); 1865 g_return_val_if_fail(nonce != NULL, NULL);
1865 g_return_val_if_fail(session_key != NULL, NULL); 1866 g_return_val_if_fail(session_key != NULL, NULL);