This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [open-source] Re: Wish for 2002 ...


<mouring@etoh.eviladmin.org> writes:

> On Fri, 11 Jan 2002, Linus Torvalds wrote:
> 
> >
> > On Fri, 11 Jan 2002, Markus Friedl wrote:
> >
> > > On Thu, Jan 10, 2002 at 04:37:27PM -0800, Paul Eggert wrote:
> > > > 	len = strlen(challenge) + strlen(PROMPT) + 1;
> > > > 	p = xmalloc(len);
> > > > 	p[0] = '\0';
> > > > 	strlcat(p, challenge, len);
> > > > 	strlcat(p, PROMPT, len);
> 
> No where else do we do this unless we are in a loop where we can not use
> strlcpy() to create a base string (or that I see off hand).

 I see you are listed in the CREDITS file so here's a free clue...

/* non portable - easy */

 if (apsrintf(&p, "%s%s", challenge, PROMPT) < 0)
  /* error path -- looks like call abort() from above */;

/* portable - faster */

len_chal = strlen(challenge);
len_prompt = strlen(PROMPT);
tmp = p = xmalloc(len_chal + len_prompt + 1);

memcpy(tmp, challenge, len_chal);
tmp += len_chal;
memcpy(tmp, PROMPT, len_prompt + 1);

-- 
# James Antill -- james@and.org
:0:
* ^From: .*james@and\.org
/dev/null


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]