mirror of
https://github.com/fumiama/base16384.git
synced 2026-06-07 19:40:23 +08:00
sync (#22)
* fix typo * fix: 32bit be decoding * chore: add Rust alternative (#18) * Update C# Link (#20) * 尝试修复#19 - 移除未使用的参数 int blen - 完善文档、注释 - 完善文件名错误检测 - 修复 encbuf, decbuf 处理逻辑 * fix: disable mmap in windows * fix: encode bufsz (#19) * v2.2.5 * Update Swift Link (#21) --------- Co-authored-by: 忘忧北萱草 <wybxc@qq.com> Co-authored-by: LC <64722907+lc6464@users.noreply.github.com> Co-authored-by: oboard <oboard@outlook.com>
This commit is contained in:
12
base1432.c
12
base1432.c
@@ -1,6 +1,6 @@
|
||||
/* base1432.c
|
||||
* This file is part of the base16384 distribution (https://github.com/fumiama/base16384).
|
||||
* Copyright (c) 2022 Fumiama Minamoto.
|
||||
* Copyright (c) 2022-2023 Fumiama Minamoto.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -62,7 +62,7 @@
|
||||
|
||||
// #define DEBUG
|
||||
|
||||
int base16384_encode(const char* data, int dlen, char* buf, int blen) {
|
||||
int base16384_encode(const char* data, int dlen, char* buf) {
|
||||
int outlen = dlen / 7 * 8;
|
||||
int offset = dlen % 7;
|
||||
switch(offset) { // 算上偏移标志字符占用的2字节
|
||||
@@ -140,7 +140,7 @@ int base16384_encode(const char* data, int dlen, char* buf, int blen) {
|
||||
return outlen;
|
||||
}
|
||||
|
||||
int base16384_decode(const char* data, int dlen, char* buf, int blen) {
|
||||
int base16384_decode(const char* data, int dlen, char* buf) {
|
||||
int outlen = dlen;
|
||||
int offset = 0;
|
||||
if(data[dlen-2] == '=') {
|
||||
@@ -194,7 +194,11 @@ int base16384_decode(const char* data, int dlen, char* buf, int blen) {
|
||||
if(offset--) {
|
||||
buf[i] = (sum & 0x0f000000) >> 20;
|
||||
// 这里有读取越界
|
||||
sum = vals[n];
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
sum = __builtin_bswap32(vals[n]);
|
||||
#else
|
||||
sum = vals[n];
|
||||
#endif
|
||||
sum -= 0x0000004e;
|
||||
buf[i++] |= (sum & 0x0000003c) >> 2;
|
||||
if(offset--) {
|
||||
|
||||
Reference in New Issue
Block a user