svn commit: r205118 - head/sbin/sysctl
Garrett Cooper
yanefbsd at gmail.com
Sat Mar 13 21:13:52 UTC 2010
On Sat, Mar 13, 2010 at 3:08 AM, Bruce Cran <brucec at freebsd.org> wrote:
> Author: brucec
> Date: Sat Mar 13 11:08:57 2010
> New Revision: 205118
> URL: http://svn.freebsd.org/changeset/base/205118
>
> Log:
> Free the memory allocated via strdup.
>
> PR: bin/113881
> Submitted by: Alexander Drozdov dzal_mail mtu-net.ru
> Approved by: rrs (mentor)
> MFC after: 1 week
>
> Modified:
> head/sbin/sysctl/sysctl.c
>
> Modified: head/sbin/sysctl/sysctl.c
> ==============================================================================
> --- head/sbin/sysctl/sysctl.c Sat Mar 13 11:06:47 2010 (r205117)
> +++ head/sbin/sysctl/sysctl.c Sat Mar 13 11:08:57 2010 (r205118)
> @@ -382,6 +382,7 @@ S_timeval(int l2, void *p)
> if (*p2 == '\n')
> *p2 = '\0';
> fputs(p1, stdout);
> + free(p1);
> return (0);
> }
strdup(3) can fail in that section of code, thus the fputs(3)
could segfault:
[gcooper at bayonetta ~]$ cat foo.c
#include <string.h>
#include <stdio.h>
int main(void) {
char *foo = NULL;
fputs(foo, stdout);
free(foo);
return 0;
}
[gcooper at bayonetta ~]$ gcc -o foo foo.c
[gcooper at bayonetta ~]$ ./foo
Segmentation fault: 11 (core dumped)
Could a...
if (p1 == NULL)
... be added before the fputs(3) please?
Thanks,
-Garrett
More information about the svn-src-head
mailing list