Apply patch: ncpfs-hg-commit-431.patch
This commit is contained in:
104
lib/ncplib.c
104
lib/ncplib.c
@@ -216,10 +216,10 @@ ncp_negotiate_size_and_options(struct ncp_conn *conn,
|
||||
#endif
|
||||
|
||||
static long
|
||||
ncp_login_object(struct ncp_conn *conn,
|
||||
const unsigned char *username,
|
||||
ncp_login_object(struct ncp_conn *conn,
|
||||
const char *username,
|
||||
int login_type,
|
||||
const unsigned char *password);
|
||||
const char *password);
|
||||
|
||||
static long
|
||||
ncp_do_close(struct ncp_conn *conn);
|
||||
@@ -666,7 +666,7 @@ static void run_wdog(struct ncp_conn *conn, int fd) {
|
||||
if (pfd[0].revents & POLLIN) {
|
||||
struct sockaddr_ipx sender;
|
||||
int sizeofaddr = sizeof(struct sockaddr_ipx);
|
||||
char buf[1024];
|
||||
unsigned char buf[1024];
|
||||
size_t pktsize;
|
||||
NWCCODE err;
|
||||
|
||||
@@ -1294,7 +1294,7 @@ ncp_connect_ipx_addr(struct ncp_conn *conn, const struct sockaddr_ipx *target,
|
||||
int ncp_sock, wdog_sock;
|
||||
long err;
|
||||
|
||||
conn->ncp_reply_buffer = (char*)malloc(NCP_PACKET_SIZE);
|
||||
conn->ncp_reply_buffer = malloc(NCP_PACKET_SIZE);
|
||||
if (!conn->ncp_reply_buffer) {
|
||||
return ENOMEM;
|
||||
}
|
||||
@@ -1397,7 +1397,7 @@ ncp_connect_in_addr(struct ncp_conn *conn, const struct sockaddr_in *target,
|
||||
int ncp_sock;
|
||||
long err;
|
||||
|
||||
conn->ncp_reply_buffer = (char*)malloc(NCP_PACKET_SIZE);
|
||||
conn->ncp_reply_buffer = malloc(NCP_PACKET_SIZE);
|
||||
if (!conn->ncp_reply_buffer) {
|
||||
return ENOMEM;
|
||||
}
|
||||
@@ -2444,6 +2444,30 @@ ncp_find_conn_spec(const char *server, const char *user, const char *password,
|
||||
uid, 0, err);
|
||||
}
|
||||
|
||||
static int
|
||||
ncp_init_get_argument(int *argc, char **argv, int arg_no, const char **target)
|
||||
{
|
||||
int count = 1;
|
||||
|
||||
if (target != NULL) {
|
||||
if (arg_no + 1 >= *argc) {
|
||||
/* No argument to switch */
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
*target = argv[arg_no + 1];
|
||||
count = 2;
|
||||
}
|
||||
/* Delete the consumed switch from the argument list
|
||||
and decrement the argument count */
|
||||
while (count + arg_no < *argc) {
|
||||
argv[arg_no] = argv[arg_no + count];
|
||||
arg_no += 1;
|
||||
}
|
||||
*argc -= count;
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct ncp_conn *
|
||||
ncp_initialize_2(int *argc, char **argv, int login_necessary,
|
||||
int login_type, long *err, int required)
|
||||
@@ -2457,28 +2481,6 @@ ncp_initialize_2(int *argc, char **argv, int login_necessary,
|
||||
int i = 1;
|
||||
NWCCODE nwerr;
|
||||
|
||||
static int get_argument(int arg_no, const char **target) {
|
||||
int count = 1;
|
||||
|
||||
if (target != NULL) {
|
||||
if (arg_no + 1 >= *argc) {
|
||||
/* No argument to switch */
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
*target = argv[arg_no + 1];
|
||||
count = 2;
|
||||
}
|
||||
/* Delete the consumed switch from the argument list
|
||||
and decrement the argument count */
|
||||
while (count + arg_no < *argc) {
|
||||
argv[arg_no] = argv[arg_no + count];
|
||||
arg_no += 1;
|
||||
}
|
||||
*argc -= count;
|
||||
return 0;
|
||||
}
|
||||
|
||||
*err = EINVAL;
|
||||
|
||||
while (i < *argc) {
|
||||
@@ -2489,17 +2491,17 @@ ncp_initialize_2(int *argc, char **argv, int login_necessary,
|
||||
}
|
||||
switch (argv[i][1]) {
|
||||
case 'S':
|
||||
if (get_argument(i, &server) != 0) {
|
||||
if (ncp_init_get_argument(argc, argv, i, &server) != 0) {
|
||||
return NULL;
|
||||
}
|
||||
continue;
|
||||
case 'U':
|
||||
if (get_argument(i, &user) != 0) {
|
||||
if (ncp_init_get_argument(argc, argv, i, &user) != 0) {
|
||||
return NULL;
|
||||
}
|
||||
continue;
|
||||
case 'P':
|
||||
if (get_argument(i, &password) != 0) {
|
||||
if (ncp_init_get_argument(argc, argv, i, &password) != 0) {
|
||||
return NULL;
|
||||
}
|
||||
if (password) {
|
||||
@@ -2509,14 +2511,14 @@ ncp_initialize_2(int *argc, char **argv, int login_necessary,
|
||||
}
|
||||
continue;
|
||||
case 'n':
|
||||
if (get_argument(i, NULL) != 0) {
|
||||
if (ncp_init_get_argument(argc, argv, i, NULL) != 0) {
|
||||
return NULL;
|
||||
}
|
||||
password = NWC_NOPASSWORD;
|
||||
continue;
|
||||
#ifdef NDS_SUPPORT
|
||||
case 'b':
|
||||
if (get_argument(i, NULL) != 0) {
|
||||
if (ncp_init_get_argument(argc, argv, i, NULL) != 0) {
|
||||
return NULL;
|
||||
}
|
||||
bindery_only = 1;
|
||||
@@ -2524,7 +2526,7 @@ ncp_initialize_2(int *argc, char **argv, int login_necessary,
|
||||
#endif
|
||||
#ifdef CONFIG_NATIVE_IP
|
||||
case 'A':
|
||||
if (get_argument(i, &address) != 0) {
|
||||
if (ncp_init_get_argument(argc, argv, i, &address) != 0) {
|
||||
return NULL;
|
||||
}
|
||||
continue;
|
||||
@@ -3036,7 +3038,7 @@ ncp_send_broadcast2(struct ncp_conn *conn,
|
||||
*/
|
||||
long
|
||||
ncp_get_encryption_key(struct ncp_conn *conn,
|
||||
char *target)
|
||||
unsigned char *target)
|
||||
{
|
||||
NW_FRAGMENT rp;
|
||||
NWCCODE err;
|
||||
@@ -3529,7 +3531,7 @@ static long
|
||||
ncp_keyed_verify_password(struct ncp_conn *conn,
|
||||
const struct ncp_bindery_object *object,
|
||||
const unsigned char *key,
|
||||
const unsigned char *passwd)
|
||||
const char *passwd)
|
||||
{
|
||||
dword tmpID = htonl(object->object_id);
|
||||
unsigned char buf[128];
|
||||
@@ -3599,7 +3601,7 @@ long
|
||||
ncp_login_encrypted(struct ncp_conn *conn,
|
||||
const struct ncp_bindery_object *object,
|
||||
const unsigned char *key,
|
||||
const unsigned char *passwd)
|
||||
const char *passwd)
|
||||
{
|
||||
dword tmpID;
|
||||
unsigned char buf[128];
|
||||
@@ -3642,7 +3644,7 @@ ncp_login_encrypted(struct ncp_conn *conn,
|
||||
long
|
||||
ncp_login_unencrypted(struct ncp_conn *conn,
|
||||
NWObjectType object_type, const char *object_name,
|
||||
const unsigned char *passwd)
|
||||
const char *passwd)
|
||||
{
|
||||
long result;
|
||||
|
||||
@@ -3669,8 +3671,8 @@ long
|
||||
ncp_change_login_passwd(struct ncp_conn *conn,
|
||||
const struct ncp_bindery_object *object,
|
||||
const unsigned char *key,
|
||||
const unsigned char *oldpasswd,
|
||||
const unsigned char *newpasswd)
|
||||
const char *oldpasswd,
|
||||
const char *newpasswd)
|
||||
{
|
||||
long id;
|
||||
unsigned char cryptkey[8];
|
||||
@@ -3687,8 +3689,8 @@ ncp_change_login_passwd(struct ncp_conn *conn,
|
||||
shuffle((byte *) & id, oldpasswd, strlen(oldpasswd), oldpwd);
|
||||
shuffle((byte *) & id, newpasswd, strlen(newpasswd), newpwd);
|
||||
nw_encrypt(cryptkey, oldpwd, cryptkey);
|
||||
newpassencrypt(oldpwd, newpwd, newpwd);
|
||||
newpassencrypt(oldpwd + 8, newpwd + 8, newpwd + 8);
|
||||
newpassencrypt(oldpwd, newpwd);
|
||||
newpassencrypt(oldpwd + 8, newpwd + 8);
|
||||
if ((len = strlen(newpasswd)) > 63) {
|
||||
len = 63;
|
||||
}
|
||||
@@ -3707,17 +3709,17 @@ ncp_change_login_passwd(struct ncp_conn *conn,
|
||||
|
||||
long
|
||||
ncp_login_user(struct ncp_conn *conn,
|
||||
const unsigned char *username,
|
||||
const unsigned char *password)
|
||||
const char *username,
|
||||
const char *password)
|
||||
{
|
||||
return ncp_login_object(conn, username, NCP_BINDERY_USER, password);
|
||||
}
|
||||
|
||||
static long
|
||||
ncp_login_object(struct ncp_conn *conn,
|
||||
const unsigned char *username,
|
||||
const char *username,
|
||||
int login_type,
|
||||
const unsigned char *password)
|
||||
const char *password)
|
||||
{
|
||||
long result;
|
||||
unsigned char ncp_key[8];
|
||||
@@ -3790,10 +3792,10 @@ ncp_sign_stop(UNUSED(NWCONN_HANDLE conn))
|
||||
}
|
||||
|
||||
long
|
||||
ncp_sign_start(struct ncp_conn *conn, const char *sign_root)
|
||||
ncp_sign_start(struct ncp_conn *conn, const unsigned char *sign_root)
|
||||
{
|
||||
#ifdef SIGNATURES
|
||||
static const char init_last[16]=
|
||||
static const unsigned char init_last[16]=
|
||||
{0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,
|
||||
0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10};
|
||||
if (ncp_get_sign_wanted(conn)) {
|
||||
@@ -3829,8 +3831,8 @@ ncp_sign_start(struct ncp_conn *conn, const char *sign_root)
|
||||
long
|
||||
ncp_send_nds_frag(struct ncp_conn *conn,
|
||||
int ndsverb,
|
||||
const char *inbuf, size_t inbuflen,
|
||||
char *outbuf, size_t outbufsize, size_t *outbuflen)
|
||||
const void *iinbuf, size_t inbuflen,
|
||||
void *ioutbuf, size_t outbufsize, size_t *outbuflen)
|
||||
{
|
||||
long result;
|
||||
size_t sizeleft, i;
|
||||
@@ -3841,6 +3843,8 @@ ncp_send_nds_frag(struct ncp_conn *conn,
|
||||
int32_t ndsCode = -399;
|
||||
size_t replyLen = 0;
|
||||
size_t fragLen;
|
||||
const nuint8* inbuf = iinbuf;
|
||||
nuint8* outbuf = ioutbuf;
|
||||
|
||||
if (inbuflen && !inbuf) {
|
||||
return ERR_NULL_POINTER;
|
||||
|
||||
Reference in New Issue
Block a user