@@ -1260,47 +1260,46 @@ int ParseScpCommand(WOLFSSH* ssh)
1260
1260
1261
1261
case 't' :
1262
1262
ssh -> scpDirection = WOLFSSH_SCP_TO ;
1263
- #ifdef WOLFSSL_NUCLEUS
1264
1263
ssh -> scpBasePathSz = cmdSz + WOLFSSH_MAX_FILENAME ;
1265
1264
ssh -> scpBasePathDynamic = (char * )WMALLOC (
1266
1265
ssh -> scpBasePathSz ,
1267
1266
ssh -> ctx -> heap , DYNTYPE_BUFFER );
1268
- #endif
1267
+ if (ssh -> scpBasePathDynamic == NULL ) {
1268
+ return WS_MEMORY_E ;
1269
+ }
1270
+ WMEMSET (ssh -> scpBasePathDynamic , 0 , ssh -> scpBasePathSz );
1269
1271
if (idx + 2 < cmdSz ) {
1270
1272
/* skip space */
1271
1273
idx += 2 ;
1272
- #ifdef WOLFSSL_NUCLEUS
1273
1274
ssh -> scpBasePath = ssh -> scpBasePathDynamic ;
1274
- WMEMCPY (ssh -> scpBasePathDynamic , cmd + idx , cmdSz );
1275
- #else
1276
- ssh -> scpBasePath = cmd + idx ;
1277
- #endif
1275
+ WMEMCPY (ssh -> scpBasePathDynamic , cmd + idx ,
1276
+ cmdSz - idx );
1278
1277
ret = ParseBasePathHelper (ssh , cmdSz );
1279
1278
if (ret == WS_SUCCESS &&
1280
- wolfSSH_CleanPath (ssh , (char * )ssh -> scpBasePath ) < 0 )
1279
+ wolfSSH_CleanPath (ssh ,
1280
+ ssh -> scpBasePathDynamic ) < 0 )
1281
1281
ret = WS_FATAL_ERROR ;
1282
1282
}
1283
1283
break ;
1284
1284
1285
1285
case 'f' :
1286
1286
ssh -> scpDirection = WOLFSSH_SCP_FROM ;
1287
- #ifdef WOLFSSL_NUCLEUS
1288
1287
ssh -> scpBasePathSz = cmdSz + WOLFSSH_MAX_FILENAME ;
1289
1288
ssh -> scpBasePathDynamic = (char * )WMALLOC (
1290
1289
ssh -> scpBasePathSz ,
1291
1290
ssh -> ctx -> heap , DYNTYPE_BUFFER );
1292
- #endif
1291
+ if (ssh -> scpBasePathDynamic == NULL ) {
1292
+ return WS_MEMORY_E ;
1293
+ }
1294
+ WMEMSET (ssh -> scpBasePathDynamic , 0 , ssh -> scpBasePathSz );
1293
1295
if (idx + 2 < cmdSz ) {
1294
1296
/* skip space */
1295
1297
idx += 2 ;
1296
- #ifdef WOLFSSL_NUCLEUS
1297
1298
ssh -> scpBasePath = ssh -> scpBasePathDynamic ;
1298
- WMEMCPY (ssh -> scpBasePathDynamic , cmd + idx , cmdSz );
1299
- #else
1300
- ssh -> scpBasePath = cmd + idx ;
1301
- #endif
1299
+ WMEMCPY (ssh -> scpBasePathDynamic , cmd + idx ,
1300
+ cmdSz - idx );
1302
1301
if (wolfSSH_CleanPath (ssh ,
1303
- ( char * ) ssh -> scpBasePath ) < 0 )
1302
+ ssh -> scpBasePathDynamic ) < 0 )
1304
1303
ret = WS_FATAL_ERROR ;
1305
1304
}
1306
1305
break ;
0 commit comments