Re: [PATCH] [TRIVIAL] kstrdup

Valdis.Kletnieks@vt.edu
Mon, 13 Jan 2003 22:53:32 -0500


--==_Exmh_1507362016P
Content-Type: text/plain; charset=us-ascii

On Mon, 13 Jan 2003 22:38:03 EST, Jeff Garzik said:
> On Mon, Jan 13, 2003 at 10:28:14PM -0500, Valdis.Kletnieks@vt.edu wrote:
> > Out of curiosity, who's job is it to avoid the race condition between when
> > this function takes the strlen() and the other processor makes it a longer
> > string before we return from kmalloc() and do the strcpy()?
>
> The caller's.

That's cool, long as everybody agrees on that - I've already filled my career
quota of chasing down bugs due to non-threadsafe use of str*() functions. ;)

All the same, I'd probably feel better if it used strncpy() instead - there'd
still be the possibility of copying now-stale data, but at least you'd not be
able to walk off the end of the *new* array's allocated space....

/Valdis

--==_Exmh_1507362016P
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Exmh version 2.5 07/13/2001

iD8DBQE+I4m8cC3lWbTT17ARAiTKAJ97vumfkUOAplSMG2IQN7rGMQ7wrgCg8PBW
ekSMhqHvDjTVxIw9RK+m928=
=/7gx
-----END PGP SIGNATURE-----

--==_Exmh_1507362016P--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/