Project

Profile

Help

Bug #2691

closed

longer custom path to

Added by Roger Martin over 8 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Category:
Saxon-C Internals
Start date:
2016-03-31
Due date:
% Done:

100%

Estimated time:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Found in version:
1.0.0
Fixed in version:
1.0.1
SaxonC Languages:
SaxonC Platforms:
SaxonC Architecture:

Description

Hi,

When the SAXONC_HOME is set to a path longer than the "/usr/lib" the concatenation that uses dllname and resources_dir falls off the size of the memory allocated for each

SaxonCGlue.h

@

    "/usr/libr/libsaxonhec.so";  //rename according to product edition (hec or pec) Also make change in the c file

@

my local work around is

@

    "/usr/libr/libsaxonhec.so\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";  //rename according to product edition (hec or pec) Also make change in the c file

@

and similarly for resources_dir.

yet this could be too short too but for my use my custom path fits within.

in SaxonCGlue.c

@

if(getenv("SAXONC_HOME")!= NULL) {


	char * env = getenv("SAXONC_HOME");

	size_t env_len = strlen(env);

	size_t name_len =  15;

	size_t rDir_len = 11;

	//dllname =malloc(sizeof(char)*name_len);

	//resources_dir =malloc(sizeof(char)*rDir_len);

	memset(&dllname[0], 0, sizeof(dllname));

	memset(&resources_dir[0], 0, sizeof(resources_dir));

	strncat(resources_dir, env,  env_len);

	strncat(resources_dir, "/saxon-data", rDir_len);

	strncat(dllname, env, env_len);

	strncat(dllname, "/libsaxonhec.so", name_len); //rename according to product edition (-hec or -pec)

#ifdef DEBUG

	printf("resources_dir: %s\n", resources_dir);	

	printf("envDir: %s\n", env);

	printf("size of env %i\n", strlen(env));

	printf("size of dllname %i\n", strlen(dllname));

	printf("dllName: %s\n", dllname);

	printf("resources_dir: %s\n", resources_dir);

#endif

}

@

I don't think the strncat and related functions actually expand the allocation of these variables


Related issues

Related to SaxonC - Bug #3117: Unable to load libsaxoneec. with missing .so extensionClosedO'Neil Delpratt2017-01-26

Actions
Actions #1

Updated by O'Neil Delpratt over 8 years ago

  • Status changed from New to In Progress
  • Found in version set to 1.0.0

Yes you are right there is a problem here. I think we can use malloc to set the size of dllname. Something like the following:

dllname =malloc(sizeof(char)*name_len+env_len+1);

I will try to get this fix in the maintenance release which should be out shortly.

Actions #2

Updated by O'Neil Delpratt over 8 years ago

  • Category set to Saxon-C Internals
  • Status changed from In Progress to Resolved
  • Assignee set to O'Neil Delpratt
  • Priority changed from Low to Normal
  • % Done changed from 0 to 100

I have redesigned how we set the Saxon/C library and resources path locations. This applies for both the default and when we set the SAXONC_HOME environment variable. As mentioned in comment #1 we now create these variables on the heap using malloc@. I found using @snprintf to concatenate the path with the file name much cleaner.

The key files in this fix are SaxonCGlue.h, SaxonCGlue.C and SaxonProcessor.cpp

Bug fixed and committed to subversion. The patch will be available in the next maintenance release.

Actions #3

Updated by O'Neil Delpratt over 8 years ago

  • Status changed from Resolved to Closed
  • Fixed in version set to 1.0.1

Bug fix applied in the Saxon/C 1.0.1 maintenance release.

Actions #4

Updated by O'Neil Delpratt almost 8 years ago

  • Related to Bug #3117: Unable to load libsaxoneec. with missing .so extension added

Please register to edit this issue

Also available in: Atom PDF