From: "Randy.Dunlap" <rddunlap@osdl.org>
To: opacki@acn.waw.pl
Cc: linux-kernel@vger.kernel.org
Subject: Re: LKM, problem with simple char from string.
Date: Mon, 16 Aug 2004 14:26:37 -0700 [thread overview]
Message-ID: <20040816142637.69105e2c.rddunlap@osdl.org> (raw)
In-Reply-To: <200408161231.51998.opacki@acn.waw.pl>
On Mon, 16 Aug 2004 12:31:51 +0200 authn wrote:
| Hello,
| I am coding a linux kernel module and have problem with some string from user
| space (from execve system call). There is no problem with useing this string
| as a one, for example printk(KERN_ALERT "%s", string) works fine.
| Problem appears when i want to printk or compare single char, in first case it
| is printked with some extra '<1>' and in second case, when i compare it with
| other one, it doesnt fit to real char (it is "connected" with '<1>' in some
| way ?). I tried to copy it to kmalloced buffer:
|
| if ((k_space=(char *)kmalloc(len, GFP_KERNEL))==NULL)
| return -1;
| memcpy_fromfs((void *)k_space, (void *)argv[argc], len);
|
| but then playing with k_space[i] was the same.
| Short code from module:
| if ((k_space=(char *)kmalloc(len, GFP_KERNEL))==NULL)
| return -1;
| memset(k_space, '\0', sizeof(k_space));
I don't think that this is the main problem, but sizeof(k_space) here
is just the sizeof a pointer (I guess, can't see entire source code),
like 4 or 8.
| memcpy_fromfs((char *)k_space, (char *)argv[argc], len);
| printk(KERN_ALERT"%s\n", k_space);
| printk(KERN_ALERT "%c\n",k_space[i]);
| And then i ll have in log file string (from first printk call) and char with
| <1> (from second printk call). It doesnt let me to compare chars.
| What it happens ?
--
~Randy
prev parent reply other threads:[~2004-08-16 21:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-16 10:31 authn
2004-08-16 21:26 ` Randy.Dunlap [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040816142637.69105e2c.rddunlap@osdl.org \
--to=rddunlap@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=opacki@acn.waw.pl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®