char name[nname + /*length of longest extension:*/24];
/* note to myself: better check that length! */
char *p = xstpncpy(name, filename, nname+1);
+ size_t remain = name + sizeof(name) - p;
for (Lisp_Object ext = Vmodule_extensions;
CONSP(ext); ext = XCDR(ext)) {
continue;
}
- strncpy(p, (const char*)XSTRING_DATA(XCAR(ext)),
- (size_t)XSTRING_LENGTH(XCAR(ext))+1);
+ xstrncpy(p, (const char*)XSTRING_DATA(XCAR(ext)),
+ remain);
if (__file_exists_p(name)) {
EMOD_DEBUG_LOADER("trying %s\n", name);
char *p;
p = xstpncpy(name,
(const char*)XSTRING_DATA(XCAR(path)),
- (size_t)XSTRING_LENGTH(XCAR(path)));
+ sizeof(name)-2);
*p++ = '/';
- strncpy(p, filename, nfilename+1);
+ *p = '\0';
+ xstrncpy(p, filename, name + sizeof(name) - p);
if (__file_exists_p(name)) {
EMOD_DEBUG_LOADER("trying %s\n", name);
* carries the correct extension
* see __emodng_open_prepend_paths_append_exts for
* cope with all the combinations */
- char *p = xstpncpy(
- name,
+ char *p = xstpncpy(name,
(const char*)XSTRING_DATA(XCAR(path)),
- (size_t)XSTRING_LENGTH(XCAR(path)));
+ sizeof(name)-2);
+ int remain;
if (*(p-1) != '/') {
*p++ = '/';
+ *p = '\0';
}
- p = xstpncpy(p, filename, nfilename);
+ remain = name+sizeof(name)-p;
+ p = xstpncpy(p, filename, remain);
+ remain = name+sizeof(name)-p;
/* append all extensions now */
for (Lisp_Object ext = Vmodule_extensions;
continue;
}
- strncpy(p,
- (const char*)XSTRING_DATA(XCAR(ext)),
- (size_t)XSTRING_LENGTH(XCAR(ext))+1);
+ xstrncpy(p,(const char*)XSTRING_DATA(XCAR(ext)),
+ remain);
if (__file_exists_p(name)) {
EMOD_DEBUG_LOADER("trying \"%s\"\n",
if (LIKELY((STRINGP(lse)))) {
p = xstpncpy(p,
(const char*)XSTRING_DATA(lse),
- XSTRING_LENGTH(lse));
+ sp+sizeof(sp)-p-1);
*p++ = ':';
}
}