ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  /dev/hello_world: A Simple Introduction to Device Drivers under Linux
Subject:   Small problem in hello_proc.c?
Date:   2007-07-08 06:12:15
From:   stderr.dk
I think there is a small problem in hello_proc.c.


First you check whether "size" is small then "len" and if so, return -EINVAL.


If not (and offset==0), you do strcpy(buffer, hello_str); but strcpy() will copy strlen(hello_str) + 1 bytes (since it also copy a '\0' to "buffer").


If size==len, the buffer only has enough space for "len" bytes, but you're copying "len"+1 bytes.


Shouldn't it be something like


if(size <= len)
return -EINVAL;


?


1 to 1 of 1
  1. Small problem in hello_proc.c?
    2007-07-08 11:47:27  valhenson [View]

1 to 1 of 1