1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2026-01-01 01:41:18 +01:00

Merge pull request #18390 from benpicco/ncget-enhance

sys/shell: improve 'ncget' command
This commit is contained in:
fabian18 2022-08-02 19:12:27 +02:00 committed by GitHub
commit d491898f3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -121,7 +121,16 @@ static int _nanocoap_get_handler(int argc, char **argv)
}
dst = buffer;
} else {
char *filename = strrchr(url, '/');
dst = argv[2];
if (_is_dir(dst) && filename) {
if (snprintf(buffer, sizeof(buffer), "%s%s",
dst, filename + 1) >= (int)sizeof(buffer)) {
printf("Output file path too long\n");
return -ENOBUFS;
}
dst = buffer;
}
}
/* alternatively write the file to stdout */