The buffer passed over from the boot loader is now null terminated.

load_driver_settings() now accepts absolute paths as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12808 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-05-25 13:35:46 +00:00
parent 6851f9807c
commit ff229e1ebb

View File

@ -636,11 +636,13 @@ driver_settings_init(kernel_args *args)
return B_NO_MEMORY; return B_NO_MEMORY;
if (settings->size != 0) { if (settings->size != 0) {
handle->text = malloc(settings->size); handle->text = malloc(settings->size + 1);
if (handle->text == NULL) if (handle->text == NULL)
return B_NO_MEMORY; return B_NO_MEMORY;
memcpy(handle->text, settings->buffer, settings->size); memcpy(handle->text, settings->buffer, settings->size);
handle->text[settings->size] = '\0';
// null terminate the buffer
} else } else
handle->text = NULL; handle->text = NULL;
@ -709,6 +711,7 @@ load_driver_settings(const char *driverName)
// we got it, now let's see if it already has been parsed // we got it, now let's see if it already has been parsed
if (handle->magic != SETTINGS_MAGIC) { if (handle->magic != SETTINGS_MAGIC) {
handle->magic = SETTINGS_MAGIC; handle->magic = SETTINGS_MAGIC;
if (parse_settings(handle) != B_OK) { if (parse_settings(handle) != B_OK) {
// no valid settings, let's cut down its memory requirements // no valid settings, let's cut down its memory requirements
free(handle->text); free(handle->text);
@ -741,7 +744,7 @@ load_driver_settings(const char *driverName)
#endif #endif
// open the settings from the standardized location // open the settings from the standardized location
{ if (driverName[0] != '/') {
char path[B_FILE_NAME_LENGTH + 64]; char path[B_FILE_NAME_LENGTH + 64];
// ToDo: use the kernel's find_directory for this // ToDo: use the kernel's find_directory for this
@ -749,7 +752,9 @@ load_driver_settings(const char *driverName)
strlcat(path, driverName, sizeof(path)); strlcat(path, driverName, sizeof(path));
file = open(path, O_RDONLY); file = open(path, O_RDONLY);
} } else
file = open(driverName, O_RDONLY);
if (file < B_OK) { if (file < B_OK) {
#ifdef _KERNEL_MODE #ifdef _KERNEL_MODE
mutex_unlock(&sLock); mutex_unlock(&sLock);