X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=udev_libc_wrapper.c;h=4e9f9f1fe87108625ae539fbf4823a8a1b061ed4;hp=23cb7b43168bc9ff7c3619bcf1440627f67f8b42;hb=b4f192f054410bf9ddd04b770f0b46f0fd25abce;hpb=8a4c0c32f4252efb0f0adbf5cdc0261d359cd568 diff --git a/udev_libc_wrapper.c b/udev_libc_wrapper.c index 23cb7b431..4e9f9f1fe 100644 --- a/udev_libc_wrapper.c +++ b/udev_libc_wrapper.c @@ -58,7 +58,10 @@ size_t strlcpy(char *dst, const char *src, size_t size) bytes++; } - *q = '\0'; + /* If size == 0 there is no space for a final null... */ + if (size) + *q = '\0'; + return bytes; } @@ -156,7 +159,8 @@ static unsigned long get_id_by_name(const char *uname, const char *dbfile) if (count >= sizeof(line)) continue; - strlcpy(line, bufline, count); + memcpy(line, bufline, count-1); + line[count-1] = '\0'; pos = line; /* get name */