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
4 changes: 2 additions & 2 deletions ee/erl/src/erl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ struct erl_record_t * _init_load_erl_from_file(const char * fname, char * erl_id
argv[0] = erl_id;
argv[1] = 0;

snprintf(tfname, sizeof(tfname), "%s%s", _init_erl_prefix, fname);
snprintf(tfname, sizeof(tfname), "%*s%s", sizeof(_init_erl_prefix), _init_erl_prefix, fname);

return load_erl_from_file(tfname, 1, argv);
}
Expand Down Expand Up @@ -1093,7 +1093,7 @@ struct erl_record_t * _init_load_erl_from_file_to_addr(const char * fname, u32 a
argv[0] = erl_id;
argv[1] = 0;

snprintf(tfname, sizeof(tfname), "%s%s", _init_erl_prefix, fname);
snprintf(tfname, sizeof(tfname), "%*s%s", sizeof(_init_erl_prefix), _init_erl_prefix, fname);

return load_erl_from_file_to_addr(tfname, addr, 1, argv);
}
Expand Down
8 changes: 4 additions & 4 deletions ee/font/src/fontx.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ int fontx_load_single_krom(fontx_t *fontx)
fontx_header = (fontx_hdr*)fontx->font;

// define header as single-byte font
strncpy(fontx_header->id, "FONTX2", 6);
strcpy(fontx_header->id, "FONTX2");
fontx_header->id[6] = '\0';
strncpy(fontx_header->name, "KROM", 8);
strcpy(fontx_header->name, "KROM");
fontx_header->name[8] = '\0';

fontx_header->width = 8;
Expand Down Expand Up @@ -237,9 +237,9 @@ int fontx_load_double_krom(fontx_t *fontx)
fontx_header = (fontx_hdr*)fontx->font;

// define the header as double-byte font
strncpy(fontx_header->id, "FONTX2", 6);
strcpy(fontx_header->id, "FONTX2");
fontx_header->id[6] = '\0';
strncpy(fontx_header->name, "KROM", 8);
strcpy(fontx_header->name, "KROM");
fontx_header->name[8] = '\0';

fontx_header->width = 16;
Expand Down
6 changes: 1 addition & 5 deletions ee/ioprpgen/src/ioprpgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,7 @@ ioprpgen_write_romdir_entry(const struct ioprpgen_ctx *ctx, const char *name, u3
{
struct ioprp_romdir_entry ent;
memset(&ent, 0, sizeof(ent));
if ( name )
{
strncpy(ent.m_name, name, sizeof(ent.m_name) - 1);
ent.m_name[sizeof(ent.m_name) - 1] = 0;
}
strlcpy(ent.m_name, name ? name : "", sizeof(ent.m_name));
ent.m_extinfo_size = extinfo_size;
ent.m_data_size = data_size;
return ctx->m_write_cb(ctx->m_write_cb_userdata, ctx, &ent, sizeof(ent)) == sizeof(ent);
Expand Down
24 changes: 8 additions & 16 deletions ee/kernel/src/fileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ int fioOpen(const char *name, int mode)
WaitSema(_fio_completion_sema);

arg.mode = mode;
strncpy(arg.name, name, FIO_PATH_MAX - 1);
arg.name[FIO_PATH_MAX - 1] = 0;
strlcpy(arg.name, name, sizeof(arg.name));

if ((res = sceSifCallRpc(&_fio_cd, FIO_F_OPEN, _fio_block_mode, &arg, sizeof arg,
_fio_recv_data, 4, (void *)_fio_intr, NULL)) >= 0) {
Expand Down Expand Up @@ -399,8 +398,7 @@ int fioRemove(const char *name)
WaitSema(_fio_io_sema);
WaitSema(_fio_completion_sema);

strncpy(arg.path, name, FIO_PATH_MAX - 1);
arg.path[FIO_PATH_MAX - 1] = 0;
strlcpy(arg.path, name, sizeof(arg.path));

if ((res = sceSifCallRpc(&_fio_cd, FIO_F_REMOVE, 0, &arg, sizeof arg,
&arg, 4, (void *)_fio_intr, NULL)) >= 0) {
Expand Down Expand Up @@ -432,8 +430,7 @@ int fioMkdir(const char *path)
WaitSema(_fio_io_sema);
WaitSema(_fio_completion_sema);

strncpy(arg.path, path, FIO_PATH_MAX - 1);
arg.path[FIO_PATH_MAX - 1] = 0;
strlcpy(arg.path, path, sizeof(arg.path));

if ((res = sceSifCallRpc(&_fio_cd, FIO_F_MKDIR, 0, &arg, sizeof arg,
&arg, 4, (void *)_fio_intr, NULL)) >= 0) {
Expand Down Expand Up @@ -465,8 +462,7 @@ int fioRmdir(const char *dirname)
WaitSema(_fio_io_sema);
WaitSema(_fio_completion_sema);

strncpy(arg.path, dirname, FIO_PATH_MAX - 1);
arg.path[FIO_PATH_MAX - 1] = 0;
strlcpy(arg.path, dirname, sizeof(arg.path));

if ((res = sceSifCallRpc(&_fio_cd, FIO_F_RMDIR, 0, &arg, sizeof arg,
&arg, 4, (void *)_fio_intr, NULL)) >= 0) {
Expand Down Expand Up @@ -542,8 +538,7 @@ int fioDopen(const char *name)
WaitSema(_fio_io_sema);
WaitSema(_fio_completion_sema);

strncpy(arg.name, name, FIO_PATH_MAX - 1);
arg.name[FIO_PATH_MAX - 1] = 0;
strlcpy(arg.name, name, sizeof(arg.name));

if ((res = sceSifCallRpc(&_fio_cd, FIO_F_DOPEN, 0, &arg, sizeof arg,
&arg, 4, (void *)_fio_intr, NULL)) >= 0) {
Expand Down Expand Up @@ -636,8 +631,7 @@ int fioGetstat(const char *name, io_stat_t *buf)
WaitSema(_fio_completion_sema);

arg.p.buf = buf;
strncpy(arg.name, name, FIO_PATH_MAX - 1);
arg.name[FIO_PATH_MAX - 1] = 0;
strlcpy(arg.name, name, sizeof(arg.name));

if (!IS_UNCACHED_SEG(buf))
sceSifWriteBackDCache(buf, sizeof(io_stat_t));
Expand Down Expand Up @@ -670,8 +664,7 @@ int fioChstat(const char *name, io_stat_t *buf, u32 cbit)

arg.p.cbit = cbit;
memcpy(&arg.stat, buf, sizeof(io_stat_t));
strncpy(arg.name, name, FIO_PATH_MAX - 1);
arg.name[FIO_PATH_MAX - 1] = 0;
strlcpy(arg.name, name, sizeof(arg.name));

if ((res = sceSifCallRpc(&_fio_cd, FIO_F_CHSTAT, 0, &arg, sizeof arg,
&arg, 4, (void *)_fio_intr, NULL)) >= 0) {
Expand Down Expand Up @@ -703,8 +696,7 @@ int fioFormat(const char *name)
WaitSema(_fio_io_sema);
WaitSema(_fio_completion_sema);

strncpy(arg.path, name, FIO_PATH_MAX - 1);
arg.path[FIO_PATH_MAX - 1] = 0;
strlcpy(arg.path, name, sizeof(arg.path));

if ((res = sceSifCallRpc(&_fio_cd, FIO_F_FORMAT, 0, &arg, sizeof arg,
&arg, 4, (void *)_fio_intr, NULL)) >= 0) {
Expand Down
3 changes: 1 addition & 2 deletions ee/kernel/src/iopheap.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ int SifLoadIopHeap(const char *path, void *addr)
return -E_LIB_API_INIT;

arg.p.addr = addr;
strncpy(arg.path, path, LIH_PATH_MAX - 1);
arg.path[LIH_PATH_MAX - 1] = 0;
strlcpy(arg.path, path, sizeof(arg.path));

if (sceSifCallRpc(&_ih_cd, 3, 0, &arg, sizeof arg, &arg, 4, NULL, NULL) < 0)
return -E_SIF_RPC_CALL;
Expand Down
12 changes: 4 additions & 8 deletions ee/kernel/src/loadfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ int _SifLoadModule(const char *path, int arg_len, const char *args, int *modres,

memset(&arg, 0, sizeof arg);

strncpy(arg.path, path, LF_PATH_MAX - 1);
arg.path[LF_PATH_MAX - 1] = 0;
strlcpy(arg.path, path, sizeof(arg.path));

if (args && arg_len) {
arg.p.arg_len = arg_len > LF_ARG_MAX ? LF_ARG_MAX : arg_len;
Expand Down Expand Up @@ -167,8 +166,7 @@ int SifSearchModuleByName(const char *name)
if (SifLoadFileInit() < 0)
return -SCE_EBINDMISS;

strncpy(arg.name, name, LF_PATH_MAX - 1);
arg.name[LF_PATH_MAX - 1] = 0;
strlcpy(arg.name, name, sizeof(arg.name));

if (sceSifCallRpc(&_lf_cd, LF_F_SEARCH_MOD_BY_NAME, 0, &arg, sizeof arg, &arg, 4, NULL, NULL) < 0)
return -SCE_ECALLMISS;
Expand Down Expand Up @@ -201,10 +199,8 @@ int _SifLoadElfPart(const char *path, const char *secname, t_ExecData *data, int
if (SifLoadFileInit() < 0)
return -SCE_EBINDMISS;

strncpy(arg.path, path, LF_PATH_MAX - 1);
strncpy(arg.secname, secname, LF_ARG_MAX - 1);
arg.path[LF_PATH_MAX - 1] = 0;
arg.secname[LF_ARG_MAX - 1] = 0;
strlcpy(arg.path, path, sizeof(arg.path));
strlcpy(arg.secname, secname, sizeof(arg.secname));

if (sceSifCallRpc(&_lf_cd, fno, 0, &arg, sizeof arg, &arg,
sizeof(t_ExecData), NULL, NULL) < 0)
Expand Down
2 changes: 1 addition & 1 deletion ee/libcglue/src/glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct passwd __dummy_passwd;
__attribute__((constructor))
static void __dummy_passwd_init(void)
{
strncpy(__dummy_passwd_loginbuf, "ps2user", sizeof(__dummy_passwd_loginbuf));
strcpy(__dummy_passwd_loginbuf, "ps2user");
__dummy_passwd.pw_name = &__dummy_passwd_loginbuf[0];
__dummy_passwd.pw_passwd = "xxx";
__dummy_passwd.pw_uid = 1000;
Expand Down
3 changes: 1 addition & 2 deletions ee/libcglue/src/ps2sdkapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,7 @@ int __fioDreadHelper(void *userdata, struct dirent *dir)
}

dir->d_fileno = rv; // TODO: This number should be in theory a unique number per file
strncpy(dir->d_name, iodir.name, __MAXNAMLEN);
dir->d_name[__MAXNAMLEN - 1] = 0;
snprintf(dir->d_name, sizeof(dir->d_name), "%*s", (int)(sizeof(iodir.name) - 1), iodir.name);
dir->d_reclen = 0;
switch (iodir.stat.mode & FIO_SO_IFMT) {
case FIO_SO_IFLNK: dir->d_type = DT_LNK; break;
Expand Down
5 changes: 3 additions & 2 deletions ee/network/netman/src/rpc_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <kernel.h>
#include <sifrpc.h>
#include <string.h>
#include <stdio.h>
#include <malloc.h>
#include <netman.h>
#include <netman_rpc.h>
Expand Down Expand Up @@ -293,7 +294,7 @@ int NetManSetMainIF(const char *name)

WaitSema(NetManIOSemaID);

strncpy(TransmitBuffer.netifName, name, NETMAN_NETIF_NAME_MAX_LEN);
strlcpy(TransmitBuffer.netifName, name, sizeof(TransmitBuffer.netifName));
TransmitBuffer.netifName[NETMAN_NETIF_NAME_MAX_LEN-1] = '\0';
if((result=sceSifCallRpc(&NETMAN_rpc_cd, NETMAN_IOP_RPC_FUNC_SET_MAIN_NETIF, 0, &TransmitBuffer, NETMAN_NETIF_NAME_MAX_LEN, &ReceiveBuffer, sizeof(s32), NULL, NULL))>=0)
result=ReceiveBuffer.result;
Expand All @@ -316,7 +317,7 @@ int NetManQueryMainIF(char *name)
{
if((result=ReceiveBuffer.QueryMainNetIFResult.result) == 0)
{
strncpy(name, ReceiveBuffer.QueryMainNetIFResult.name, NETMAN_NETIF_NAME_MAX_LEN);
sprintf(name, "%*s", (int)sizeof(ReceiveBuffer.QueryMainNetIFResult.name), ReceiveBuffer.QueryMainNetIFResult.name);
name[NETMAN_NETIF_NAME_MAX_LEN-1] = '\0';
}
}
Expand Down
3 changes: 1 addition & 2 deletions ee/rpc/cdvd/src/libcdvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ s32 sceCdSearchFile(sceCdlFILE *file, const char *name)
}
}

strncpy(searchFileSendBuff.name, name, 255);
searchFileSendBuff.name[255] = '\0';
strlcpy(searchFileSendBuff.name, name, sizeof(searchFileSendBuff.name));
searchFileSendBuff.dest = &searchFileSendBuff;

if (CdDebug > 0)
Expand Down
3 changes: 1 addition & 2 deletions ee/rpc/filexio/src/fileXio_ps2sdk.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,7 @@ int __fileXioDreadHelper(void *userdata, struct dirent *dir)
}

dir->d_fileno = rv; // TODO: This number should be in theory a unique number per file
strncpy(dir->d_name, ioxdir.name, __MAXNAMLEN);
dir->d_name[__MAXNAMLEN - 1] = 0;
snprintf(dir->d_name, sizeof(dir->d_name), "%*s", (int)(sizeof(ioxdir.name) - 1), ioxdir.name);
dir->d_reclen = 0;
switch (ioxdir.stat.mode & FIO_S_IFMT) {
case FIO_S_IFLNK: dir->d_type = DT_LNK; break;
Expand Down
Loading
Loading