Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions doc/ps2link-protocol.txt
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
command.length = htons(sizeof(command));
command.offset = htonl(offset);
command.size = htonl(size);
if (pathname) { strncpy(command.pathname, pathname, 256); }
if (pathname) { snprintf(command.pathname, sizeof(command.pathname), "%s", pathname); }

------------------------------
0xBABE0208 (startvu command)
Expand Down Expand Up @@ -168,7 +168,7 @@
command.number = htonl(0xBABE020A);
command.length = htons(sizeof(command));
command.type = htonl(type);
if (pathname) { strncpy(command.pathname, pathname, 256); }
if (pathname) { snprintf(command.pathname, sizeof(command.pathname), "%s", pathname); }

-----------------------------
0xBABE020B (gsexec command)
Expand All @@ -185,7 +185,7 @@
command.number = htonl(0xBABE020B);
command.length = htons(sizeof(command));
command.size = htonl(size);
if (pathname) { strncpy(command.pathname, pathname, 256); }
if (pathname) { snprintf(command.pathname, sizeof(command.pathname), "%s", pathname); }

--------------------------------------
PS2LINK REQUEST AND RESPONSE PACKETS
Expand Down
22 changes: 11 additions & 11 deletions doc/ps2netfs-protocol.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
request.number = htonl(0xBEEF8011);
request.length = htons(sizeof(request));
request.flags = htonl(mode);
if (pathname) { strncpy(request.pathname, pathname, 256); }
if (pathname) { snprintf(request.pathname, sizeof(request.pathname), "%s", pathname); }

-----------------------------
0xBEEF8021 (close request)
Expand Down Expand Up @@ -131,7 +131,7 @@
request.number = htonl(0xBEEF8071);
request.length = htons(sizeof(request));
request.flags = htonl(flags);
if (pathname) { strncpy(request.pathname, pathname, 256); }
if (pathname) { snprintf(request.pathname, sizeof(request.pathname), "%s", pathname); }

-----------------------------
0xBEEF8081 (mkdir request)
Expand All @@ -148,7 +148,7 @@
request.number = htonl(0xBEEF8081);
request.length = htons(sizeof(request));
request.flags = htonl(flags);
if (pathname) { strncpy(request.pathname, pathname, 256); }
if (pathname) { snprintf(request.pathname, sizeof(request.pathname), "%s", pathname); }

-----------------------------
0xBEEF8091 (rmdir request)
Expand All @@ -165,7 +165,7 @@
request.number = htonl(0xBEEF8091);
request.length = htons(sizeof(request));
request.flags = htonl(flags);
if (pathname) { strncpy(request.pathname, pathname, 256); }
if (pathname) { snprintf(request.pathname, sizeof(request.pathname), "%s", pathname); }

------------------------------
0xBEEF80A1 (dopen request)
Expand All @@ -182,7 +182,7 @@
request.number = htonl(0xBEEF80A1);
request.length = htons(sizeof(request));
request.flags = htonl(flags);
if (pathname) { strncpy(request.pathname, pathname, 256); }
if (pathname) { snprintf(request.pathname, sizeof(request.pathname), "%s", pathname); }

------------------------------
0xBEEF80B1 (dclose request)
Expand Down Expand Up @@ -245,7 +245,7 @@
request.number = htonl(0xBEEF8131);
request.length = htons(sizeof(request));
request.flags = htonl(flags);
if (device) { strncpy(request.device, device, 256); }
if (device) { snprintf(request.device, sizeof(request.device), "%s", device); }

-----------------------------
0xBEEF8141 (mount request)
Expand All @@ -268,9 +268,9 @@
request.length = htons(sizeof(request));
request.flags = htonl(flags);
request.argc = htonl(argc);
if (device) { strncpy(request.device, device, 256); }
if (fsname) { strncpy(request.fsname, fsname, 256); }
if (argv) { strncpy(request.argv, argv, 256); }
if (device) { snprintf(request.device, sizeof(request.device), "%s", device); }
if (fsname) { snprintf(request.fsname, sizeof(request.fsname), "%s", fsname); }
if (argv) { snprintf(request.argv, sizeof(request.argv), "%s", argv); }

------------------------------
0xBEEF8151 (umount request)
Expand All @@ -287,7 +287,7 @@
request.number = htonl(0xBEEF8151);
request.length = htons(sizeof(request));
request.flags = htonl(flags);
if (device) { strncpy(request.device, device, 256); }
if (device) { snprintf(request.device, sizeof(request.device), "%s", device); }

-------------------------------
0xBEEF8F21 (devlist request)
Expand All @@ -304,4 +304,4 @@
request.number = htonl(0xBEEF8F21);
request.length = htons(sizeof(request));
request.flags = htonl(flags);
if (pathname) { strncpy(request.pathname, pathname, 256); }
if (pathname) { snprintf(request.pathname, sizeof(request.pathname), "%s", pathname); }
4 changes: 2 additions & 2 deletions src/fsclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
for (loop0=0; env[loop0]; loop0++) {

// A hostname has been specified...
if (strncmp(env[loop0], "PS2HOSTNAME", 11) == 0) { strncpy(hostname, &env[loop0][12], sizeof(hostname)); }
if (strncmp(env[loop0], "PS2HOSTNAME", 11) == 0) { snprintf(hostname, sizeof(hostname), "%s", &env[loop0][12]); }

}

Expand All @@ -41,7 +41,7 @@
if (argc == loop0) { printf("Error: No hostname was supplied the '-h' option.\n"); print_usage(); return -1; }

// Set the hostname to the supplied value.
strncpy(hostname, argv[loop0], sizeof(hostname));
snprintf(hostname, sizeof(hostname), "%s", argv[loop0]);

}

Expand Down
4 changes: 2 additions & 2 deletions src/ps2client.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
for (loop0=0; env[loop0]; loop0++) {

// A hostname has been specified...
if (strncmp(env[loop0], "PS2HOSTNAME", 11) == 0) { strncpy(hostname, &env[loop0][12], sizeof(hostname)); }
if (strncmp(env[loop0], "PS2HOSTNAME", 11) == 0) { snprintf(hostname, sizeof(hostname), "%s", &env[loop0][12]); }

}

Expand All @@ -39,7 +39,7 @@
if (argc == loop0) { printf("Error: No hostname was supplied the '-h' option.\n"); print_usage(); return -1; }

// Set the hostname to the supplied value.
strncpy(hostname, argv[loop0], sizeof(hostname));
snprintf(hostname, sizeof(hostname), "%s", argv[loop0]);

}

Expand Down
22 changes: 12 additions & 10 deletions src/ps2link.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
console_socket = network_listen(0x4712, SOCK_DGRAM);

// Create the console thread.
if (console_socket > 0) { pthread_create(&console_thread_id, NULL, ps2link_thread_console, (void *)&console_thread_id); }
if (console_socket > 0) { pthread_create(&console_thread_id, NULL, ps2link_thread_console, NULL); }

// Connect to the request port.
request_socket = network_connect(hostname, 0x4711, SOCK_STREAM);

// Create the request thread.
if (request_socket > 0) { pthread_create(&request_thread_id, NULL, ps2link_thread_request, (void *)&request_thread_id); }
if (request_socket > 0) { pthread_create(&request_thread_id, NULL, ps2link_thread_request, NULL); }

// Connect to the command port.
command_socket = network_connect(hostname, 0x4712, SOCK_DGRAM);
Expand Down Expand Up @@ -193,7 +193,7 @@
command.length = htons(sizeof(command));
command.offset = htonl(offset);
command.size = htonl(size);
if (pathname) { strncpy(command.pathname, pathname, 256); }
if (pathname) { snprintf(command.pathname, sizeof(command.pathname), "%s", pathname); }

// Send the command packet.
return network_send(command_socket, &command, sizeof(command));
Expand Down Expand Up @@ -233,7 +233,7 @@
command.number = htonl(PS2LINK_COMMAND_DUMPREG);
command.length = htons(sizeof(command));
command.type = htonl(type);
if (pathname) { strncpy(command.pathname, pathname, 256); }
if (pathname) { snprintf(command.pathname, sizeof(command.pathname), "%s", pathname); }

// Send the command packet.
return network_send(command_socket, &command, sizeof(command));
Expand All @@ -247,7 +247,7 @@
command.number = htonl(PS2LINK_COMMAND_GSEXEC);
command.length = htons(sizeof(command));
command.size = htonl(size);
if (pathname) { strncpy(command.pathname, pathname, 256); }
if (pathname) { snprintf(command.pathname, sizeof(command.pathname), "%s", pathname); }

// Send the command packet.
return network_send(command_socket, &command, sizeof(command));
Expand All @@ -262,7 +262,7 @@
command.length = htons(sizeof(command));
command.offset = htonl(offset);
command.size = htonl(size);
if (pathname) { strncpy(command.pathname, pathname, 256); }
if (pathname) { snprintf(command.pathname, sizeof(command.pathname), "%s", pathname); }

// Send the command packet.
return network_send(command_socket, &command, sizeof(command));
Expand Down Expand Up @@ -813,11 +813,12 @@ int ps2link_response_getstat(int result, unsigned int mode, unsigned int attr, u
// PS2LINK THREAD FUNCTIONS //
//////////////////////////////

void *ps2link_thread_console(void *thread_id) {
void *ps2link_thread_console(void *userdata) {
char buffer[1024];

(void)userdata;
// If the socket isn't open, this thread isn't needed.
if (console_socket < 0) { pthread_exit(thread_id); }
if (console_socket < 0) { return NULL; }

// Loop forever...
for (;;) {
Expand All @@ -844,11 +845,12 @@ int ps2link_response_getstat(int result, unsigned int mode, unsigned int attr, u

}

void *ps2link_thread_request(void *thread_id) {
void *ps2link_thread_request(void *userdata) {
struct { unsigned int number; unsigned short length; char buffer[512]; } PACKED packet;

(void)userdata;
// If the socket isn't open, this thread isn't needed.
if (request_socket < 0) { pthread_exit(thread_id); }
if (request_socket < 0) { return NULL; }

// Loop forever...
for (;;) {
Expand Down
21 changes: 11 additions & 10 deletions src/ps2netfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
command.number = htonl(PS2NETFS_COMMAND_DELETE);
command.length = htons(sizeof(command));
command.flags = htonl(flags);
if (pathname) { strncpy(command.pathname, pathname, 256); }
if (pathname) { snprintf(command.pathname, sizeof(command.pathname), "%s", pathname); }

// Send the command packet.
if (network_send(ps2netfs_socket, &command, sizeof(command)) < 0) { return -1; }
Expand All @@ -180,7 +180,7 @@
command.number = htonl(PS2NETFS_COMMAND_MKDIR);
command.length = htons(sizeof(command));
command.flags = htonl(flags);
if (pathname) { strncpy(command.pathname, pathname, 256); }
if (pathname) { snprintf(command.pathname, sizeof(command.pathname), "%s", pathname); }

// Send the command packet.
if (network_send(ps2netfs_socket, &command, sizeof(command)) < 0) { return -1; }
Expand All @@ -201,7 +201,7 @@
command.number = htonl(PS2NETFS_COMMAND_RMDIR);
command.length = htons(sizeof(command));
command.flags = htonl(flags);
if (pathname) { strncpy(command.pathname, pathname, 256); }
if (pathname) { snprintf(command.pathname, sizeof(command.pathname), "%s", pathname); }

// Send the command packet.
if (network_send(ps2netfs_socket, &command, sizeof(command)) < 0) { return -1; }
Expand All @@ -222,7 +222,7 @@
command.number = htonl(PS2NETFS_COMMAND_DOPEN);
command.length = htons(sizeof(command));
command.flags = htonl(flags);
if (pathname) { strncpy(command.pathname, pathname, 256); }
if (pathname) { snprintf(command.pathname, sizeof(command.pathname), "%s", pathname); }

// Send the command packet.
if (network_send(ps2netfs_socket, &command, sizeof(command)) < 0) { return -1; }
Expand Down Expand Up @@ -296,7 +296,7 @@
command.number = htonl(PS2NETFS_COMMAND_SYNC);
command.length = htons(sizeof(command));
command.flags = htonl(flags);
if (device) { strncpy(command.device, device, 256); }
if (device) { snprintf(command.device, sizeof(command.device), "%s", device); }

// Send the command packet.
if (network_send(ps2netfs_socket, &command, sizeof(command)) < 0) { return -1; }
Expand All @@ -318,9 +318,9 @@
command.length = htons(sizeof(command));
command.flags = htonl(flags);
command.argc = htonl(argc);
if (device) { strncpy(command.device, device, 256); }
if (fsname) { strncpy(command.fsname, fsname, 256); }
if (argv) { strncpy(command.argv, argv, 256); }
if (device) { snprintf(command.device, sizeof(command.device), "%s", device); }
if (fsname) { snprintf(command.fsname, sizeof(command.fsname), "%s", fsname); }
if (argv) { snprintf(command.argv, sizeof(command.argv), "%s", argv); }

// Send the command packet.
if (network_send(ps2netfs_socket, &command, sizeof(command)) < 0) { return -1; }
Expand All @@ -337,10 +337,11 @@
struct { unsigned int number; unsigned short length; int flags; char device[256]; } PACKED command;
struct { unsigned int number; unsigned short length; int result; } PACKED response;

(void)flags;
// Build the command packet.
command.number = htonl(PS2NETFS_COMMAND_UMOUNT);
command.length = htons(sizeof(command));
if (device) { strncpy(command.device, device, 256); }
if (device) { snprintf(command.device, sizeof(command.device), "%s", device); }

// Send the command packet.
if (network_send(ps2netfs_socket, &command, sizeof(command)) < 0) { return -1; }
Expand Down Expand Up @@ -375,7 +376,7 @@
command.number = htonl(PS2NETFS_COMMAND_DEVLIST);
command.length = htons(sizeof(command));
command.flags = htonl(flags);
if (pathname) { strncpy(command.pathname, pathname, 256); }
if (pathname) { snprintf(command.pathname, sizeof(command.pathname), "%s", pathname); }

// Send the command packet.
if (network_send(ps2netfs_socket, &command, sizeof(command)) < 0) { return -1; }
Expand Down
2 changes: 1 addition & 1 deletion src/utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

}

int fix_pathname(char *pathname) { int loop0 = 0;
int fix_pathname(char *pathname) { unsigned int loop0 = 0;

// If empty, set a pathname default.
if (pathname[0] == 0) { strcpy(pathname, "."); }
Expand Down
Loading