/* Get the info out of the AHX module data*/ static void process_ahx_mod(char *credits, size_t credits_len, unsigned char *buf, size_t len) { int i; size_t offset; char tmpstr[256]; if (len < 13) return; offset = read_be_u16(buf + 4); if (offset >= len) return; if (!string_checker(buf, offset, len)) return; snprintf(tmpstr, sizeof tmpstr, "\nSong title: %s\n", buf + offset); strlcat(credits, tmpstr, credits_len); for (i = 0; i < buf[12]; i++) { if (!string_checker(buf, offset, len)) break; offset = offset + 1 + strlen((char *)buf + offset); if (offset < len) { snprintf(tmpstr, 256, "\n %s", buf + offset); strlcat(credits, tmpstr, credits_len); } } }
/* Wanted Team's loadseg modules */ static void process_WTWT_mod(char *credits, size_t credits_len, unsigned char *buf, size_t len, char *lo, char *hi, int rel) { int offset, txt_offset, chunk; char tmpstr[256]; /* check for Magic ID */ offset = find_tag((uint8_t *) buf, 0, len, (uint8_t *) lo, 4); if (offset == -1) return; offset = find_tag((uint8_t *) buf, offset + 4, offset + 8, (uint8_t *) hi, 4); if (offset == -1) return; chunk = offset - 8; /* here's where our first chunk should be */ offset = offset + rel; /* offset to our info pointers */ if (chunk < len && offset < len) { txt_offset = read_be_u32(buf + offset) + chunk; if (txt_offset < len && txt_offset != chunk) { if (!string_checker(buf, txt_offset, len)) return; snprintf(tmpstr, sizeof tmpstr, "\nMODULENAME:\n %s\n", buf + txt_offset); strlcat(credits, tmpstr, credits_len); } txt_offset = read_be_u32(buf + offset + 4) + chunk; if (txt_offset < len && txt_offset != chunk) { if (!string_checker(buf, txt_offset, len)) return; snprintf(tmpstr, sizeof tmpstr, "\nAUTHORNAME:\n %s\n", buf + txt_offset); strlcat(credits, tmpstr, credits_len); } txt_offset = read_be_u32(buf + offset + 8) + chunk; if (txt_offset < len && txt_offset != chunk) { if (!string_checker(buf, txt_offset, len)) return; snprintf(tmpstr, sizeof tmpstr, "\nSPECIALINFO:\n %s", buf + txt_offset); strlcat(credits, tmpstr, credits_len); } } }
/* Get the info out of the protracker module data*/ static void process_ptk_mod(char *credits, size_t credits_len, int inst, uint8_t * buf, size_t len) { int i; char tmpstr[256]; if (!string_checker(buf, 0, len)) return; snprintf(tmpstr, 35, "\nSong title: %s", buf); strlcat(credits, tmpstr, credits_len); if (inst == 31) { if (len >= 0x43c) { snprintf(tmpstr, sizeof tmpstr, "\nmax positions: %d\n", buf[0x3b6]); strlcat(credits, tmpstr, credits_len); } } else { if (len >= 0x1da) { snprintf(tmpstr, sizeof tmpstr, "\nmax positions: %d\n", buf[0x1d6]); strlcat(credits, tmpstr, credits_len); } } snprintf(tmpstr, sizeof tmpstr, "\nINST - NAME SIZE VOL FINE LSTART LSIZE\n"); strlcat(credits, tmpstr, credits_len); if (len >= (0x14 + inst * 0x1e)) { for (i = 0; i < inst; i++) { if (!string_checker(buf, 0x14 + i * 0x1e, len)) break; snprintf(tmpstr, sizeof tmpstr, "[%2d] - ", i + 1); strlcat(credits, tmpstr, credits_len); snprintf(tmpstr, 23, "%-23s", buf + 0x14 + (i * 0x1e)); strlcat(credits, tmpstr, credits_len); snprintf(tmpstr, sizeof tmpstr, " %6d %2d %2d %6d %6d\n", read_be_u16(buf + 42 + i * 0x1e) * 2, buf[45 + i * 0x1e], buf[44 + i * 0x1e], read_be_u16(buf + 46 + i * 0x1e) * 2, read_be_u16(buf + 48 + i * 0x1e) * 2); strlcat(credits, tmpstr, credits_len); } } }
/* * Get the info out of the Deltamusic 2 module data */ static void process_dm2_mod(char *credits, size_t credits_len, unsigned char *buf, size_t len) { char tmpstr[256]; if (!string_checker(buf, 0x148, len)) return; snprintf(tmpstr, sizeof tmpstr, "\nRemarks:\n%s", buf + 0x148); strlcat(credits, tmpstr, credits_len); }
/* Get the info out of the digibooster module data*/ static void process_digi_mod(char *credits, size_t credits_len, uint8_t * buf, size_t len) { int i; char tmpstr[256]; if (len < (642 + 0x30 * 0x1e)) return; if (!string_checker(buf, 610, len)) return; snprintf(tmpstr, 0x2f, "\nSong title: %s \n", buf + 610); strlcat(credits, tmpstr, credits_len); snprintf(tmpstr, sizeof tmpstr, "max positions: %d\n", buf[47]); strlcat(credits, tmpstr, credits_len); snprintf(tmpstr, sizeof tmpstr, "\nINST - NAME SIZE VOL FINE LSTART LSIZE\n"); strlcat(credits, tmpstr, credits_len); if (len >= (642 + 0x1f * 0x1e)) { for (i = 0; i < 0x1f; i++) { if (!string_checker(buf, 642 + i * 0x1e, len)) break; snprintf(tmpstr, sizeof tmpstr, "[%2d] - ", i + 1); strlcat(credits, tmpstr, credits_len); snprintf(tmpstr, 30, "%-30s", buf + 642 + (i * 0x1e)); strlcat(credits, tmpstr, credits_len); snprintf(tmpstr, sizeof tmpstr, " %11d %2d %3d %11d %11d\n", read_be_u32(buf + 176 + i * 4), buf[548 + i], buf[579 + i], read_be_u32(buf + 300 + i * 4), read_be_u32(buf + 424 + i * 4)); strlcat(credits, tmpstr, credits_len); } } }
static const char *obscure_msg(const char *old_p, const char *new_p, const struct passwd *pw) { unsigned length; unsigned size; unsigned mixed; unsigned c; unsigned i; const char *p; char *hostname; /* size */ if (!new_p || (length = strlen(new_p)) < CONFIG_PASSWORD_MINLEN) return "too short"; /* no username as-is, as sub-string, reversed, capitalized, doubled */ if (string_checker(new_p, pw->pw_name)) { return "similar to username"; } #ifndef __BIONIC__ /* no gecos as-is, as sub-string, reversed, capitalized, doubled */ if (pw->pw_gecos[0] && string_checker(new_p, pw->pw_gecos)) { return "similar to gecos"; } #endif /* hostname as-is, as sub-string, reversed, capitalized, doubled */ hostname = safe_gethostname(); i = string_checker(new_p, hostname); free(hostname); if (i) return "similar to hostname"; /* Should / Must contain a mix of: */ mixed = 0; for (i = 0; i < length; i++) { if (islower(new_p[i])) { /* a-z */ mixed |= LOWERCASE; } else if (isupper(new_p[i])) { /* A-Z */ mixed |= UPPERCASE; } else if (isdigit(new_p[i])) { /* 0-9 */ mixed |= NUMBERS; } else { /* special characters */ mixed |= SPECIAL; } /* Count i'th char */ c = 0; p = new_p; while (1) { p = strchr(p, new_p[i]); if (p == NULL) { break; } c++; p++; if (!*p) { break; } } /* More than 50% similar characters ? */ if (c*2 >= length) { return "too many similar characters"; } } size = CONFIG_PASSWORD_MINLEN + 2*CATEGORIES; for (i = 1; i <= LAST_CAT; i <<= 1) if (mixed & i) size -= 2; if (length < size) return "too weak"; if (old_p && old_p[0]) { /* check vs. old password */ if (string_checker(new_p, old_p)) { return "similar to old password"; } } return NULL; }