* Fixed warning.

* Use strlcpy() to copy the confstr instead of strncpy().


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22565 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2007-10-15 11:57:28 +00:00
parent dcdb996481
commit c3d49e1317

View File

@ -1,13 +1,18 @@
/*
** Copyright 2002-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the Haiku License.
* Copyright 2002-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#include <unistd.h>
#include <sys/resource.h>
#include <stdio.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/resource.h>
#include <SupportDefs.h>
int
@ -24,7 +29,7 @@ getdtablesize(void)
long
sysconf(int name)
{
// This is about what BeOS does, better POSIX conformance would be nice, though
// TODO: This is about what BeOS does, better POSIX conformance would be nice, though
switch (name) {
case _SC_ARG_MAX:
@ -101,13 +106,12 @@ pathconf(const char *path, int name)
}
#define min_c(a,b) ((a)>(b)?(b):(a))
size_t
confstr(int name, char *buf, size_t len)
confstr(int name, char *buffer, size_t length)
{
size_t string_len = 1;
size_t stringLength = 1;
char *string = "";
switch (name) {
case 0:
break;
@ -115,8 +119,10 @@ confstr(int name, char *buf, size_t len)
errno = EINVAL;
return 0;
}
if (buf != NULL)
strncpy(buf, string, min_c(len, string_len));
return string_len;
if (buffer != NULL)
strlcpy(buffer, string, min_c(length, stringLength));
return stringLength;
}