Esempio n. 1
0
/*
 * smb_auth_lmupr
 *
 * Converts the given LM password to all uppercase.
 * The standard strupr cannot
 * be used here because lm_pwd doesn't have to be
 * nul terminated.
 */
static void
smb_auth_lmupr(unsigned char *lm_pwd)
{
    unsigned char *p = lm_pwd;
    int i;

    for (i = 0; (*p) && (i < SMBAUTH_LM_PWD_SZ); i++) {
        if (smb_isascii(*p)) {
            *p = smb_toupper(*p);
            p++;
        }
    }
}
Esempio n. 2
0
/*
 * smb_vop_catia_v4tov5
 * (unix (v4) to windows (v5))
 *
 * Traverse each character in the given filename 'srcbuf' and convert
 * the special Unix character that is listed in the catia_maps table to
 * the UTF-8 encoding of the corresponding Windows character if any is
 * encountered in the filename.
 *
 * The translated name is returned in buf.
 * If an error occurs the conversion terminates and the original name
 * is returned in buf.
 */
void
smb_vop_catia_v4tov5(char *name, char *buf, int buflen)
{
	int v5_idx, numbytes;
	int space_left = buflen - 1; /* one byte reserved for null */
	smb_wchar_t wc;
	char mbstring[MTS_MB_CHAR_MAX];
	char *src = name, *dst = buf;

	ASSERT(name);
	ASSERT(buf);

	if (!buf || !name)
		return;

	(void) bzero(buf, buflen);
	while (*src) {
		if (smb_isascii(*src)) {
			/* Lookup required */
			v5_idx = (int)*src++;
			numbytes = smb_wctomb(mbstring,
			    smb_catia_v5_lookup[v5_idx]);
			if (space_left < numbytes)
				break;
			(void) strncpy(dst, mbstring, numbytes);
		} else {
			if ((numbytes = smb_mbtowc(&wc, src,
			    MTS_MB_CHAR_MAX)) < 0)
				break;
			if (space_left < numbytes)
				break;
			(void) strncpy(dst, src, numbytes);
			src += numbytes;
		}

		dst += numbytes;
		space_left -= numbytes;
	}

	if (*src)
		(void) strlcpy(buf, name, buflen);
}