* 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:
@@ -1,13 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright 2002-2004, Axel Dörfler, [email protected]. All rights reserved.
|
* Copyright 2002-2007, Axel Dörfler, [email protected]. All rights reserved.
|
||||||
** Distributed under the terms of the Haiku License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/resource.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
|
||||||
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -24,7 +29,7 @@ getdtablesize(void)
|
|||||||
long
|
long
|
||||||
sysconf(int name)
|
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) {
|
switch (name) {
|
||||||
case _SC_ARG_MAX:
|
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
|
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 = "";
|
char *string = "";
|
||||||
|
|
||||||
switch (name) {
|
switch (name) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
@@ -115,8 +119,10 @@ confstr(int name, char *buf, size_t len)
|
|||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (buf != NULL)
|
|
||||||
strncpy(buf, string, min_c(len, string_len));
|
if (buffer != NULL)
|
||||||
return string_len;
|
strlcpy(buffer, string, min_c(length, stringLength));
|
||||||
|
|
||||||
|
return stringLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user