Patch for the bug on remove_sep().
Ding Yi Chen <[email protected]> Mon, 23 Nov 2009 23:11:43 -0500 (EST)
| Newsgroups | gmane.comp.gnome.devtools.gob.general |
|---|---|
| Message-ID | <1017367425.458471259035903514.JavaMail.root@zmail04.collab.prod.int.phx2.redhat.com> |
------=_Part_17364_450333179.1259035903513
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Hi,
I am using gob2 to develop various projects such as WritRecogn, ibus-chewing, and MakerDialog.
Recently I found that those project are failed to compile. After investigation, I think the problem
might reside in remove_sep(), src/util.c.
In remove_sep(), the code that remove ':' is:
while((p = strchr(s, ':')))
strcpy(p, p+1);
However, according to the man page of strcpy:
"The strings may not overlap, and the destination string dest must be
large enough to receive the copy."
In fact, this code block produces unexpected results in some systems.
For example:
Ma:Class is converted to Ma:Clsss
Ma:Placement is converted to Ma:Plccemnnt
The patch that address this issue is attached.
Regards,
--
Ding-Yi Chen
Software Engineer
Internationalization Group
Red Hat, Inc.
Register now for Red Hat Virtual Experience, December 9.
Enterprise Linux, virtualization, cloud, and more.
http://www.redhat.com/virtualexperience
------=_Part_17364_450333179.1259035903513
Content-Type: application/octet-stream; name=gob2-remove_sep.patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=gob2-remove_sep.patch
diff -up ./src/util.c.orig ./src/util.c
--- ./src/util.c.orig 2009-11-24 13:20:39.000000000 +1000
+++ ./src/util.c 2009-11-24 13:35:54.000000000 +1000
@@ -81,13 +81,17 @@ remove_sep(const char *base)
{
char *p;
char *s = g_strdup(base);
+ char *q=s;
/* don't eat C++ :: thingies */
if (for_cpp && strstr (s, "::") != NULL)
return s;
- while((p = strchr(s, ':')))
- strcpy(p, p+1);
+ for(p=(char *)base;*p;p++){
+ if (*p!=':')
+ *q++=*p;
+ }
+ *q='\0';
return s;
}
------=_Part_17364_450333179.1259035903513
Content-Type: text/plain; charset=us-ascii; name="footer"
Content-Transfer-Encoding: 8bit
--
to unsubscribe:
send mail to [email protected] with "unsubscribe gob-list" in the subject
------=_Part_17364_450333179.1259035903513--