Re: htdig: core problem with modified htsearch :(


Gilles Detillieux (grdetil@scrc.umanitoba.ca)
Wed, 20 Jan 1999 16:45:41 -0600 (CST)


According to Doug:
>
> Well I'm getting closer to my goal, but I have an (what I'm hoping is a
> small) error in my code that causes htsearch to "work" in the sense that
> sending it a fake test on the command line outputs the desired html, but
> it cores every time it runs.
>
> I'm a decent C programmer, but my C++ leaves a lot to be desired. Here
> is what I've done:
>
>
> *** htdig-3.1.0b4/htsearch/Display.cc Tue Dec 22 18:15:39 1998
> --- htdig-3.1.0b4-mod/htsearch/Display.cc Wed Jan 20 13:13:22 1999
> ***************
> *** 265,272 ****
> {
> vars.Add("EXCERPT", excerpt(ref));
> }
> char *url = match->getURL();
> ! vars.Add("URL", new String(url));
> vars.Add("SCORE", new String(form("%d", match->getScore())));
> vars.Add("CURRENT", new String(form("%d", current)));
> char *title = ref->DocTitle();
> --- 265,280 ----
> {
> vars.Add("EXCERPT", excerpt(ref));
> }
> +
> char *url = match->getURL();
> !
> ! size_t sn_max_qs_size = 128;
> ! char *sn_query_string =
> "?track=00101.00015.005.00012.001-99010613001212638\0";
> !
> ! char *new_url = strncat(url, sn_query_string, sn_max_qs_size);
> !
> ! vars.Add("URL", new String(new_url));
> !
> vars.Add("SCORE", new String(form("%d", match->getScore())));
> vars.Add("CURRENT", new String(form("%d", current)));
> char *title = ref->DocTitle();
>

Yikes! NO! You can't just overwrite the string returned by
match->getURL(), as you're doing with strncat(), because you have no idea
how much extra memory is available in the string. I haven't tested this,
but I think what you want is something more like:

        char *url = match->getURL();
        String *new_url = new String(url);
        *new_url << "?track=00101.00015.005.00012.001-99010613001212638";
        vars.Add("URL", new_url);

-- 
Gilles R. Detillieux              E-mail: <grdetil@scrc.umanitoba.ca>
Spinal Cord Research Centre       WWW:    http://www.scrc.umanitoba.ca/~grdetil
Dept. Physiology, U. of Manitoba  Phone:  (204)789-3766
Winnipeg, MB  R3E 3J7  (Canada)   Fax:    (204)789-3930
----------------------------------------------------------------------
To unsubscribe from the htdig mailing list, send a message to
htdig-request@sdsu.edu containing the single word "unsubscribe" in
the body of the message.



This archive was generated by hypermail 2.0b3 on Mon Jan 25 1999 - 08:15:23 PST