This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/2703] envz_strip() works incorrectly
- From: "rsa at us dot ibm dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 2 Jun 2006 17:53:23 -0000
- Subject: [Bug libc/2703] envz_strip() works incorrectly
- References: <20060529035214.2703.Joy.lists@gmail.com>
- Reply-to: sourceware-bugzilla at sourceware dot org
------- Additional Comments From rsa at us dot ibm dot com 2006-06-02 17:53 -------
Created an attachment (id=1062)
--> (http://sourceware.org/bugzilla/attachment.cgi?id=1062&action=view)
envz_split() patch to fix reversed src & dest pointers when invoking memmove().
Here's a better testcase:
#include <stdio.h>
#include <envz.h>
#include <stdlib.h>
int main() {
size_t size = 0;
char **argz;
char *str=malloc(100);
argz = &str;
argz_add_sep(argz, &size, "(a=1)", '\0');
argz_add_sep(argz, &size, "(b=2)", '\0');
argz_add_sep(argz, &size, "(*)", '\0');
argz_add_sep(argz, &size, "(*)", '\0');
argz_add_sep(argz, &size, "(e=5)", '\0');
argz_add_sep(argz, &size, "(f=)", '\0');
argz_add_sep(argz, &size, "(*)", '\0');
argz_add_sep(argz, &size, "(h=8)", '\0');
argz_add_sep(argz, &size, "(i=9)", '\0');
argz_add_sep(argz, &size, "(j)", '\0');
write(1, *argz, size);
printf("\ncalling envz_strip with size=%d\n", size);
envz_strip(argz, &size);
write(1, *argz, size);
printf("\nsize=%d\n", size);
argz=0;
free(str);
return 0;
}
Sean Lee is correct. This was a problem of reversed src & dest pointers when
invoking memmove() within envz_split. Getting a periodic segmentation
violation was unpredictably related to the improper memmove() invocation. The
attached patch corrects the problem in my tests.
--
http://sourceware.org/bugzilla/show_bug.cgi?id=2703
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.