/*
- * $Id: nad.c,v 1.12 2005-04-28 20:49:20 bfernhomberg Exp $
+ * $Id: nad.c,v 1.13 2006-09-18 01:06:44 didg Exp $
*/
#ifdef HAVE_CONFIG_H
goto utompath_error;
}
- mpath[outlen] = 0;
if (flags & CONV_REQMANGLE)
goto utompath_error;
fprintf (stderr, "conversion from %s to %s for %s failed.", vol.v_maccodepage, vol.v_volcodepage, mpath);
return(mtoupathcap( upath ));
}
- upath[outlen] = 0;
return( upath );
}
from_charset, to_charset, name, ntohl(cur_did));
return name;
}
- buffer[outlen] = 0;
if (!strcmp(buffer, name)) {
return name;
from_charset, to_charset, name, ntohl(cur_did));
return name;
}
- buffer[outlen] = 0;
+
if (strcmp (name, buffer)) {
if (dry_run) {
fprintf(stdout, "dry_run: would rename %s to %s.\n", name, buffer);
if ((c1.rbitmap & (1<<DIRPBIT_LNAME))) {
if ( (size_t)(-1) == (len = convert_string(vol->v_maccharset, CH_UCS2, path->m_name, strlen(path->m_name), convbuf, 512)) )
goto crit_check_ret;
- convbuf[len] = 0;
+
if ((c1.rbitmap & (1<<CATPBIT_PARTIAL))) {
if (strcasestr_w( (ucs2_t*) convbuf, (ucs2_t*) c1.lname) == NULL)
goto crit_check_ret;
if ( (size_t)(-1) == (len = convert_charset( CH_UTF8_MAC, CH_UCS2, CH_UTF8, path->m_name, strlen(path->m_name), convbuf, 512, &flags))) {
goto crit_check_ret;
}
- convbuf[len] = 0;
+
if (c1.rbitmap & (1<<CATPBIT_PARTIAL)) {
if (strcasestr_w((ucs2_t *) convbuf, (ucs2_t*)c1.utf8name) == NULL)
goto crit_check_ret;
/* Get the long filename */
memcpy(tmppath, bspec1 + spec1[1] + 1, (bspec1 + spec1[1])[0]);
tmppath[(bspec1 + spec1[1])[0]]= 0;
- len = convert_string ( vol->v_maccharset, CH_UCS2, tmppath, strlen(tmppath), c1.lname, 64);
+ len = convert_string ( vol->v_maccharset, CH_UCS2, tmppath, strlen(tmppath), c1.lname, sizeof(c1.lname));
if (len == (size_t)(-1))
return AFPERR_PARAM;
- c1.lname[len] = 0;
#if 0
/* FIXME: do we need it ? It's always null ! */
len = convert_charset(CH_UTF8_MAC, CH_UCS2, CH_UTF8, c1.utf8name, namelen, c1.utf8name, 512, &flags);
if (len == (size_t)(-1))
return AFPERR_PARAM;
- c1.utf8name[len]=0;
}
/* Call search */
/*
- * $Id: mangle.c,v 1.17 2005-04-28 20:49:44 bfernhomberg Exp $
+ * $Id: mangle.c,v 1.18 2006-09-18 01:06:44 didg Exp $
*
* Copyright (c) 2002. Joe Marcus Clarke (marcus@marcuscom.com)
* All Rights Reserved. See COPYRIGHT.
static char *demangle_checks ( const struct vol *vol, char* uname, char * mfilename, size_t prefix, char * ext)
{
u_int16_t flags;
- static char buffer[MAXPATHLEN +1];
+ static char buffer[MAXPATHLEN];
size_t len;
size_t mfilenamelen;
/*
- * $Id: status.c,v 1.17 2005-05-03 14:55:10 didg Exp $
+ * $Id: status.c,v 1.18 2006-09-18 01:06:44 didg Exp $
*
* Copyright (c) 1990,1993 Regents of The University of Michigan.
* All Rights Reserved. See COPYRIGHT.
nbp_name(server, &Obj, &Type, &Zone);
if ((size_t)-1 == (len = convert_string(
options->unixcharset, options->maccharset,
- Obj, strlen(Obj), buf, 31)) ) {
+ Obj, strlen(Obj), buf, sizeof(buf))) ) {
len = MIN(strlen(Obj), 31);
*data++ = len;
memcpy( data, Obj, len );
}
}
+/**
+ *
+ **/
+static size_t add_null(charset_t to, char *buf, size_t bytesleft, size_t len)
+{
+ /* Terminate the string */
+ if (to == CH_UCS2 && bytesleft >= 2) {
+ buf[len] = 0;
+ buf[len+1] = 0;
+
+ }
+ else if ( to != CH_UCS2 && bytesleft > 0 )
+ buf[len] = 0;
+ else {
+ errno = E2BIG;
+ return (size_t)(-1);
+ }
+
+ return len;
+}
+
+
/**
* Convert string from one encoding to another, making error checking etc
*
LOG(log_debug, logtype_default,"Conversion error: %s",reason);
return (size_t)-1;
}
-
+
/* Terminate the string */
- if (to == CH_UCS2 && destlen-o_len >= 2) {
- o_save[destlen-o_len] = 0;
- o_save[destlen-o_len+1] = 0;
- }
- else if ( to != CH_UCS2 && destlen-o_len > 0 )
- o_save[destlen-o_len] = 0;
- else {
- /* FIXME: what should we do here, string *might* be unterminated. E2BIG? */
- }
-
- return destlen-o_len;
+ return add_null( to, o_save, o_len, destlen -o_len);
}
}
free(buffer);
- dst[len] = 0;
return (len);
}
}
free(buffer);
- dst[len] = 0;
return (len);
}