Skip to content

Commit c07a868

Browse files
Merge pull request #663 from ejohnstown/scp-file-modes
SCP File Modes
2 parents 1b3a81f + 7fa60c4 commit c07a868

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/wolfscp.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ static int ScpPushDir(void *fs, ScpSendCtx* ctx, const char* path, void* heap);
5757
static int ScpPopDir(void *fs, ScpSendCtx* ctx, void* heap);
5858
#endif
5959

60+
#define WOLFSSH_MODE_MASK 0777
61+
6062
const char scpError[] = "scp error: %s, %d";
6163
const 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

Comments
 (0)