Skip to content

Commit c13dc10

Browse files
committed
verify pointer to be non-NULL before dereferencing
1 parent 58254f7 commit c13dc10

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/misc/ssh/ssh_decode_sequence_multi.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,33 +88,39 @@ int ssh_decode_sequence_multi(const unsigned char *in, unsigned long inlen, ...)
8888
inlen -= size;
8989
}
9090

91+
vdata = va_arg(args, void*);
92+
if (vdata == NULL) {
93+
err = CRYPT_INVALID_ARG;
94+
goto error;
95+
}
96+
9197
/* Read data */
9298
switch (type) {
9399
case LTC_SSHDATA_BYTE:
94-
cdata = va_arg(args, unsigned char*);
100+
cdata = vdata;
95101
*cdata = *in++;
96102
break;
97103
case LTC_SSHDATA_BOOLEAN:
98-
cdata = va_arg(args, unsigned char*);
104+
cdata = vdata;
99105
/*
100106
The value 0 represents FALSE, and the value 1 represents TRUE. All non-zero values MUST be
101107
interpreted as TRUE; however, applications MUST NOT store values other than 0 and 1.
102108
*/
103109
*cdata = (*in++)?1:0;
104110
break;
105111
case LTC_SSHDATA_UINT32:
106-
u32data = va_arg(args, ulong32*);
112+
u32data = vdata;
107113
LOAD32H(*u32data, in);
108114
in += 4;
109115
break;
110116
case LTC_SSHDATA_UINT64:
111-
u64data = va_arg(args, ulong64*);
117+
u64data = vdata;
112118
LOAD64H(*u64data, in);
113119
in += 8;
114120
break;
115121
case LTC_SSHDATA_STRING:
116122
case LTC_SSHDATA_NAMELIST:
117-
sdata = va_arg(args, char*);
123+
sdata = vdata;
118124
bufsize = va_arg(args, ulong32*);
119125
if (bufsize == NULL) {
120126
err = CRYPT_INVALID_ARG;
@@ -132,7 +138,6 @@ int ssh_decode_sequence_multi(const unsigned char *in, unsigned long inlen, ...)
132138
in += size;
133139
break;
134140
case LTC_SSHDATA_MPINT:
135-
vdata = va_arg(args, void*);
136141
if (size == 0) {
137142
if ((err = mp_set(vdata, 0)) != CRYPT_OK) { goto error; }
138143
} else if ((in[0] & 0x80) != 0) {

0 commit comments

Comments
 (0)