diff --git a/gui-win32/r16.c b/gui-win32/r16.c index 9de6783..2add199 100644 --- a/gui-win32/r16.c +++ b/gui-win32/r16.c @@ -59,7 +59,7 @@ runes16toutf(char *p, Rune16 *r, int nc) op = p; ep = p + nc; - while(c = *r++) { + while((c = *r++)) { n = 1; if(c >= Runeself) n = runelen(c); diff --git a/gui-win32/r16.h b/gui-win32/r16.h index ea4ee28..2c40026 100644 --- a/gui-win32/r16.h +++ b/gui-win32/r16.h @@ -9,3 +9,4 @@ Rune16* runes16dup(Rune16*); Rune16* utftorunes16(Rune16*, char*, int); char* runes16toutf(char*, Rune16*, int); int runes16cmp(Rune16*, Rune16*); +void* smalloc(ulong); diff --git a/gui-win32/screen.c b/gui-win32/screen.c index c7ba8b2..0364545 100644 --- a/gui-win32/screen.c +++ b/gui-win32/screen.c @@ -41,7 +41,7 @@ static Rendez rend; Point ZP; uint windowStyle; -const uint BORDERLESS = WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_THICKFRAME | WS_SYSMENU | WS_DLGFRAME | WS_CLIPSIBLINGS | WS_VISIBLE | WS_POPUP ^ WS_MINIMIZE | WS_MAXIMIZE; +const uint BORDERLESS = (WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_THICKFRAME | WS_SYSMENU | WS_DLGFRAME | WS_CLIPSIBLINGS | WS_VISIBLE) | (WS_POPUP ^ WS_MINIMIZE) | WS_MAXIMIZE; static int isready(void*a) @@ -570,12 +570,12 @@ setcolor(ulong index, ulong red, ulong green, ulong blue) } -uchar* +char* clipreadunicode(HANDLE h) { Rune16 *p; int n; - uchar *q; + char *q; p = GlobalLock(h); n = rune16nlen(p, runes16len(p)+1); @@ -586,10 +586,10 @@ clipreadunicode(HANDLE h) return q; } -uchar * +char * clipreadutf(HANDLE h) { - uchar *p; + char *p; p = GlobalLock(h); p = strdup(p); @@ -602,7 +602,7 @@ char* clipread(void) { HANDLE h; - uchar *p; + char *p; if(!OpenClipboard(window)) { oserror(); @@ -626,7 +626,7 @@ int clipwrite(char *buf) { HANDLE h; - char *p, *e; + char *p; Rune16 *rp; int n = strlen(buf); diff --git a/include/libsec.h b/include/libsec.h index 96d4811..d35a9b5 100644 --- a/include/libsec.h +++ b/include/libsec.h @@ -132,7 +132,7 @@ struct DESstate void setupDESstate(DESstate *s, uchar key[8], uchar *ivec); void des_key_setup(uchar[8], ulong[32]); -void block_cipher(ulong*, uchar*, int); +void block_cipher(ulong[32], uchar[8], int); void desCBCencrypt(uchar*, int, DESstate*); void desCBCdecrypt(uchar*, int, DESstate*); void desECBencrypt(uchar*, int, DESstate*); @@ -163,7 +163,7 @@ struct DES3state }; void setupDES3state(DES3state *s, uchar key[3][8], uchar *ivec); -void triple_block_cipher(ulong keys[3][32], uchar*, int); +void triple_block_cipher(ulong keys[3][32], uchar[8], int); void des3CBCencrypt(uchar*, int, DES3state*); void des3CBCdecrypt(uchar*, int, DES3state*); void des3ECBencrypt(uchar*, int, DES3state*); @@ -192,7 +192,7 @@ struct DigestState { uvlong len; union { - u32int state[8]; + u32int state[16]; u64int bstate[8]; }; uchar buf[256]; diff --git a/kern/devmnt.c b/kern/devmnt.c index 9121bfd..06c28fe 100644 --- a/kern/devmnt.c +++ b/kern/devmnt.c @@ -1113,8 +1113,8 @@ mntfree(Mntrpc *r) lock(&mntalloc.lk); if(mntalloc.nrpcfree >= 10){ free(r->rpc); - free(r); freetag(r->request.tag); + free(r); } else{ r->list = mntalloc.rpcfree; diff --git a/kern/win32.c b/kern/win32.c index d18c790..99e7d1c 100644 --- a/kern/win32.c +++ b/kern/win32.c @@ -287,7 +287,7 @@ WinMain(HINSTANCE x, HINSTANCE y, LPSTR z, int w) Rune *warg; if(0 && win_hasunicode()){ - warg = GetCommandLineW(); + warg = (Rune*)GetCommandLineW(); n = (wstrlen(warg)+1)*UTFmax; arg = malloc(n); wstrtoutf(arg, warg, n); @@ -465,6 +465,6 @@ showfilewrite(char *a, int n) action = Lopen; arg = cmd; } - ShellExecute(0, 0, action, arg, 0, SW_SHOWNORMAL); + ShellExecute(0, 0, (LPCWSTR)action, (LPCWSTR)arg, 0, SW_SHOWNORMAL); return n; } diff --git a/libauthsrv/opasstokey.c b/libauthsrv/opasstokey.c index d263d4b..0db6a34 100644 --- a/libauthsrv/opasstokey.c +++ b/libauthsrv/opasstokey.c @@ -14,7 +14,7 @@ opasstokey(char *key, char *p) return 0; if(n > 10) n = 10; - strncpy((char*)t, p, n); + memcpy((char*)t, p, n); if(n >= 9){ c = p[8] & 0xf; if(n == 10) diff --git a/libc/runevsmprint.c b/libc/runevsmprint.c index 6d391e2..7643c68 100644 --- a/libc/runevsmprint.c +++ b/libc/runevsmprint.c @@ -6,23 +6,24 @@ static int runeFmtStrFlush(Fmt *f) { Rune *s; - int n; + int n, d; if(f->start == nil) return 0; n = (uintptr)f->farg; n *= 2; - s = (Rune*)f->start; - f->start = realloc(s, sizeof(Rune)*n); - if(f->start == nil){ + d = (Rune*)f->to - (Rune*)f->start; + s = realloc(f->start, sizeof(Rune)*n); + if(s == nil){ f->farg = nil; f->to = nil; f->stop = nil; - free(s); + free(f->start); return 0; } + f->start = s; f->farg = (void*)(uintptr)n; - f->to = (Rune*)f->start + ((Rune*)f->to - s); + f->to = (Rune*)f->start + d; f->stop = (Rune*)f->start + n - 1; return 1; } diff --git a/libc/strtod.c b/libc/strtod.c index a48abe5..f3b1637 100644 --- a/libc/strtod.c +++ b/libc/strtod.c @@ -1,5 +1,6 @@ #include #include +#include #include "fmtdef.h" static ulong diff --git a/libc/vsmprint.c b/libc/vsmprint.c index df5abe4..27d08ac 100644 --- a/libc/vsmprint.c +++ b/libc/vsmprint.c @@ -6,23 +6,24 @@ static int fmtStrFlush(Fmt *f) { char *s; - int n; + int n, d; if(f->start == nil) return 0; n = (uintptr)f->farg; n *= 2; - s = (char*)f->start; - f->start = realloc(s, n); - if(f->start == nil){ + d = (char*)f->to - (char*)f->start; + s = realloc(f->start, n); + if(s == nil){ f->farg = nil; f->to = nil; f->stop = nil; - free(s); + free(f->start); return 0; } + f->start = s; f->farg = (void*)(uintptr)n; - f->to = (char*)f->start + ((char*)f->to - s); + f->to = (char*)f->start + d; f->stop = (char*)f->start + n - 1; return 1; } diff --git a/libmemdraw/draw.c b/libmemdraw/draw.c index 7c6f486..c569a74 100644 --- a/libmemdraw/draw.c +++ b/libmemdraw/draw.c @@ -101,7 +101,7 @@ _memimagedrawsetup(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage if(mask == nil) mask = memopaque; -DBG print("memimagedraw %p/%luX %R @ %p %p/%luX %P %p/%luX %P... ", dst, dst->chan, r, dst->data->bdata, src, src->chan, p0, mask, mask->chan, p1); +DBG print("memimagedraw %p/%luX %R @ %p %p/%luX %P %p/%luX %P... ", dst, dst->chan, r, dst->data->bdata, src, src->chan, p0, mask, mask->chan, p1); if(drawclip(dst, &r, src, &p0, mask, &p1, &par.sr, &par.mr) == 0){ // if(drawdebug) @@ -776,9 +776,9 @@ DBG print("["); bmask = rdmask(&mpar, mpar.bufbase, masky); DBG print("]\n"); bdst = rddst(&dpar, dpar.bufbase, dsty); -DBG dumpbuf("src", bsrc, dx); -DBG dumpbuf("mask", bmask, dx); -DBG dumpbuf("dst", bdst, dx); +DBG dumpbuf("src", bsrc, dx); +DBG dumpbuf("mask", bmask, dx); +DBG dumpbuf("dst", bdst, dx); bdst = calc(bdst, bsrc, bmask, dx, isgrey, op); wrdst(&dpar, dpar.bytermin+dsty*dpar.bwidth, bdst); } diff --git a/libmemlayer/draw.c b/libmemlayer/draw.c index c352a0b..d6c6c25 100644 --- a/libmemlayer/draw.c +++ b/libmemlayer/draw.c @@ -64,7 +64,8 @@ memdraw(Memimage *dst, Rectangle r, Memimage *src, Point p0, Memimage *mask, Poi mask = memopaque; if(mask->layer){ -if(drawdebug) iprint("mask->layer != nil\n"); + if(drawdebug) + iprint("mask->layer != nil\n"); return; /* too hard, at least for now */ } @@ -75,7 +76,8 @@ if(drawdebug) iprint("mask->layer != nil\n"); } if(drawclip(dst, &r, src, &p0, mask, &p1, &srcr, &mr) == 0){ -if(drawdebug) iprint("drawclip dstcr %R srccr %R maskcr %R\n", dst->clipr, src->clipr, mask->clipr); + if(drawdebug) + iprint("drawclip dstcr %R srccr %R maskcr %R\n", dst->clipr, src->clipr, mask->clipr); return; } diff --git a/libsec/aes.c b/libsec/aes.c index 3999c23..2a16e14 100644 --- a/libsec/aes.c +++ b/libsec/aes.c @@ -61,8 +61,6 @@ static uchar basekey[3][16] = { static int aes_setupEnc(ulong rk[/*4*(Nr + 1)*/], const uchar cipherKey[], int keyBits); -static int aes_setupDec(ulong rk[/*4*(Nr + 1)*/], const uchar cipherKey[], - int keyBits); static int aes_setup(ulong erk[/*4*(Nr + 1)*/], ulong drk[/*4*(Nr + 1)*/], const uchar cipherKey[], int keyBits); @@ -1240,56 +1238,6 @@ aes_setupEnc(ulong rk[/*4*(Nr + 1)*/], const uchar cipherKey[], int keyBits) return 0; } -/** - * Expand the cipher key into the decryption key schedule. - * - * @return the number of rounds for the given cipher key size. - */ -static int -aes_setupDec(ulong rk[/* 4*(Nr + 1) */], const uchar cipherKey[], int keyBits) -{ - int Nr, i, j; - ulong temp; - - /* expand the cipher key: */ - Nr = aes_setupEnc(rk, cipherKey, keyBits); - /* invert the order of the round keys: */ - for (i = 0, j = 4*Nr; i < j; i += 4, j -= 4) { - temp = rk[i ]; rk[i ] = rk[j ]; rk[j ] = temp; - temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp; - temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp; - temp = rk[i + 3]; rk[i + 3] = rk[j + 3]; rk[j + 3] = temp; - } - /* - * apply the inverse MixColumn transform to all round keys - * but the first and the last: - */ - for (i = 1; i < Nr; i++) { - rk += 4; - rk[0] = - Td0[Te4[(rk[0] >> 24) ]] ^ - Td1[Te4[(rk[0] >> 16) & 0xff]] ^ - Td2[Te4[(rk[0] >> 8) & 0xff]] ^ - Td3[Te4[(rk[0] ) & 0xff]]; - rk[1] = - Td0[Te4[(rk[1] >> 24) ]] ^ - Td1[Te4[(rk[1] >> 16) & 0xff]] ^ - Td2[Te4[(rk[1] >> 8) & 0xff]] ^ - Td3[Te4[(rk[1] ) & 0xff]]; - rk[2] = - Td0[Te4[(rk[2] >> 24) ]] ^ - Td1[Te4[(rk[2] >> 16) & 0xff]] ^ - Td2[Te4[(rk[2] >> 8) & 0xff]] ^ - Td3[Te4[(rk[2] ) & 0xff]]; - rk[3] = - Td0[Te4[(rk[3] >> 24) ]] ^ - Td1[Te4[(rk[3] >> 16) & 0xff]] ^ - Td2[Te4[(rk[3] >> 8) & 0xff]] ^ - Td3[Te4[(rk[3] ) & 0xff]]; - } - return Nr; -} - /* using round keys in rk, perform Nr rounds of encrypting pt into ct */ void aes_encrypt(const ulong rk[/* 4*(Nr + 1) */], int Nr, const uchar pt[16], diff --git a/libsec/des.c b/libsec/des.c index c54541c..090fd4b 100644 --- a/libsec/des.c +++ b/libsec/des.c @@ -369,7 +369,7 @@ keycompperm(u32int left, u32int right, ulong *ek) } void -des_key_setup(uchar key[8], ulong *ek) +des_key_setup(uchar key[8], ulong ek[32]) { u32int left, right, v0, v1; @@ -471,7 +471,7 @@ des64to56(uchar *k64, uchar *k56) } void -key_setup(uchar key[7], ulong *ek) +key_setup(uchar key[7], ulong ek[32]) { uchar k64[8];