Skip to contentSkip to conversation

libc: Fix strcpy() assignment mistake

PATCH In review Paul Semel 2 participants 2 messages Oct 11, 2017

lore
Share & tools
lore

Paul Semel

author
#0 lore raw

PATCH 1/1 libc: Fix strcpy() assignment mistake

From: Paul Semel <[email protected]>

the strcpy function was doing a comparison instead of doing an assignment.

---
 common/libc/string.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/libc/string.c +1 -1
index 94acc7e..967f2fa 100644
@@ -24,7 +24,7 @@ size_t strnlen(const char *str, size_t max)
 {
     char *p = dst;
 
-    while ( *p++ == *src++ )
+    while ( (*p++ = *src++) )
         ;
 
     return dst;
Signature · 7 lines
1.8.3.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#1 lore raw
Quoted 10 lines · Paul Semel

From: Paul Semel <[email protected]>

the strcpy function was doing a comparison instead of doing an assignment.

Oops.  This issue is hidden due to __builtin_strcpy() optimising all in-tree callsites.

pushed.

common/libc/string.c size_t strnlen(const char *str, size_t max)

Quoted 9 lines
---
 common/libc/string.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/libc/string.c +0 -0
index 94acc7e..967f2fa 100644
@@ -24,7 +24,7 @@ size_t strnlen(const char *str, size_t max)

It looks like git isn't terribly happy with the (strcpy) preprocessor trick.  I did a double-take when I first read the patch.

~Andrew

common/libc/string.c size_t strnlen(const char *str, size_t max) · line 30

Quoted 8 lines
common/libc/string.c +1 -1
 {
     char *p = dst;
 
-    while ( *p++ == *src++ )
+    while ( (*p++ = *src++) )
         ;
 
     return dst;

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel