Re: modulo encrypt problem

From: Richard Bos (rlb_at_hoekstra-uitgeverij.nl)
Date: 10/19/04


Date: Tue, 19 Oct 2004 14:38:33 GMT

john blackburn <john.blackburnNOSPAMPLS@lintonhealy.co.uk> wrote:

> for (count=0; count < (strlen(pattern)-4); count++) {
>
> digval = ((*(pattern+strlen(pattern)-count-1)-'0')+key[strlen(pattern)-count-1]+digval)%10;
> *(pattern+4+count) = digval+'0';

Assuming that strlen(pattern)>5, you're scribbling over your own input
buffer. When count==0, you read from pattern[strlen(pattern)-1], but you
write to pattern[4]. By the time count gets to strlen(pattern)-5, you
write to pattern[strlen(pattern)-1], but you read from pattern[4]...
which already contains its new value. The original values of the early
members of pattern never even get read. You need to use a second buffer
to hold the output while you still need the original value of pattern.

Richard



Relevant Pages

  • Re: "secure" file flag?
    ... necessary to flush the data through the drive cache. ... onto the platters after you have applied each pattern. ... > buffer contents is prepared for the next step of the erasure process, ... to the conclusion disk encryption is probably a lower-cost solution. ...
    (freebsd-hackers)
  • Re: RegEx partial matching
    ... If you don't want your buffer to be too big, ... you can safely discard the lower 10 characters. ... > like to be safe and just keep 3x the length of the pattern I'm looking ... I want to match full featured regular expressions not just fixed ...
    (comp.lang.java.programmer)
  • Re: regular expression reverse match?
    ... >> determines if the buffer is acceptable against a pattern as the string ... >> added to the buffer as long as it's within the pattern. ... >I don't think its possible with regular expressions, or at least the way you ... I compared rex to simplifying a math problem like ...
    (comp.lang.python)
  • [newbie] _lfind syntax problem
    ... UINT bufferlen; ... BYTE *pattern; //holds pointer to pattern to search for ... Now, I've decided to use _lfind for this searching (I'm not using bsearch, ...
    (microsoft.public.dotnet.languages.vc)
  • [newbie] _lfind syntax problem
    ... UINT bufferlen; ... BYTE *pattern; //holds pointer to pattern to search for ... Now, I've decided to use _lfind for this searching (I'm not using bsearch, ...
    (microsoft.public.vc.language)