Re:Android Project Changeset 4f8b683: libc/memset.c
by jared314 on Tuesday May 25, 2010 @07:42PM
(#1379031)
Can someone who lives in the world of C fill in the blanks?
If this was a major typo, I have done things along those lines.
[ Parent
| on HN ]
Re:Android Project Changeset 4f8b683: libc/memset.c
by justinweiss on Tuesday May 25, 2010 @07:47PM
(#1379043)
memset sets a block of memory to a given value. It is often used to initialize an uninitialized block of memory to 0. So often, in fact, that this bug where it always initialized the memory to 0 survived so long.
Re:Android Project Changeset 4f8b683: libc/memset.c
by abstractbill on Tuesday May 25, 2010 @08:23PM
(#1379109)
So often, in fact, that this bug where it always initialized the memory to 0 survived so long.
Given that the bug went undetected for so long, I think you could almost reasonably claim that calling memset with a nonzero parameter is a "corner case" ;)
Re:Android Project Changeset 4f8b683: libc/memset.c
by Psyonic on Thursday May 27, 2010 @06:12PM
(#1385093)
It is a "corner case," or close to it, but that's not why it wasn't caught here. I don't think this code is ever called, as explained above. It's default code in case there isn't a platform specific version, but there pretty much always is a platform specific version.
Re:Android Project Changeset 4f8b683: libc/memset.c
by fserb on Tuesday May 25, 2010 @08:45PM
(#1379165)
on Google code search: "lang:c memset\(.+,\s[^0]+\s,.+\)" return 32k results and "lang:c memset\(.+,\s0+\s,.+\)" returns 335k.
Re:Android Project Changeset 4f8b683: libc/memset.c
by wlievens on Wednesday May 26, 2010 @03:14AM
(#1379718)
10% is a lot more than I would have thought, wow. Good job looking that up.
Re:Android Project Changeset 4f8b683: libc/memset.c
by mey on Tuesday May 25, 2010 @07:56PM
(#1379061)
Wish there was a cross-link to a bug tracking system where this was initially reported.
Re:Android Project Changeset 4f8b683: libc/memset.c
by pufuwozu on Tuesday May 25, 2010 @08:00PM
(#1379067)
You can just search for the change ID:
Re:Android Project Changeset 4f8b683: libc/memset.c
by draebek on Tuesday May 25, 2010 @07:48PM
(#1379045)
memset's job is to fill a block of memory with a given byte. The most common fill byte is 0, to initialize or otherwise clear a buffer. It looks like it is so common, in fact, that a programmer accidentally made Android's memset _always_ fill with 0, no matter what byte was passed in, and presumably no one noticed for a while. (I can't figure out when this patch was introduced.)
Re:Android Project Changeset 4f8b683: libc/memset.c
by jared314 on Tuesday May 25, 2010 @07:50PM
(#1379050)
The "Up to change" link takes you to the summary. May 13, 2010
Re:Android Project Changeset 4f8b683: libc/memset.c
by fourneau on Tuesday May 25, 2010 @07:48PM
(#1379048)
Memset (according to the c++ reference) is supposed to: "Sets the first num bytes of the block of memory pointed by ptr to the specified value (interpreted as an unsigned char)."
So, give it a pointer to some memory, give it a value and the number of bytes you want to set and it'll go wild. In this case, memset was just blindly dropping in zeroes into the memory block