chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[PATCH] apply default permissions only for devices that will need it
[elogind.git]
/
udev_libc_wrapper.c
diff --git
a/udev_libc_wrapper.c
b/udev_libc_wrapper.c
index 16d90913cf84606d38cf5ac794cd391b957f29d7..1852141c9378c7baa9b389013ed838a90a2d9871 100644
(file)
--- a/
udev_libc_wrapper.c
+++ b/
udev_libc_wrapper.c
@@
-36,11
+36,15
@@
#define __OWN_USERDB_PARSER__
#endif
#define __OWN_USERDB_PARSER__
#endif
+#ifdef __GLIBC__
+#define __OWN_STRLCPYCAT__
+#endif
+
#ifdef USE_STATIC
#define __OWN_USERDB_PARSER__
#endif
#ifdef USE_STATIC
#define __OWN_USERDB_PARSER__
#endif
-#if
ndef strlcpy
+#if
def __OWN_STRLCPYCAT__
size_t strlcpy(char *dst, const char *src, size_t size)
{
size_t bytes = 0;
size_t strlcpy(char *dst, const char *src, size_t size)
{
size_t bytes = 0;
@@
-49,17
+53,18
@@
size_t strlcpy(char *dst, const char *src, size_t size)
char ch;
while ((ch = *p++)) {
char ch;
while ((ch = *p++)) {
- if (bytes < size)
+ if (bytes
+1
< size)
*q++ = ch;
bytes++;
}
*q++ = ch;
bytes++;
}
- *q = '\0';
+ /* If size == 0 there is no space for a final null... */
+ if (size)
+ *q = '\0';
+
return bytes;
}
return bytes;
}
-#endif
-#ifndef strlcat
size_t strlcat(char *dst, const char *src, size_t size)
{
size_t bytes = 0;
size_t strlcat(char *dst, const char *src, size_t size)
{
size_t bytes = 0;
@@
-71,9
+76,11
@@
size_t strlcat(char *dst, const char *src, size_t size)
q++;
bytes++;
}
q++;
bytes++;
}
+ if (bytes == size)
+ return (bytes + strlen(src));
while ((ch = *p++)) {
while ((ch = *p++)) {
- if (bytes < size)
+ if (bytes
+1
< size)
*q++ = ch;
bytes++;
}
*q++ = ch;
bytes++;
}
@@
-81,7
+88,7
@@
size_t strlcat(char *dst, const char *src, size_t size)
*q = '\0';
return bytes;
}
*q = '\0';
return bytes;
}
-#endif
+#endif
/* __OWN_STRLCPYCAT__ */
#ifndef __OWN_USERDB_PARSER__
#include <sys/types.h>
#ifndef __OWN_USERDB_PARSER__
#include <sys/types.h>