]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Rename crc32() to crc32_compute(), to avoid clashing catastrophically
authorSimon Tatham <anakin@pobox.com>
Tue, 13 May 2003 18:23:43 +0000 (18:23 +0000)
committerSimon Tatham <anakin@pobox.com>
Tue, 13 May 2003 18:23:43 +0000 (18:23 +0000)
with the crc32() function in the zlib interface. (Not that PuTTY
itself _uses_ zlib, but on Unix it's linked against libgtk which
uses libpng which uses zlib. And zlib has poor namespace management
so it defines this ridiculously intrusive function name. Arrrrgh.)

[originally from svn r3191]

ssh.c
ssh.h
sshcrc.c

diff --git a/ssh.c b/ssh.c
index 2b33bea37f33cc18bb887cd27c47682b127b007e..20a5ce4d1a38bb2a755d5008c5c52d513e531d6b 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -856,7 +856,7 @@ static int ssh1_rdpkt(Ssh ssh, unsigned char **data, int *datalen)
     if (ssh->cipher)
        ssh->cipher->decrypt(ssh->v1_cipher_ctx, ssh->pktin.data, st->biglen);
 
-    st->realcrc = crc32(ssh->pktin.data, st->biglen - 4);
+    st->realcrc = crc32_compute(ssh->pktin.data, st->biglen - 4);
     st->gotcrc = GET_32BIT(ssh->pktin.data + st->biglen - 4);
     if (st->gotcrc != st->realcrc) {
        bombout(("Incorrect CRC received on packet"));
@@ -1244,7 +1244,7 @@ static int s_wrpkt_prepare(Ssh ssh)
 
     for (i = 0; i < pad; i++)
        ssh->pktout.data[i + 4] = random_byte();
-    crc = crc32(ssh->pktout.data + 4, biglen - 4);
+    crc = crc32_compute(ssh->pktout.data + 4, biglen - 4);
     PUT_32BIT(ssh->pktout.data + biglen, crc);
     PUT_32BIT(ssh->pktout.data, len);
 
diff --git a/ssh.h b/ssh.h
index 97600939f2a82daa2b87d63680d2cfda026260fc..11f2d19e6afbb4b70bab7315b6a40319d63aba31 100644 (file)
--- a/ssh.h
+++ b/ssh.h
@@ -73,7 +73,7 @@ void freersakey(struct RSAKey *key);
 typedef unsigned int word32;
 typedef unsigned int uint32;
 
-unsigned long crc32(const void *s, size_t len);
+unsigned long crc32_compute(const void *s, size_t len);
 unsigned long crc32_update(unsigned long crc_input, const void *s, size_t len);
 
 /* SSH CRC compensation attack detector */
index 702d7a08233b081d2880b8c24c88b052c6ddb069..ed20395b7247d73fc515929971056df048d8da18 100644 (file)
--- a/sshcrc.c
+++ b/sshcrc.c
  *
  *  - Compile with no special #defines. Will generate a table
  *    that's already initialised at compile time, and one function
- *    crc32(buf,len) that uses it. Normal usage.
+ *    crc32_compute(buf,len) that uses it. Normal usage.
  *
  *  - Compile with INITFUNC defined. Will generate an uninitialised
- *    array as the table, and as well as crc32(buf,len) it will
- *    also generate void crc32_init(void) which sets up the table
- *    at run time. Useful if binary size is important.
+ *    array as the table, and as well as crc32_compute(buf,len) it
+ *    will also generate void crc32_init(void) which sets up the
+ *    table at run time. Useful if binary size is important.
  *
  *  - Compile with GENPROGRAM defined. Will create a standalone
  *    program that does the initialisation and outputs the table as
@@ -224,7 +224,7 @@ unsigned long crc32_update(unsigned long crcword, const void *buf, size_t len)
     return crcword;
 }
 
-unsigned long crc32(const void *buf, size_t len)
+unsigned long crc32_compute(const void *buf, size_t len)
 {
     return crc32_update(0L, buf, len);
 }