chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
increase kernel uevent buffer size
[elogind.git]
/
udev_libc_wrapper.c
diff --git
a/udev_libc_wrapper.c
b/udev_libc_wrapper.c
index 0dafe4d077bb344bdd7dc95adf260f6d822742ca..02a1f8d016c2a7273e0d5e31f547964105d212d9 100644
(file)
--- a/
udev_libc_wrapper.c
+++ b/
udev_libc_wrapper.c
@@
-27,20
+27,21
@@
#include <fcntl.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/types.h>
-#include "../udev_libc_wrapper.h"
-#include "../udev.h"
-#include "../udev_utils.h"
-#include "../logging.h"
+#include "udev.h"
#ifdef __KLIBC__
#define __OWN_USERDB_PARSER__
#endif
#ifdef __KLIBC__
#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
+50,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
+73,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
+85,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>
@@
-95,7
+99,7
@@
uid_t lookup_user(const char *user)
pw = getpwnam(user);
if (pw == NULL)
pw = getpwnam(user);
if (pw == NULL)
-
dbg
("specified user unknown '%s'", user);
+
info
("specified user unknown '%s'", user);
else
uid = pw->pw_uid;
else
uid = pw->pw_uid;
@@
-109,7
+113,7
@@
gid_t lookup_group(const char *group)
gr = getgrnam(group);
if (gr == NULL)
gr = getgrnam(group);
if (gr == NULL)
-
dbg
("specified group unknown '%s'", group);
+
info
("specified group unknown '%s'", group);
else
gid = gr->gr_gid;
else
gid = gr->gr_gid;
@@
-137,10
+141,10
@@
static unsigned long get_id_by_name(const char *uname, const char *dbfile)
char *tail;
if (file_map(dbfile, &buf, &bufsize) != 0) {
char *tail;
if (file_map(dbfile, &buf, &bufsize) != 0) {
-
dbg("can't open '%s' as db file", dbfile
);
+
err("can't open '%s' as db file: %s", dbfile, strerror(errno)
);
return 0;
}
return 0;
}
- dbg("
reading '%s' as db file"
, dbfile);
+ dbg("
search '%s' in '%s'", uname
, dbfile);
/* loop through the whole file */
cur = 0;
/* loop through the whole file */
cur = 0;
@@
-152,7
+156,8
@@
static unsigned long get_id_by_name(const char *uname, const char *dbfile)
if (count >= sizeof(line))
continue;
if (count >= sizeof(line))
continue;
- strlcpy(line, bufline, count);
+ memcpy(line, bufline, count-1);
+ line[count-1] = '\0';
pos = line;
/* get name */
pos = line;
/* get name */