Re: What's wrong with this RC4?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


sci.crypt archive

Re: What's wrong with this RC4?

From: Chris Barts <puonegf+hfrarg@tznvy.pbz>
Date: Wed Dec 28 2005 - 18:14:32 CET

Andrew Pogrebennyk <andrew86@voliacable.com> wrote on Wednesday 28 December
2005 04:56 in sci.crypt <pan.2005.12.28.11.56.35.888981@voliacable.com>:

> int main()

int main(void)

>
> cipher = calloc (SIZEOF(plain), sizeof(plain[0]));

What if calloc() fails? Always wrap these calls in if statements like so:

  if ((cipher = calloc(sizeof(plain), sizeof(plain[0])) == NULL) {
      fprintf(stderr, "rc4: calloc() failed\n");
      exit(EXIT_FAILURE);
  }

Of course, you might have a more intelligent failure mode in mind than that.
For this program, however, that is plenty good enough.

>
> free (cipher);

You'd be surprised how often people fail to do this.

> return 0;

And this.

-- 
My address happens to be com (dot) gmail (at) usenet (plus) chbarts,
wardsback and translated.
It's in my header if you need a spoiler.
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Received on Tue Jan 3 03:41:40 2006