/*
- * $Id: mangle.c,v 1.16.2.1.2.6 2003-11-01 02:14:56 bfernhomberg Exp $
+ * $Id: mangle.c,v 1.16.2.1.2.8 2004-02-14 15:47:20 didg Exp $
*
* Copyright (c) 2002. Joe Marcus Clarke (marcus@marcuscom.com)
* All Rights Reserved. See COPYRIGHT.
#include <ctype.h>
#include "mangle.h"
#include "desktop.h"
+#include <atalk/util.h>
#define hextoint( c ) ( isdigit( c ) ? c - '0' : c + 10 - 'A' )
#define isuxdigit(x) (isdigit(x) || (isupper(x) && isxdigit(x)))
-
-
static char *demangle_checks ( const struct vol *vol, char* uname, char * mfilename, size_t prefix, char * ext)
{
u_int16_t flags;
{
char *t;
char *u_name;
- u_int32_t id = 0;
+ u_int32_t id, file_id;
static char buffer[12 + MAXPATHLEN + 1];
int len = 12 + MAXPATHLEN + 1;
struct dir *dir;
size_t prefix;
+ id = file_id = 0;
+
t = strchr(mfilename, MANGLE_CHAR);
if (t == NULL) {
return mfilename;
return mfilename;
}
- id = htonl(id);
+ file_id = id = htonl(id);
if (osx) {
*osx = id;
}
}
if (!osx) {
/* convert back to mac name and check it's the same */
- t = utompath(vol, u_name, id, utf8_encoding());
+ t = utompath(vol, u_name, file_id, utf8_encoding());
if (!strcmp(t, mfilename)) {
return u_name;
}
}
}
m = mfilename;
- memset(m, 0, MAX_LENGTH + 1);
k = sprintf(mangle_suffix, "%c%X", MANGLE_CHAR, ntohl(id));
- strncpy(m, filename, MAX_LENGTH - k - ext_len);
+ strlcpy(m, filename, MAX_LENGTH - k - ext_len +1);
if (*m == 0) {
strcat(m, "???");
}