2004-06-28 18:43:47

by so usp

[permalink] [raw]
Subject: Doubt

Hi...

i would like to know how to copy a string such as
"Test" to a char vector (char buffer[256]) in kernel
mode.

Thanks,
Luis Henrique.

______________________________________________________________________

Yahoo! Mail - agora com 100MB de espa?o, anti-spam e antiv?rus gr?tis!
http://br.info.mail.yahoo.com/


2004-06-28 18:59:36

by Esteve Espuña Sargatal

[permalink] [raw]
Subject: Re: Doubt

Example from arch/i386/kernel/kgdb_stub.c:


#include <asm/string.h> /* for strcpy */

static char remcomOutBuffer[BUFMAX];

strcpy(remcomOutBuffer, "OK");

Hope it's ok.

On Mon, 2004-06-28 at 20:43, so usp wrote:
> Hi...
>
> i would like to know how to copy a string such as
> "Test" to a char vector (char buffer[256]) in kernel
> mode.
>
> Thanks,
> Luis Henrique.
>
> ______________________________________________________________________
>
> Yahoo! Mail - agora com 100MB de espa?o, anti-spam e antiv?rus gr?tis!
> http://br.info.mail.yahoo.com/
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>

2004-06-28 19:59:11

by Christophe Saout

[permalink] [raw]
Subject: Re: Doubt

Am Mo, den 28.06.2004 um 20:59 Uhr +0200 schrieb Esteve Espuña Sargatal:

> #include <asm/string.h> /* for strcpy */
>
> static char remcomOutBuffer[BUFMAX];
>
> strcpy(remcomOutBuffer, "OK");
>
> Hope it's ok.

Not really. Well, this example here works, but only if you know that you
won't overflow the buffer.

strlcpy(emcomOutBuffer, "OK", BUFMAX);

(replace "OK" with the string you wish to copy)


Attachments:
signature.asc (189.00 B)
Dies ist ein digital signierter Nachrichtenteil