* Move strncpy() from core to the pluginlib
* Introduce strlcpy() and use that instead in most places (use memcpy in a few) in core and some plugins
* Drop strncpy() from the codec api as no codec used it
* Bump codec and plugin api versions


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21863 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Nils Wallménius 2009-07-14 13:57:45 +00:00
parent c2900a1bac
commit 3d4701a6e4
83 changed files with 271 additions and 271 deletions

View file

@ -543,7 +543,7 @@ char * get_game_text(int selected_item, void *data,
rb->snprintf(text_buffer, 50,"%s vs. %s (%s)", temp_node->white_player,
temp_node->black_player, temp_node->game_date);
rb->strncpy(buffer, text_buffer, buffer_len);
rb->strlcpy(buffer, text_buffer, buffer_len);
return buffer;
}

View file

@ -283,8 +283,7 @@ enum plugin_status plugin_start(const void* parameter)
while (1)
{
/* copy one lcd line */
rb->strncpy(output, ptr, display_columns);
output[display_columns] = '\0';
rb->strlcpy(output, ptr, display_columns + 1);
/* typecast to kill a warning... */
if((int)rb->strlen(ptr) < display_columns)

View file

@ -59,7 +59,6 @@ int my_close(int id);
#define memcmp(a,b,c) rb->memcmp((a),(b),(c))
#define memchr(a,b,c) rb->memchr((a),(b),(c))
#define strcpy(a,b) rb->strcpy((a),(b))
#define strncpy(a,b,c) rb->strncpy((a),(b),(c))
#define strlen(a) rb->strlen((a))
#define strcmp(a,b) rb->strcmp((a),(b))
#define strncmp(a,b,c) rb->strncmp((a),(b),(c))

View file

@ -130,7 +130,7 @@ output_header_props (void)
{
char buffer[128];
rb->strncpy (buffer, "GM[1]FF[4]CA[UTF-8]AP[Rockbox Goban:1.0]ST[2]\n\n",
rb->strlcpy (buffer, "GM[1]FF[4]CA[UTF-8]AP[Rockbox Goban:1.0]ST[2]\n\n",
sizeof (buffer));
write_file (sgf_fd, buffer, rb->strlen (buffer));

View file

@ -1511,7 +1511,7 @@ void init_invadrox(void)
if (highscore_load(HISCOREFILE, &hiscore, 1) < 0) {
/* Init hiscore to 0 */
rb->strncpy(hiscore.name, "Invader", sizeof(hiscore.name));
rb->strlcpy(hiscore.name, "Invader", sizeof(hiscore.name));
hiscore.score = 0;
hiscore.level = 1;
}

View file

@ -330,11 +330,11 @@ static void hash_pw(union hash *out)
static void make_key(void)
{
int i;
char buf[sizeof(master_pw) + sizeof(salt) + 1];
char buf[sizeof(master_pw) + sizeof(salt) + 1] = {0};
struct md5_s key_md5;
size_t len = rb->strlen(master_pw);
rb->strncpy(buf, master_pw, sizeof(buf));
rb->strlcpy(buf, master_pw, sizeof(buf));
rb->memcpy(&buf[len], &salt, sizeof(salt));
@ -418,7 +418,7 @@ static int parse_buffer(void)
break;
}
rb->strncpy(entry->title, start, FIELD_LEN);
rb->strlcpy(entry->title, start, FIELD_LEN);
start = end + 1;
end = rb->strchr(start, '\0'); /* find eol */
@ -428,7 +428,7 @@ static int parse_buffer(void)
break;
}
rb->strncpy(entry->name, start, FIELD_LEN);
rb->strlcpy(entry->name, start, FIELD_LEN);
start = end + 1;
end = rb->strchr(start, '\0'); /* find eol */
@ -437,7 +437,7 @@ static int parse_buffer(void)
{
break;
}
rb->strncpy(entry->password, start, FIELD_LEN);
rb->strlcpy(entry->password, start, FIELD_LEN);
start = end + 1;
entry->used = true;
if (i + 1 < MAX_ENTRIES - 1)
@ -469,13 +469,13 @@ static void write_output(int fd)
for (i = 0; i < pw_list.num_entries; i++)
{
len = rb->strlen(entry->title);
rb->strncpy(p, entry->title, len+1);
rb->strlcpy(p, entry->title, len+1);
p += len+1;
len = rb->strlen(entry->name);
rb->strncpy(p, entry->name, len+1);
rb->strlcpy(p, entry->name, len+1);
p += len+1;
len = rb->strlen(entry->password);
rb->strncpy(p, entry->password, len+1);
rb->strlcpy(p, entry->password, len+1);
p += len+1;
if (entry->next)
entry = entry->next;
@ -517,7 +517,7 @@ static int enter_pw(char *pw_buf, size_t buflen, bool new_pw)
}
else
{
rb->strncpy(pw_buf, buf[0], buflen);
rb->strlcpy(pw_buf, buf[0], buflen);
hash_pw(&pwhash);
return 0;
}

View file

@ -6,6 +6,7 @@ playback_control.c
rgb_hsv.c
buflib.c
display_text.c
strncpy.c
#if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4)
grey_core.c
grey_draw.c

View file

@ -139,7 +139,7 @@ int configfile_load(const char *filename, struct configdata *cfg,
break;
case TYPE_STRING:
rb->strncpy(cfg[i].string, val, cfg[i].max);
rb->strlcpy(cfg[i].string, val, cfg[i].max);
break;
}
}

View file

@ -72,7 +72,7 @@ int highscore_load(char *filename, struct highscore *scores, int num_scores)
scores[i].score = rb->atoi(score);
scores[i].level = rb->atoi(level);
rb->strncpy(scores[i].name, name, sizeof(scores[i].name)-1);
rb->strlcpy(scores[i].name, name, sizeof(scores[i].name));
i++;
}
rb->close(fd);
@ -100,8 +100,7 @@ int highscore_update(int score, int level, const char *name,
entry = scores + pos;
entry->score = score;
entry->level = level;
rb->strncpy(entry->name, name, sizeof(entry->name));
entry->name[sizeof(entry->name)-1] = '\0';
rb->strlcpy(entry->name, name, sizeof(entry->name));
return pos;
}

125
apps/plugins/lib/strncpy.c Normal file
View file

@ -0,0 +1,125 @@
/*
FUNCTION
<<strncpy>>---counted copy string
INDEX
strncpy
ANSI_SYNOPSIS
#include <string.h>
char *strncpy(char *<[dst]>, const char *<[src]>, size_t <[length]>);
TRAD_SYNOPSIS
#include <string.h>
char *strncpy(<[dst]>, <[src]>, <[length]>)
char *<[dst]>;
char *<[src]>;
size_t <[length]>;
DESCRIPTION
<<strncpy>> copies not more than <[length]> characters from the
the string pointed to by <[src]> (including the terminating
null character) to the array pointed to by <[dst]>. If the
string pointed to by <[src]> is shorter than <[length]>
characters, null characters are appended to the destination
array until a total of <[length]> characters have been
written.
RETURNS
This function returns the initial value of <[dst]>.
PORTABILITY
<<strncpy>> is ANSI C.
<<strncpy>> requires no supporting OS subroutines.
QUICKREF
strncpy ansi pure
*/
#include <string.h>
#include <limits.h>
/*SUPPRESS 560*/
/*SUPPRESS 530*/
/* Nonzero if either X or Y is not aligned on a "long" boundary. */
#define UNALIGNED(X, Y) \
(((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1)))
#if LONG_MAX == 2147483647L
#define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080)
#else
#if LONG_MAX == 9223372036854775807L
/* Nonzero if X (a long int) contains a NULL byte. */
#define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080)
#else
#error long int is not a 32bit or 64bit type.
#endif
#endif
#ifndef DETECTNULL
#error long int is not a 32bit or 64bit byte
#endif
#define TOO_SMALL(LEN) ((LEN) < sizeof (long))
char *
_DEFUN (strncpy, (dst0, src0),
char *dst0 _AND
_CONST char *src0 _AND
size_t count)
{
#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__)
char *dscan;
_CONST char *sscan;
dscan = dst0;
sscan = src0;
while (count > 0)
{
--count;
if ((*dscan++ = *sscan++) == '\0')
break;
}
while (count-- > 0)
*dscan++ = '\0';
return dst0;
#else
char *dst = dst0;
_CONST char *src = src0;
long *aligned_dst;
_CONST long *aligned_src;
/* If SRC and DEST is aligned and count large enough, then copy words. */
if (!UNALIGNED (src, dst) && !TOO_SMALL (count))
{
aligned_dst = (long*)dst;
aligned_src = (long*)src;
/* SRC and DEST are both "long int" aligned, try to do "long int"
sized copies. */
while (count >= sizeof (long int) && !DETECTNULL(*aligned_src))
{
count -= sizeof (long int);
*aligned_dst++ = *aligned_src++;
}
dst = (char*)aligned_dst;
src = (char*)aligned_src;
}
while (count > 0)
{
--count;
if ((*dst++ = *src++) == '\0')
break;
}
while (count-- > 0)
*dst++ = '\0';
return dst0;
#endif /* not PREFER_SIZE_OVER_SPEED */
}

View file

@ -51,7 +51,7 @@
#define strcpy rb->strcpy
#define strip_extension rb->strip_extension
#define strlen rb->strlen
#define strncpy rb->strncpy
#define strlcpy rb->strlcpy
#define strrchr rb->strrchr
#endif

View file

@ -181,8 +181,7 @@ const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) {
void luaO_chunkid (char *out, const char *source, size_t bufflen) {
if (*source == '=') {
strncpy(out, source+1, bufflen); /* remove first char */
out[bufflen-1] = '\0'; /* ensures null termination */
strlcpy(out, source+1, bufflen); /* remove first char */
}
else { /* out = "source", or "...source" */
if (*source == '@') {

View file

@ -737,9 +737,7 @@ static const char *scanformat (lua_State *L, const char *strfrmt, char *form) {
if (isdigit(uchar(*p)))
luaL_error(L, "invalid format (width or precision too long)");
*(form++) = '%';
strncpy(form, strfrmt, p - strfrmt + 1);
form += p - strfrmt + 1;
*form = '\0';
strlcpy(form, strfrmt, p - strfrmt + 1);
return p;
}

View file

@ -63,7 +63,7 @@ long pow(long x, long y);
#define strchr rb->strchr
#define strcmp rb->strcmp
#define strcpy rb->strcpy
#define strncpy rb->strncpy
#define strlcpy rb->strlcpy
#define strlen rb->strlen
#endif /* _ROCKCONF_H_ */

View file

@ -2399,9 +2399,8 @@ char mp3_name[80];
void get_mp3_filename(const char *wav_name)
{
int slen = rb->strlen(wav_name);
rb->strncpy(mp3_name, wav_name, 79);
rb->strncpy(mp3_name + slen - 4, ".mp3", 5);
rb->strlcpy(mp3_name, wav_name, sizeof(mp3_name));
rb->strlcpy(mp3_name + rb->strlen(mp3_name) - 4, ".mp3", 5);
}
#if CONFIG_KEYPAD == IRIVER_H100_PAD || CONFIG_KEYPAD == IRIVER_H300_PAD

View file

@ -344,7 +344,7 @@ static void backlight_brightness_formatter(char *buf, size_t length,
int value, const char *input)
{
if (value < 0)
rb->strncpy(buf, BACKLIGHT_OPTION_DEFAULT, length);
rb->strlcpy(buf, BACKLIGHT_OPTION_DEFAULT, length);
else
rb->snprintf(buf, length, "%d", value + MIN_BRIGHTNESS_SETTING);

View file

@ -913,7 +913,7 @@ bool get_albumart_for_index_from_db(const int slide_index, char *buf,
{
if ( slide_index == -1 )
{
rb->strncpy( buf, EMPTY_SLIDE, buflen );
rb->strlcpy( buf, EMPTY_SLIDE, buflen );
}
if (!rb->tagcache_search(&tcs, tag_filename))
@ -930,8 +930,7 @@ bool get_albumart_for_index_from_db(const int slide_index, char *buf,
#ifdef HAVE_TC_RAMCACHE
if (rb->tagcache_fill_tags(&id3, tcs.result))
{
rb->strncpy(id3.path, tcs.result, sizeof(id3.path));
id3.path[sizeof(id3.path) - 1] = 0;
rb->strlcpy(id3.path, tcs.result, sizeof(id3.path));
}
else
#endif

View file

@ -70,8 +70,7 @@ static bool file_properties(char* selected_file)
char* ptr = rb->strrchr(selected_file, '/') + 1;
int dirlen = (ptr - selected_file);
rb->strncpy(tstr, selected_file, dirlen);
tstr[dirlen] = 0;
rb->strlcpy(tstr, selected_file, dirlen + 1);
dir = rb->opendir(tstr);
if (dir)
@ -212,7 +211,7 @@ static bool dir_properties(char* selected_file)
{
DPS dps;
char tstr[64];
rb->strncpy(dps.dirname, selected_file, MAX_PATH);
rb->strlcpy(dps.dirname, selected_file, MAX_PATH);
dps.len = MAX_PATH;
dps.dc = 0;
dps.fc = 0;
@ -220,7 +219,7 @@ static bool dir_properties(char* selected_file)
if(false == _dir_properties(&dps))
return false;
rb->strncpy(str_dirname, selected_file, MAX_PATH);
rb->strlcpy(str_dirname, selected_file, MAX_PATH);
rb->snprintf(str_dircount, sizeof str_dircount, "Subdirs: %d", dps.dc);
rb->snprintf(str_filecount, sizeof str_filecount, "Files: %d", dps.fc);
rb->snprintf(str_size, sizeof str_size, "Size: %s",
@ -236,35 +235,35 @@ char * get_props(int selected_item, void* data, char *buffer, size_t buffer_len)
switch(selected_item)
{
case 0:
rb->strncpy(buffer, str_dirname, buffer_len);
rb->strlcpy(buffer, str_dirname, buffer_len);
break;
case 1:
rb->strncpy(buffer, its_a_dir ? str_dircount : str_filename,
rb->strlcpy(buffer, its_a_dir ? str_dircount : str_filename,
buffer_len);
break;
case 2:
rb->strncpy(buffer, its_a_dir ? str_filecount : str_size, buffer_len);
rb->strlcpy(buffer, its_a_dir ? str_filecount : str_size, buffer_len);
break;
case 3:
rb->strncpy(buffer, its_a_dir ? str_size : str_date, buffer_len);
rb->strlcpy(buffer, its_a_dir ? str_size : str_date, buffer_len);
break;
case 4:
rb->strncpy(buffer, its_a_dir ? "" : str_time, buffer_len);
rb->strlcpy(buffer, its_a_dir ? "" : str_time, buffer_len);
break;
case 5:
rb->strncpy(buffer, its_a_dir ? "" : str_artist, buffer_len);
rb->strlcpy(buffer, its_a_dir ? "" : str_artist, buffer_len);
break;
case 6:
rb->strncpy(buffer, its_a_dir ? "" : str_title, buffer_len);
rb->strlcpy(buffer, its_a_dir ? "" : str_title, buffer_len);
break;
case 7:
rb->strncpy(buffer, its_a_dir ? "" : str_album, buffer_len);
rb->strlcpy(buffer, its_a_dir ? "" : str_album, buffer_len);
break;
case 8:
rb->strncpy(buffer, its_a_dir ? "" : str_duration, buffer_len);
rb->strlcpy(buffer, its_a_dir ? "" : str_duration, buffer_len);
break;
default:
rb->strncpy(buffer, "ERROR", buffer_len);
rb->strlcpy(buffer, "ERROR", buffer_len);
break;
}
return buffer;
@ -284,8 +283,7 @@ enum plugin_status plugin_start(const void* parameter)
struct dirent* entry;
char* ptr = rb->strrchr(file, '/') + 1;
int dirlen = (ptr - file);
rb->strncpy(str_dirname, file, dirlen);
str_dirname[dirlen] = 0;
rb->strlcpy(str_dirname, file, dirlen + 1);
dir = rb->opendir(str_dirname);
if (dir)

View file

@ -86,7 +86,7 @@ void traversedir(char* location, char* name)
/* check if path is removed directory, if so dont enter it */
rb->snprintf(path, MAX_PATH, "%s/%s", fullpath, entry->d_name);
while(path[0] == '/')
rb->strncpy(path, path + 1, rb->strlen(path));
rb->strlcpy(path, path + 1, sizeof(path));
for(i = 0; i < num_replaced_dirs; i++)
{
if(!rb->strcmp(path, removed_dirs[i]))
@ -141,8 +141,8 @@ bool custom_dir(void)
(num_replaced_dirs < MAX_REMOVED_DIRS))
{
num_replaced_dirs ++;
rb->strncpy(removed_dirs[num_replaced_dirs - 1], line + 2,
rb->strlen(line));
rb->strlcpy(removed_dirs[num_replaced_dirs - 1], line + 2,
sizeof(line));
}
}
rb->close(fd2);
@ -157,7 +157,7 @@ bool custom_dir(void)
{
/* remove preceeding '/'s from the line */
while(line[0] == '/')
rb->strncpy(line, line + 1, rb->strlen(line));
rb->strlcpy(line, line + 1, sizeof(line));
rb->snprintf(formatted_line, MAX_PATH, "/%s", line);
@ -237,7 +237,7 @@ void generate(void)
char *list_get_name_cb(int selected_item, void* data, char* buf, size_t buf_len)
{
(void)data;
rb->strncpy(buf, list->folder[selected_item], buf_len);
rb->strlcpy(buf, list->folder[selected_item], buf_len);
return buf;
}

View file

@ -162,11 +162,10 @@ static void munge_name(char *buf, const size_t bufsiz) {
* checksum or something like that?
*/
static void build_slot_path(char *buf, size_t bufsiz, size_t slot_id) {
char name_buf[40];
char name_buf[17];
/* munge state file name */
strncpy(name_buf, rom.name, 40);
name_buf[16] = '\0';
strlcpy(name_buf, rom.name, sizeof(name_buf));
munge_name(name_buf, strlen(name_buf));
/* glom the whole mess together */
@ -211,7 +210,7 @@ static bool do_file(char *path, char *desc, bool is_load) {
/* build description buffer */
memset(desc_buf, 0, 20);
if (desc)
strncpy(desc_buf, desc, 20);
strlcpy(desc_buf, desc, 20);
/* save state */
write(fd, desc_buf, 20);
@ -241,8 +240,7 @@ static bool do_slot(size_t slot_id, bool is_load) {
if (!is_load)
if (rb->kbd_input(desc_buf, 20) || !strlen(desc_buf))
{
memset(desc_buf, 0, 20);
strncpy(desc_buf, "Untitled", 20);
strlcpy(desc_buf, "Untitled", 20);
}
/* load/save file */

View file

@ -67,7 +67,7 @@ void dynamic_recompile (struct dynarec_block *newblock);
#define strcat(a,b) rb->strcat((a),(b))
#define memset(a,b,c) rb->memset((a),(b),(c))
#define strcpy(a,b) rb->strcpy((a),(b))
#define strncpy(a,b,c) rb->strncpy((a),(b),(c))
#define strlcpy(a,b,c) rb->strlcpy((a),(b),(c))
#define strlen(a) rb->strlen((a))
#define strcmp(a,b) rb->strcmp((a),(b))
#define strchr(a,b) rb->strchr((a),(b))

View file

@ -686,7 +686,7 @@ static bool browse( char *dst, int dst_size, const char *start )
if( selected < 0 || selected >= item_count )
break;
struct entry* e = &dc[indexes[selected]];
rb->strncpy( bbuf_s, e->name, sizeof( bbuf_s ) );
rb->strlcpy( bbuf_s, e->name, sizeof( bbuf_s ) );
if( !( e->attr & ATTR_DIRECTORY ) )
{
*tree = backup;

View file

@ -213,8 +213,7 @@ bool parse_entry_content(char *line, sc_entry_t *entry, int last_segm)
DEBUGF("Bad entry: pathlen=%d, displen=%d\n", path_len, disp_len);
return false;
}
rb->strncpy(entry->path, path, path_len);
entry->path[path_len] = '\0';
rb->strlcpy(entry->path, path, path_len + 1);
rb->strcpy(entry->disp, disp); /* Safe since we've checked the length */
entry->explicit_disp = expl;
return true;
@ -295,15 +294,14 @@ bool parse_name_value(char *line, char *name, int namesize,
/* Too long name */
return false;
}
rb->strncpy(name, line, name_len);
name[name_len] = '\0';
rb->strlcpy(name, line, name_len + 1);
val_len = rb->strlen(line) - name_len - NAME_VALUE_SEPARATOR_LEN;
if (val_len >= valuesize) {
/* Too long value */
return false;
}
rb->strncpy(value, sep+NAME_VALUE_SEPARATOR_LEN, val_len+1);
rb->strlcpy(value, sep+NAME_VALUE_SEPARATOR_LEN, val_len+1);
return true;
}

View file

@ -689,7 +689,8 @@ static bool redo(void)
static void init_boards(void)
{
rb->strncpy(buffered_boards.filename, SOKOBAN_LEVELS_FILE, MAX_PATH);
rb->strlcpy(buffered_boards.filename, SOKOBAN_LEVELS_FILE,
sizeof(buffered_boards.filename));
current_info.level.index = 0;
current_info.player.row = 0;
@ -1026,8 +1027,8 @@ static bool save(char *filename, bool solution)
/* Create dir if it doesn't exist */
if ((loc = rb->strrchr(filename, '/')) != NULL) {
rb->strncpy(dirname, filename, loc - filename);
dirname[loc - filename] = '\0';
rb->strlcpy(dirname, filename, loc - filename + 1);
if(!(dir = rb->opendir(dirname)))
rb->mkdir(dirname);
else
@ -1082,7 +1083,9 @@ static bool load(char *filename, bool silent)
if (rb->strncmp(buf, "Sokoban", 7) != 0) {
rb->close(fd);
rb->strncpy(buffered_boards.filename, filename, MAX_PATH);
rb->strlcpy(buffered_boards.filename, filename,
sizeof(buffered_boards.filename));
if (!read_levels(true))
return false;

View file

@ -780,11 +780,11 @@ static void save_editor(struct mp3entry *mp3, int splittime)
bool part2_save = true;
/* file name for left part */
rb->strncpy(part1_name, mp3->path, MAX_PATH);
rb->strlcpy(part1_name, mp3->path, MAX_PATH);
generateFileName(part1_name, 1);
/* file name for right part */
rb->strncpy(part2_name, mp3->path, MAX_PATH);
rb->strlcpy(part2_name, mp3->path, MAX_PATH);
generateFileName(part2_name, 2);
while (!exit_request)

View file

@ -603,7 +603,7 @@ void default_state(struct sudoku_state_t* state)
{
int r,c;
rb->strncpy(state->filename,GAME_FILE,MAX_PATH);
rb->strlcpy(state->filename,GAME_FILE,MAX_PATH);
for (r=0;r<9;r++) {
for (c=0;c<9;c++) {
state->startboard[r][c]=default_game[r][c];
@ -626,7 +626,7 @@ void clear_state(struct sudoku_state_t* state)
{
int r,c;
rb->strncpy(state->filename,GAME_FILE,MAX_PATH);
rb->strlcpy(state->filename,GAME_FILE,MAX_PATH);
for (r=0;r<9;r++) {
for (c=0;c<9;c++) {
state->startboard[r][c]='0';
@ -719,7 +719,7 @@ bool load_sudoku(struct sudoku_state_t* state, char* filename)
return(false);
}
rb->strncpy(state->filename,filename,MAX_PATH);
rb->strlcpy(state->filename,filename,MAX_PATH);
n=rb->read(fd,buf,300);
if (n <= 0) {
return(false);
@ -1111,7 +1111,7 @@ bool sudoku_generate(struct sudoku_state_t* state)
rb->snprintf(str,sizeof(str),"Difficulty: %s",difficulty);
display_board(state);
rb->splash(HZ*3, str);
rb->strncpy(state->filename,GAME_FILE,MAX_PATH);
rb->strlcpy(state->filename,GAME_FILE,MAX_PATH);
} else {
display_board(&new_state);
rb->splash(HZ*2, "Aborted");

View file

@ -451,7 +451,6 @@ static void init_ci(void)
/* strings and memory */
ci.strcpy = rb->strcpy;
ci.strncpy = rb->strncpy;
ci.strlen = rb->strlen;
ci.strcmp = rb->strcmp;
ci.strcat = rb->strcat;
@ -716,7 +715,7 @@ enum plugin_status plugin_start(const void* parameter)
/* Test all files in the same directory as the file selected by the
user */
rb->strncpy(dirpath,parameter,sizeof(dirpath));
rb->strlcpy(dirpath,parameter,sizeof(dirpath));
ch = rb->strrchr(dirpath,'/');
ch[1]=0;

View file

@ -133,7 +133,7 @@ char *list_get_name_cb(int selected_item, void* data,
rb->snprintf(buf , buf_len, "%s ...", b);
b[buf_len-10] = t;
}
else rb->strncpy(buf, b, buf_len);
else rb->strlcpy(buf, b, buf_len);
return buf;
}

View file

@ -603,8 +603,7 @@ void save_snapshot_file(char *name)
{
int type;
rb->strncpy(filenamebuf, name, MAXFILENAME-10);
filenamebuf[MAXFILENAME-10] = '\0';
rb->strlcpy(filenamebuf, name, MAXFILENAME-10 + 1);
type = SN_Z80;
if(check_ext(filenamebuf, "z80")) type = SN_Z80;
@ -642,8 +641,7 @@ void load_snapshot_file_type(char *name, int type)
int snsh;
SNFILE snfil;
rb->strncpy(filenamebuf, name, MAXFILENAME-10);
filenamebuf[MAXFILENAME-10] = '\0';
rb->strlcpy(filenamebuf, name, MAXFILENAME-10 + 1);
spcf_find_file_type(filenamebuf, &filetype, &type);
if(type < 0) type = SN_Z80;

View file

@ -111,8 +111,7 @@ void spcf_read_command_line(const void* parameter)
file_type = extensions[ix].type;
file_subtype = extensions[ix].subtype;
rb->strncpy(filenamebuf, parameter, MAXFILENAME - 10);
filenamebuf[MAXFILENAME-10] = '\0';
rb->strlcpy(filenamebuf, parameter, MAXFILENAME - 10 + 1);
if(file_type < 0) file_subtype = -1;
if(!spcf_find_file_type(filenamebuf, &file_type, &file_subtype))
return;

View file

@ -594,8 +594,7 @@ void start_play_file_type(char *name, int seg, int type)
{
int filetype = FT_TAPEFILE;
rb->strncpy(tapename, name, MAXFILENAME-10);
tapename[MAXFILENAME-10] = '\0';
rb->strlcpy(tapename, name, MAXFILENAME-10 + 1);
currseg = seg;
tapetype = type;

View file

@ -510,8 +510,7 @@ static int interpret_tzx_header(byte *hb, struct seginfo *csp)
int blen;
rb->snprintf(seg_desc,DESC_LEN, "Begin Group: ");
blen = (int) rb->strlen(seg_desc);
rb->strncpy(seg_desc+blen, (char *) rbuf, (unsigned) csp->len);
seg_desc[csp->len + blen] = '\0';
rb->strlcpy(seg_desc+blen, (char *) rbuf, (unsigned) csp->len + 1);
}
break;
@ -618,8 +617,7 @@ static int interpret_tzx_header(byte *hb, struct seginfo *csp)
return 0;
}
csp->ptr += csp->len;
rb->strncpy(seg_desc, (char *) rbuf, (unsigned) csp->len);
seg_desc[csp->len] = '\0';
rb->strlcpy(seg_desc, (char *) rbuf, (unsigned) csp->len + 1);
break;
case 0x32: