Commit 32901365 authored by Steve French's avatar Steve French Committed by Steve French

reduce excessive stack space usage in smb password hashing

parent ff50da43
......@@ -2,7 +2,8 @@ Version 1.13
------------
Fix open of files in which O_CREATE can cause the mode to change in
some cases. Fix case in which retry of write overlaps file close.
Fix PPC64 build error.
Fix PPC64 build error. Reduce excessive stack usage in smb password
hashing.
Version 1.12
------------
......
......@@ -6,7 +6,7 @@
SMB authentication protocol
Copyright (C) Andrew Tridgell 1998
Modified by Steve French (sfrench@us.ibm.com) 2002,2003
Modified by Steve French (sfrench@us.ibm.com) 2002,2004
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
......@@ -44,7 +44,7 @@
should confirm it for yourself (and maybe let me know if you come
up with a different answer to the one above)
*/
#include <linux/slab.h>
#define uchar unsigned char
static uchar perm1[56] = { 57, 49, 41, 33, 25, 17, 9,
......@@ -191,14 +191,23 @@ static void
dohash(char *out, char *in, char *key, int forw)
{
int i, j, k;
char pk1[56];
char *pk1;
char c[28];
char d[28];
char cd[56];
char *cd;
char ki[16][48];
char pd1[64];
char *pd1;
char l[32], r[32];
char rl[64];
char *rl;
/* Have to reduce stack usage */
pk1 = kmalloc(56+56+64+64,GFP_KERNEL);
if(pk1 == NULL)
return;
cd = pk1 + 56;
pd1= cd + 56;
rl = pd1 + 64;
permute(pk1, key, perm1, 56);
......@@ -223,12 +232,22 @@ dohash(char *out, char *in, char *key, int forw)
}
for (i = 0; i < 16; i++) {
char er[48];
char erk[48];
char *er; /* er[48] */
char *erk; /* erk[48] */
char b[8][6];
char cb[32];
char pcb[32];
char r2[32];
char *cb; /* cb[32] */
char *pcb; /* pcb[32] */
char *r2; /* r2[32] */
er = kmalloc(48+48+32+32+32, GFP_KERNEL);
if(er == NULL) {
kfree(pk1);
return;
}
erk = er+48;
cb = erk+48;
pcb = cb+32;
r2 = pcb+32;
permute(er, r, perm4, 48);
......@@ -262,11 +281,14 @@ dohash(char *out, char *in, char *key, int forw)
for (j = 0; j < 32; j++)
r[j] = r2[j];
kfree(er);
}
concat(rl, r, l, 32, 32);
permute(out, rl, perm6, 64);
kfree(pk1);
}
static void
......@@ -291,11 +313,18 @@ static void
smbhash(unsigned char *out, unsigned char *in, unsigned char *key, int forw)
{
int i;
char outb[64];
char inb[64];
char keyb[64];
char *outb; /* outb[64] */
char *inb; /* inb[64] */
char *keyb; /* keyb[64] */
unsigned char key2[8];
outb = kmalloc(64 * 3,GFP_KERNEL);
if(outb == NULL)
return;
inb = outb + 64;
keyb = inb + 64;
str_to_key(key, key2);
for (i = 0; i < 64; i++) {
......@@ -314,6 +343,7 @@ smbhash(unsigned char *out, unsigned char *in, unsigned char *key, int forw)
if (outb[i])
out[i / 8] |= (1 << (7 - (i % 8)));
}
kfree(outb);
}
void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment