@@ -57,6 +57,8 @@ static int ScpPushDir(void *fs, ScpSendCtx* ctx, const char* path, void* heap);
5757static int ScpPopDir (void * fs , ScpSendCtx * ctx , void * heap );
5858#endif
5959
60+ #define WOLFSSH_MODE_MASK 0777
61+
6062const char scpError [] = "scp error: %s, %d" ;
6163const char scpState [] = "scp state: %s" ;
6264
@@ -315,7 +317,8 @@ static int SendScpFileHeader(WOLFSSH* ssh)
315317#ifndef WSCPFILEHDR
316318 WMEMSET (buf , 0 , sizeof (buf ));
317319 WSNPRINTF (buf , sizeof (buf ), "C%04o %u %s\n" ,
318- ssh -> scpFileMode , ssh -> scpFileSz , ssh -> scpFileName );
320+ ssh -> scpFileMode & WOLFSSH_MODE_MASK ,
321+ ssh -> scpFileSz , ssh -> scpFileName );
319322 filehdr = buf ;
320323#else
321324 filehdr = WSCPFILEHDR (ssh );
@@ -350,8 +353,9 @@ static int SendScpEnterDirectory(WOLFSSH* ssh)
350353
351354 WMEMSET (buf , 0 , sizeof (buf ));
352355
353- WSNPRINTF (buf , sizeof (buf ), "D%04o 0 %s\n" , ssh -> scpFileMode ,
354- ssh -> scpFileName );
356+ WSNPRINTF (buf , sizeof (buf ), "D%04o 0 %s\n" ,
357+ ssh -> scpFileMode & WOLFSSH_MODE_MASK ,
358+ ssh -> scpFileName );
355359
356360 bufSz = (int )WSTRLEN (buf );
357361
0 commit comments