diff options
Diffstat (limited to 'apps/plugins')
32 files changed, 200 insertions, 92 deletions
diff --git a/apps/plugins/chessbox/chessbox_pgn.c b/apps/plugins/chessbox/chessbox_pgn.c index a8be179fac..cd163a5e1c 100644 --- a/apps/plugins/chessbox/chessbox_pgn.c +++ b/apps/plugins/chessbox/chessbox_pgn.c | |||
@@ -543,7 +543,7 @@ char * get_game_text(int selected_item, void *data, | |||
543 | rb->snprintf(text_buffer, 50,"%s vs. %s (%s)", temp_node->white_player, | 543 | rb->snprintf(text_buffer, 50,"%s vs. %s (%s)", temp_node->white_player, |
544 | temp_node->black_player, temp_node->game_date); | 544 | temp_node->black_player, temp_node->game_date); |
545 | 545 | ||
546 | rb->strncpy(buffer, text_buffer, buffer_len); | 546 | rb->strlcpy(buffer, text_buffer, buffer_len); |
547 | return buffer; | 547 | return buffer; |
548 | } | 548 | } |
549 | 549 | ||
diff --git a/apps/plugins/dict.c b/apps/plugins/dict.c index 0c1ddf33a9..fcc55faef1 100644 --- a/apps/plugins/dict.c +++ b/apps/plugins/dict.c | |||
@@ -283,8 +283,7 @@ enum plugin_status plugin_start(const void* parameter) | |||
283 | while (1) | 283 | while (1) |
284 | { | 284 | { |
285 | /* copy one lcd line */ | 285 | /* copy one lcd line */ |
286 | rb->strncpy(output, ptr, display_columns); | 286 | rb->strlcpy(output, ptr, display_columns + 1); |
287 | output[display_columns] = '\0'; | ||
288 | 287 | ||
289 | /* typecast to kill a warning... */ | 288 | /* typecast to kill a warning... */ |
290 | if((int)rb->strlen(ptr) < display_columns) | 289 | if((int)rb->strlen(ptr) < display_columns) |
diff --git a/apps/plugins/doom/rockmacros.h b/apps/plugins/doom/rockmacros.h index 73cd902277..1ead411b85 100644 --- a/apps/plugins/doom/rockmacros.h +++ b/apps/plugins/doom/rockmacros.h | |||
@@ -59,7 +59,6 @@ int my_close(int id); | |||
59 | #define memcmp(a,b,c) rb->memcmp((a),(b),(c)) | 59 | #define memcmp(a,b,c) rb->memcmp((a),(b),(c)) |
60 | #define memchr(a,b,c) rb->memchr((a),(b),(c)) | 60 | #define memchr(a,b,c) rb->memchr((a),(b),(c)) |
61 | #define strcpy(a,b) rb->strcpy((a),(b)) | 61 | #define strcpy(a,b) rb->strcpy((a),(b)) |
62 | #define strncpy(a,b,c) rb->strncpy((a),(b),(c)) | ||
63 | #define strlen(a) rb->strlen((a)) | 62 | #define strlen(a) rb->strlen((a)) |
64 | #define strcmp(a,b) rb->strcmp((a),(b)) | 63 | #define strcmp(a,b) rb->strcmp((a),(b)) |
65 | #define strncmp(a,b,c) rb->strncmp((a),(b),(c)) | 64 | #define strncmp(a,b,c) rb->strncmp((a),(b),(c)) |
diff --git a/apps/plugins/goban/sgf_output.c b/apps/plugins/goban/sgf_output.c index c1ac052be7..6a52789f7a 100644 --- a/apps/plugins/goban/sgf_output.c +++ b/apps/plugins/goban/sgf_output.c | |||
@@ -130,7 +130,7 @@ output_header_props (void) | |||
130 | { | 130 | { |
131 | char buffer[128]; | 131 | char buffer[128]; |
132 | 132 | ||
133 | rb->strncpy (buffer, "GM[1]FF[4]CA[UTF-8]AP[Rockbox Goban:1.0]ST[2]\n\n", | 133 | rb->strlcpy (buffer, "GM[1]FF[4]CA[UTF-8]AP[Rockbox Goban:1.0]ST[2]\n\n", |
134 | sizeof (buffer)); | 134 | sizeof (buffer)); |
135 | write_file (sgf_fd, buffer, rb->strlen (buffer)); | 135 | write_file (sgf_fd, buffer, rb->strlen (buffer)); |
136 | 136 | ||
diff --git a/apps/plugins/invadrox.c b/apps/plugins/invadrox.c index c7d5696d19..fa7cb81e02 100644 --- a/apps/plugins/invadrox.c +++ b/apps/plugins/invadrox.c | |||
@@ -1511,7 +1511,7 @@ void init_invadrox(void) | |||
1511 | 1511 | ||
1512 | if (highscore_load(HISCOREFILE, &hiscore, 1) < 0) { | 1512 | if (highscore_load(HISCOREFILE, &hiscore, 1) < 0) { |
1513 | /* Init hiscore to 0 */ | 1513 | /* Init hiscore to 0 */ |
1514 | rb->strncpy(hiscore.name, "Invader", sizeof(hiscore.name)); | 1514 | rb->strlcpy(hiscore.name, "Invader", sizeof(hiscore.name)); |
1515 | hiscore.score = 0; | 1515 | hiscore.score = 0; |
1516 | hiscore.level = 1; | 1516 | hiscore.level = 1; |
1517 | } | 1517 | } |
diff --git a/apps/plugins/keybox.c b/apps/plugins/keybox.c index 08d5131eff..73fd138f09 100644 --- a/apps/plugins/keybox.c +++ b/apps/plugins/keybox.c | |||
@@ -330,11 +330,11 @@ static void hash_pw(union hash *out) | |||
330 | static void make_key(void) | 330 | static void make_key(void) |
331 | { | 331 | { |
332 | int i; | 332 | int i; |
333 | char buf[sizeof(master_pw) + sizeof(salt) + 1]; | 333 | char buf[sizeof(master_pw) + sizeof(salt) + 1] = {0}; |
334 | struct md5_s key_md5; | 334 | struct md5_s key_md5; |
335 | size_t len = rb->strlen(master_pw); | 335 | size_t len = rb->strlen(master_pw); |
336 | 336 | ||
337 | rb->strncpy(buf, master_pw, sizeof(buf)); | 337 | rb->strlcpy(buf, master_pw, sizeof(buf)); |
338 | 338 | ||
339 | rb->memcpy(&buf[len], &salt, sizeof(salt)); | 339 | rb->memcpy(&buf[len], &salt, sizeof(salt)); |
340 | 340 | ||
@@ -418,7 +418,7 @@ static int parse_buffer(void) | |||
418 | break; | 418 | break; |
419 | } | 419 | } |
420 | 420 | ||
421 | rb->strncpy(entry->title, start, FIELD_LEN); | 421 | rb->strlcpy(entry->title, start, FIELD_LEN); |
422 | start = end + 1; | 422 | start = end + 1; |
423 | 423 | ||
424 | end = rb->strchr(start, '\0'); /* find eol */ | 424 | end = rb->strchr(start, '\0'); /* find eol */ |
@@ -428,7 +428,7 @@ static int parse_buffer(void) | |||
428 | break; | 428 | break; |
429 | } | 429 | } |
430 | 430 | ||
431 | rb->strncpy(entry->name, start, FIELD_LEN); | 431 | rb->strlcpy(entry->name, start, FIELD_LEN); |
432 | start = end + 1; | 432 | start = end + 1; |
433 | 433 | ||
434 | end = rb->strchr(start, '\0'); /* find eol */ | 434 | end = rb->strchr(start, '\0'); /* find eol */ |
@@ -437,7 +437,7 @@ static int parse_buffer(void) | |||
437 | { | 437 | { |
438 | break; | 438 | break; |
439 | } | 439 | } |
440 | rb->strncpy(entry->password, start, FIELD_LEN); | 440 | rb->strlcpy(entry->password, start, FIELD_LEN); |
441 | start = end + 1; | 441 | start = end + 1; |
442 | entry->used = true; | 442 | entry->used = true; |
443 | if (i + 1 < MAX_ENTRIES - 1) | 443 | if (i + 1 < MAX_ENTRIES - 1) |
@@ -469,13 +469,13 @@ static void write_output(int fd) | |||
469 | for (i = 0; i < pw_list.num_entries; i++) | 469 | for (i = 0; i < pw_list.num_entries; i++) |
470 | { | 470 | { |
471 | len = rb->strlen(entry->title); | 471 | len = rb->strlen(entry->title); |
472 | rb->strncpy(p, entry->title, len+1); | 472 | rb->strlcpy(p, entry->title, len+1); |
473 | p += len+1; | 473 | p += len+1; |
474 | len = rb->strlen(entry->name); | 474 | len = rb->strlen(entry->name); |
475 | rb->strncpy(p, entry->name, len+1); | 475 | rb->strlcpy(p, entry->name, len+1); |
476 | p += len+1; | 476 | p += len+1; |
477 | len = rb->strlen(entry->password); | 477 | len = rb->strlen(entry->password); |
478 | rb->strncpy(p, entry->password, len+1); | 478 | rb->strlcpy(p, entry->password, len+1); |
479 | p += len+1; | 479 | p += len+1; |
480 | if (entry->next) | 480 | if (entry->next) |
481 | entry = entry->next; | 481 | entry = entry->next; |
@@ -517,7 +517,7 @@ static int enter_pw(char *pw_buf, size_t buflen, bool new_pw) | |||
517 | } | 517 | } |
518 | else | 518 | else |
519 | { | 519 | { |
520 | rb->strncpy(pw_buf, buf[0], buflen); | 520 | rb->strlcpy(pw_buf, buf[0], buflen); |
521 | hash_pw(&pwhash); | 521 | hash_pw(&pwhash); |
522 | return 0; | 522 | return 0; |
523 | } | 523 | } |
diff --git a/apps/plugins/lib/SOURCES b/apps/plugins/lib/SOURCES index 02adb7089c..72538fc2a0 100644 --- a/apps/plugins/lib/SOURCES +++ b/apps/plugins/lib/SOURCES | |||
@@ -6,6 +6,7 @@ playback_control.c | |||
6 | rgb_hsv.c | 6 | rgb_hsv.c |
7 | buflib.c | 7 | buflib.c |
8 | display_text.c | 8 | display_text.c |
9 | strncpy.c | ||
9 | #if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) | 10 | #if defined(HAVE_LCD_BITMAP) && (LCD_DEPTH < 4) |
10 | grey_core.c | 11 | grey_core.c |
11 | grey_draw.c | 12 | grey_draw.c |
diff --git a/apps/plugins/lib/configfile.c b/apps/plugins/lib/configfile.c index 5e1e776f39..21b66a317b 100644 --- a/apps/plugins/lib/configfile.c +++ b/apps/plugins/lib/configfile.c | |||
@@ -139,7 +139,7 @@ int configfile_load(const char *filename, struct configdata *cfg, | |||
139 | break; | 139 | break; |
140 | 140 | ||
141 | case TYPE_STRING: | 141 | case TYPE_STRING: |
142 | rb->strncpy(cfg[i].string, val, cfg[i].max); | 142 | rb->strlcpy(cfg[i].string, val, cfg[i].max); |
143 | break; | 143 | break; |
144 | } | 144 | } |
145 | } | 145 | } |
diff --git a/apps/plugins/lib/highscore.c b/apps/plugins/lib/highscore.c index e8e1c883b0..15ebb05f4d 100644 --- a/apps/plugins/lib/highscore.c +++ b/apps/plugins/lib/highscore.c | |||
@@ -72,7 +72,7 @@ int highscore_load(char *filename, struct highscore *scores, int num_scores) | |||
72 | 72 | ||
73 | scores[i].score = rb->atoi(score); | 73 | scores[i].score = rb->atoi(score); |
74 | scores[i].level = rb->atoi(level); | 74 | scores[i].level = rb->atoi(level); |
75 | rb->strncpy(scores[i].name, name, sizeof(scores[i].name)-1); | 75 | rb->strlcpy(scores[i].name, name, sizeof(scores[i].name)); |
76 | i++; | 76 | i++; |
77 | } | 77 | } |
78 | rb->close(fd); | 78 | rb->close(fd); |
@@ -100,8 +100,7 @@ int highscore_update(int score, int level, const char *name, | |||
100 | entry = scores + pos; | 100 | entry = scores + pos; |
101 | entry->score = score; | 101 | entry->score = score; |
102 | entry->level = level; | 102 | entry->level = level; |
103 | rb->strncpy(entry->name, name, sizeof(entry->name)); | 103 | rb->strlcpy(entry->name, name, sizeof(entry->name)); |
104 | entry->name[sizeof(entry->name)-1] = '\0'; | ||
105 | 104 | ||
106 | return pos; | 105 | return pos; |
107 | } | 106 | } |
diff --git a/apps/plugins/lib/strncpy.c b/apps/plugins/lib/strncpy.c new file mode 100644 index 0000000000..7c1973ba66 --- /dev/null +++ b/apps/plugins/lib/strncpy.c | |||
@@ -0,0 +1,125 @@ | |||
1 | /* | ||
2 | FUNCTION | ||
3 | <<strncpy>>---counted copy string | ||
4 | |||
5 | INDEX | ||
6 | strncpy | ||
7 | |||
8 | ANSI_SYNOPSIS | ||
9 | #include <string.h> | ||
10 | char *strncpy(char *<[dst]>, const char *<[src]>, size_t <[length]>); | ||
11 | |||
12 | TRAD_SYNOPSIS | ||
13 | #include <string.h> | ||
14 | char *strncpy(<[dst]>, <[src]>, <[length]>) | ||
15 | char *<[dst]>; | ||
16 | char *<[src]>; | ||
17 | size_t <[length]>; | ||
18 | |||
19 | DESCRIPTION | ||
20 | <<strncpy>> copies not more than <[length]> characters from the | ||
21 | the string pointed to by <[src]> (including the terminating | ||
22 | null character) to the array pointed to by <[dst]>. If the | ||
23 | string pointed to by <[src]> is shorter than <[length]> | ||
24 | characters, null characters are appended to the destination | ||
25 | array until a total of <[length]> characters have been | ||
26 | written. | ||
27 | |||
28 | RETURNS | ||
29 | This function returns the initial value of <[dst]>. | ||
30 | |||
31 | PORTABILITY | ||
32 | <<strncpy>> is ANSI C. | ||
33 | |||
34 | <<strncpy>> requires no supporting OS subroutines. | ||
35 | |||
36 | QUICKREF | ||
37 | strncpy ansi pure | ||
38 | */ | ||
39 | |||
40 | #include <string.h> | ||
41 | #include <limits.h> | ||
42 | |||
43 | /*SUPPRESS 560*/ | ||
44 | /*SUPPRESS 530*/ | ||
45 | |||
46 | /* Nonzero if either X or Y is not aligned on a "long" boundary. */ | ||
47 | #define UNALIGNED(X, Y) \ | ||
48 | (((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1))) | ||
49 | |||
50 | #if LONG_MAX == 2147483647L | ||
51 | #define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080) | ||
52 | #else | ||
53 | #if LONG_MAX == 9223372036854775807L | ||
54 | /* Nonzero if X (a long int) contains a NULL byte. */ | ||
55 | #define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080) | ||
56 | #else | ||
57 | #error long int is not a 32bit or 64bit type. | ||
58 | #endif | ||
59 | #endif | ||
60 | |||
61 | #ifndef DETECTNULL | ||
62 | #error long int is not a 32bit or 64bit byte | ||
63 | #endif | ||
64 | |||
65 | #define TOO_SMALL(LEN) ((LEN) < sizeof (long)) | ||
66 | |||
67 | char * | ||
68 | _DEFUN (strncpy, (dst0, src0), | ||
69 | char *dst0 _AND | ||
70 | _CONST char *src0 _AND | ||
71 | size_t count) | ||
72 | { | ||
73 | #if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) | ||
74 | char *dscan; | ||
75 | _CONST char *sscan; | ||
76 | |||
77 | dscan = dst0; | ||
78 | sscan = src0; | ||
79 | while (count > 0) | ||
80 | { | ||
81 | --count; | ||
82 | if ((*dscan++ = *sscan++) == '\0') | ||
83 | break; | ||
84 | } | ||
85 | while (count-- > 0) | ||
86 | *dscan++ = '\0'; | ||
87 | |||
88 | return dst0; | ||
89 | #else | ||
90 | char *dst = dst0; | ||
91 | _CONST char *src = src0; | ||
92 | long *aligned_dst; | ||
93 | _CONST long *aligned_src; | ||
94 | |||
95 | /* If SRC and DEST is aligned and count large enough, then copy words. */ | ||
96 | if (!UNALIGNED (src, dst) && !TOO_SMALL (count)) | ||
97 | { | ||
98 | aligned_dst = (long*)dst; | ||
99 | aligned_src = (long*)src; | ||
100 | |||
101 | /* SRC and DEST are both "long int" aligned, try to do "long int" | ||
102 | sized copies. */ | ||
103 | while (count >= sizeof (long int) && !DETECTNULL(*aligned_src)) | ||
104 | { | ||
105 | count -= sizeof (long int); | ||
106 | *aligned_dst++ = *aligned_src++; | ||
107 | } | ||
108 | |||
109 | dst = (char*)aligned_dst; | ||
110 | src = (char*)aligned_src; | ||
111 | } | ||
112 | |||
113 | while (count > 0) | ||
114 | { | ||
115 | --count; | ||
116 | if ((*dst++ = *src++) == '\0') | ||
117 | break; | ||
118 | } | ||
119 | |||
120 | while (count-- > 0) | ||
121 | *dst++ = '\0'; | ||
122 | |||
123 | return dst0; | ||
124 | #endif /* not PREFER_SIZE_OVER_SPEED */ | ||
125 | } | ||
diff --git a/apps/plugins/lib/wrappers.h b/apps/plugins/lib/wrappers.h index 5eb45d02c8..b6fbd51a39 100644 --- a/apps/plugins/lib/wrappers.h +++ b/apps/plugins/lib/wrappers.h | |||
@@ -51,7 +51,7 @@ | |||
51 | #define strcpy rb->strcpy | 51 | #define strcpy rb->strcpy |
52 | #define strip_extension rb->strip_extension | 52 | #define strip_extension rb->strip_extension |
53 | #define strlen rb->strlen | 53 | #define strlen rb->strlen |
54 | #define strncpy rb->strncpy | 54 | #define strlcpy rb->strlcpy |
55 | #define strrchr rb->strrchr | 55 | #define strrchr rb->strrchr |
56 | 56 | ||
57 | #endif | 57 | #endif |
diff --git a/apps/plugins/lua/lobject.c b/apps/plugins/lua/lobject.c index 62ad8e9359..7f73114303 100644 --- a/apps/plugins/lua/lobject.c +++ b/apps/plugins/lua/lobject.c | |||
@@ -181,8 +181,7 @@ const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) { | |||
181 | 181 | ||
182 | void luaO_chunkid (char *out, const char *source, size_t bufflen) { | 182 | void luaO_chunkid (char *out, const char *source, size_t bufflen) { |
183 | if (*source == '=') { | 183 | if (*source == '=') { |
184 | strncpy(out, source+1, bufflen); /* remove first char */ | 184 | strlcpy(out, source+1, bufflen); /* remove first char */ |
185 | out[bufflen-1] = '\0'; /* ensures null termination */ | ||
186 | } | 185 | } |
187 | else { /* out = "source", or "...source" */ | 186 | else { /* out = "source", or "...source" */ |
188 | if (*source == '@') { | 187 | if (*source == '@') { |
diff --git a/apps/plugins/lua/lstrlib.c b/apps/plugins/lua/lstrlib.c index 3d6103692f..4d58280ba8 100644 --- a/apps/plugins/lua/lstrlib.c +++ b/apps/plugins/lua/lstrlib.c | |||
@@ -737,9 +737,7 @@ static const char *scanformat (lua_State *L, const char *strfrmt, char *form) { | |||
737 | if (isdigit(uchar(*p))) | 737 | if (isdigit(uchar(*p))) |
738 | luaL_error(L, "invalid format (width or precision too long)"); | 738 | luaL_error(L, "invalid format (width or precision too long)"); |
739 | *(form++) = '%'; | 739 | *(form++) = '%'; |
740 | strncpy(form, strfrmt, p - strfrmt + 1); | 740 | strlcpy(form, strfrmt, p - strfrmt + 1); |
741 | form += p - strfrmt + 1; | ||
742 | *form = '\0'; | ||
743 | return p; | 741 | return p; |
744 | } | 742 | } |
745 | 743 | ||
diff --git a/apps/plugins/lua/rockconf.h b/apps/plugins/lua/rockconf.h index 639f336b5b..02bd0e76d1 100644 --- a/apps/plugins/lua/rockconf.h +++ b/apps/plugins/lua/rockconf.h | |||
@@ -63,7 +63,7 @@ long pow(long x, long y); | |||
63 | #define strchr rb->strchr | 63 | #define strchr rb->strchr |
64 | #define strcmp rb->strcmp | 64 | #define strcmp rb->strcmp |
65 | #define strcpy rb->strcpy | 65 | #define strcpy rb->strcpy |
66 | #define strncpy rb->strncpy | 66 | #define strlcpy rb->strlcpy |
67 | #define strlen rb->strlen | 67 | #define strlen rb->strlen |
68 | 68 | ||
69 | #endif /* _ROCKCONF_H_ */ | 69 | #endif /* _ROCKCONF_H_ */ |
diff --git a/apps/plugins/mp3_encoder.c b/apps/plugins/mp3_encoder.c index 6849daf2f3..9da0d6925f 100644 --- a/apps/plugins/mp3_encoder.c +++ b/apps/plugins/mp3_encoder.c | |||
@@ -2399,9 +2399,8 @@ char mp3_name[80]; | |||
2399 | 2399 | ||
2400 | void get_mp3_filename(const char *wav_name) | 2400 | void get_mp3_filename(const char *wav_name) |
2401 | { | 2401 | { |
2402 | int slen = rb->strlen(wav_name); | 2402 | rb->strlcpy(mp3_name, wav_name, sizeof(mp3_name)); |
2403 | rb->strncpy(mp3_name, wav_name, 79); | 2403 | rb->strlcpy(mp3_name + rb->strlen(mp3_name) - 4, ".mp3", 5); |
2404 | rb->strncpy(mp3_name + slen - 4, ".mp3", 5); | ||
2405 | } | 2404 | } |
2406 | 2405 | ||
2407 | #if CONFIG_KEYPAD == IRIVER_H100_PAD || CONFIG_KEYPAD == IRIVER_H300_PAD | 2406 | #if CONFIG_KEYPAD == IRIVER_H100_PAD || CONFIG_KEYPAD == IRIVER_H300_PAD |
diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c index 7ec1157615..a9b66fc22f 100644 --- a/apps/plugins/mpegplayer/mpeg_settings.c +++ b/apps/plugins/mpegplayer/mpeg_settings.c | |||
@@ -344,7 +344,7 @@ static void backlight_brightness_formatter(char *buf, size_t length, | |||
344 | int value, const char *input) | 344 | int value, const char *input) |
345 | { | 345 | { |
346 | if (value < 0) | 346 | if (value < 0) |
347 | rb->strncpy(buf, BACKLIGHT_OPTION_DEFAULT, length); | 347 | rb->strlcpy(buf, BACKLIGHT_OPTION_DEFAULT, length); |
348 | else | 348 | else |
349 | rb->snprintf(buf, length, "%d", value + MIN_BRIGHTNESS_SETTING); | 349 | rb->snprintf(buf, length, "%d", value + MIN_BRIGHTNESS_SETTING); |
350 | 350 | ||
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index 496e9c94df..34d1db5d5c 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c | |||
@@ -913,7 +913,7 @@ bool get_albumart_for_index_from_db(const int slide_index, char *buf, | |||
913 | { | 913 | { |
914 | if ( slide_index == -1 ) | 914 | if ( slide_index == -1 ) |
915 | { | 915 | { |
916 | rb->strncpy( buf, EMPTY_SLIDE, buflen ); | 916 | rb->strlcpy( buf, EMPTY_SLIDE, buflen ); |
917 | } | 917 | } |
918 | 918 | ||
919 | if (!rb->tagcache_search(&tcs, tag_filename)) | 919 | if (!rb->tagcache_search(&tcs, tag_filename)) |
@@ -930,8 +930,7 @@ bool get_albumart_for_index_from_db(const int slide_index, char *buf, | |||
930 | #ifdef HAVE_TC_RAMCACHE | 930 | #ifdef HAVE_TC_RAMCACHE |
931 | if (rb->tagcache_fill_tags(&id3, tcs.result)) | 931 | if (rb->tagcache_fill_tags(&id3, tcs.result)) |
932 | { | 932 | { |
933 | rb->strncpy(id3.path, tcs.result, sizeof(id3.path)); | 933 | rb->strlcpy(id3.path, tcs.result, sizeof(id3.path)); |
934 | id3.path[sizeof(id3.path) - 1] = 0; | ||
935 | } | 934 | } |
936 | else | 935 | else |
937 | #endif | 936 | #endif |
diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c index 18beec2da6..b57150b817 100644 --- a/apps/plugins/properties.c +++ b/apps/plugins/properties.c | |||
@@ -70,8 +70,7 @@ static bool file_properties(char* selected_file) | |||
70 | 70 | ||
71 | char* ptr = rb->strrchr(selected_file, '/') + 1; | 71 | char* ptr = rb->strrchr(selected_file, '/') + 1; |
72 | int dirlen = (ptr - selected_file); | 72 | int dirlen = (ptr - selected_file); |
73 | rb->strncpy(tstr, selected_file, dirlen); | 73 | rb->strlcpy(tstr, selected_file, dirlen + 1); |
74 | tstr[dirlen] = 0; | ||
75 | 74 | ||
76 | dir = rb->opendir(tstr); | 75 | dir = rb->opendir(tstr); |
77 | if (dir) | 76 | if (dir) |
@@ -212,7 +211,7 @@ static bool dir_properties(char* selected_file) | |||
212 | { | 211 | { |
213 | DPS dps; | 212 | DPS dps; |
214 | char tstr[64]; | 213 | char tstr[64]; |
215 | rb->strncpy(dps.dirname, selected_file, MAX_PATH); | 214 | rb->strlcpy(dps.dirname, selected_file, MAX_PATH); |
216 | dps.len = MAX_PATH; | 215 | dps.len = MAX_PATH; |
217 | dps.dc = 0; | 216 | dps.dc = 0; |
218 | dps.fc = 0; | 217 | dps.fc = 0; |
@@ -220,7 +219,7 @@ static bool dir_properties(char* selected_file) | |||
220 | if(false == _dir_properties(&dps)) | 219 | if(false == _dir_properties(&dps)) |
221 | return false; | 220 | return false; |
222 | 221 | ||
223 | rb->strncpy(str_dirname, selected_file, MAX_PATH); | 222 | rb->strlcpy(str_dirname, selected_file, MAX_PATH); |
224 | rb->snprintf(str_dircount, sizeof str_dircount, "Subdirs: %d", dps.dc); | 223 | rb->snprintf(str_dircount, sizeof str_dircount, "Subdirs: %d", dps.dc); |
225 | rb->snprintf(str_filecount, sizeof str_filecount, "Files: %d", dps.fc); | 224 | rb->snprintf(str_filecount, sizeof str_filecount, "Files: %d", dps.fc); |
226 | rb->snprintf(str_size, sizeof str_size, "Size: %s", | 225 | 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) | |||
236 | switch(selected_item) | 235 | switch(selected_item) |
237 | { | 236 | { |
238 | case 0: | 237 | case 0: |
239 | rb->strncpy(buffer, str_dirname, buffer_len); | 238 | rb->strlcpy(buffer, str_dirname, buffer_len); |
240 | break; | 239 | break; |
241 | case 1: | 240 | case 1: |
242 | rb->strncpy(buffer, its_a_dir ? str_dircount : str_filename, | 241 | rb->strlcpy(buffer, its_a_dir ? str_dircount : str_filename, |
243 | buffer_len); | 242 | buffer_len); |
244 | break; | 243 | break; |
245 | case 2: | 244 | case 2: |
246 | rb->strncpy(buffer, its_a_dir ? str_filecount : str_size, buffer_len); | 245 | rb->strlcpy(buffer, its_a_dir ? str_filecount : str_size, buffer_len); |
247 | break; | 246 | break; |
248 | case 3: | 247 | case 3: |
249 | rb->strncpy(buffer, its_a_dir ? str_size : str_date, buffer_len); | 248 | rb->strlcpy(buffer, its_a_dir ? str_size : str_date, buffer_len); |
250 | break; | 249 | break; |
251 | case 4: | 250 | case 4: |
252 | rb->strncpy(buffer, its_a_dir ? "" : str_time, buffer_len); | 251 | rb->strlcpy(buffer, its_a_dir ? "" : str_time, buffer_len); |
253 | break; | 252 | break; |
254 | case 5: | 253 | case 5: |
255 | rb->strncpy(buffer, its_a_dir ? "" : str_artist, buffer_len); | 254 | rb->strlcpy(buffer, its_a_dir ? "" : str_artist, buffer_len); |
256 | break; | 255 | break; |
257 | case 6: | 256 | case 6: |
258 | rb->strncpy(buffer, its_a_dir ? "" : str_title, buffer_len); | 257 | rb->strlcpy(buffer, its_a_dir ? "" : str_title, buffer_len); |
259 | break; | 258 | break; |
260 | case 7: | 259 | case 7: |
261 | rb->strncpy(buffer, its_a_dir ? "" : str_album, buffer_len); | 260 | rb->strlcpy(buffer, its_a_dir ? "" : str_album, buffer_len); |
262 | break; | 261 | break; |
263 | case 8: | 262 | case 8: |
264 | rb->strncpy(buffer, its_a_dir ? "" : str_duration, buffer_len); | 263 | rb->strlcpy(buffer, its_a_dir ? "" : str_duration, buffer_len); |
265 | break; | 264 | break; |
266 | default: | 265 | default: |
267 | rb->strncpy(buffer, "ERROR", buffer_len); | 266 | rb->strlcpy(buffer, "ERROR", buffer_len); |
268 | break; | 267 | break; |
269 | } | 268 | } |
270 | return buffer; | 269 | return buffer; |
@@ -284,8 +283,7 @@ enum plugin_status plugin_start(const void* parameter) | |||
284 | struct dirent* entry; | 283 | struct dirent* entry; |
285 | char* ptr = rb->strrchr(file, '/') + 1; | 284 | char* ptr = rb->strrchr(file, '/') + 1; |
286 | int dirlen = (ptr - file); | 285 | int dirlen = (ptr - file); |
287 | rb->strncpy(str_dirname, file, dirlen); | 286 | rb->strlcpy(str_dirname, file, dirlen + 1); |
288 | str_dirname[dirlen] = 0; | ||
289 | 287 | ||
290 | dir = rb->opendir(str_dirname); | 288 | dir = rb->opendir(str_dirname); |
291 | if (dir) | 289 | if (dir) |
diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c index 28546a340c..c9ffaed319 100644 --- a/apps/plugins/random_folder_advance_config.c +++ b/apps/plugins/random_folder_advance_config.c | |||
@@ -86,7 +86,7 @@ void traversedir(char* location, char* name) | |||
86 | /* check if path is removed directory, if so dont enter it */ | 86 | /* check if path is removed directory, if so dont enter it */ |
87 | rb->snprintf(path, MAX_PATH, "%s/%s", fullpath, entry->d_name); | 87 | rb->snprintf(path, MAX_PATH, "%s/%s", fullpath, entry->d_name); |
88 | while(path[0] == '/') | 88 | while(path[0] == '/') |
89 | rb->strncpy(path, path + 1, rb->strlen(path)); | 89 | rb->strlcpy(path, path + 1, sizeof(path)); |
90 | for(i = 0; i < num_replaced_dirs; i++) | 90 | for(i = 0; i < num_replaced_dirs; i++) |
91 | { | 91 | { |
92 | if(!rb->strcmp(path, removed_dirs[i])) | 92 | if(!rb->strcmp(path, removed_dirs[i])) |
@@ -141,8 +141,8 @@ bool custom_dir(void) | |||
141 | (num_replaced_dirs < MAX_REMOVED_DIRS)) | 141 | (num_replaced_dirs < MAX_REMOVED_DIRS)) |
142 | { | 142 | { |
143 | num_replaced_dirs ++; | 143 | num_replaced_dirs ++; |
144 | rb->strncpy(removed_dirs[num_replaced_dirs - 1], line + 2, | 144 | rb->strlcpy(removed_dirs[num_replaced_dirs - 1], line + 2, |
145 | rb->strlen(line)); | 145 | sizeof(line)); |
146 | } | 146 | } |
147 | } | 147 | } |
148 | rb->close(fd2); | 148 | rb->close(fd2); |
@@ -157,7 +157,7 @@ bool custom_dir(void) | |||
157 | { | 157 | { |
158 | /* remove preceeding '/'s from the line */ | 158 | /* remove preceeding '/'s from the line */ |
159 | while(line[0] == '/') | 159 | while(line[0] == '/') |
160 | rb->strncpy(line, line + 1, rb->strlen(line)); | 160 | rb->strlcpy(line, line + 1, sizeof(line)); |
161 | 161 | ||
162 | rb->snprintf(formatted_line, MAX_PATH, "/%s", line); | 162 | rb->snprintf(formatted_line, MAX_PATH, "/%s", line); |
163 | 163 | ||
@@ -237,7 +237,7 @@ void generate(void) | |||
237 | char *list_get_name_cb(int selected_item, void* data, char* buf, size_t buf_len) | 237 | char *list_get_name_cb(int selected_item, void* data, char* buf, size_t buf_len) |
238 | { | 238 | { |
239 | (void)data; | 239 | (void)data; |
240 | rb->strncpy(buf, list->folder[selected_item], buf_len); | 240 | rb->strlcpy(buf, list->folder[selected_item], buf_len); |
241 | return buf; | 241 | return buf; |
242 | } | 242 | } |
243 | 243 | ||
diff --git a/apps/plugins/rockboy/menu.c b/apps/plugins/rockboy/menu.c index 9821ce9ba2..76de224294 100644 --- a/apps/plugins/rockboy/menu.c +++ b/apps/plugins/rockboy/menu.c | |||
@@ -162,11 +162,10 @@ static void munge_name(char *buf, const size_t bufsiz) { | |||
162 | * checksum or something like that? | 162 | * checksum or something like that? |
163 | */ | 163 | */ |
164 | static void build_slot_path(char *buf, size_t bufsiz, size_t slot_id) { | 164 | static void build_slot_path(char *buf, size_t bufsiz, size_t slot_id) { |
165 | char name_buf[40]; | 165 | char name_buf[17]; |
166 | 166 | ||
167 | /* munge state file name */ | 167 | /* munge state file name */ |
168 | strncpy(name_buf, rom.name, 40); | 168 | strlcpy(name_buf, rom.name, sizeof(name_buf)); |
169 | name_buf[16] = '\0'; | ||
170 | munge_name(name_buf, strlen(name_buf)); | 169 | munge_name(name_buf, strlen(name_buf)); |
171 | 170 | ||
172 | /* glom the whole mess together */ | 171 | /* glom the whole mess together */ |
@@ -211,7 +210,7 @@ static bool do_file(char *path, char *desc, bool is_load) { | |||
211 | /* build description buffer */ | 210 | /* build description buffer */ |
212 | memset(desc_buf, 0, 20); | 211 | memset(desc_buf, 0, 20); |
213 | if (desc) | 212 | if (desc) |
214 | strncpy(desc_buf, desc, 20); | 213 | strlcpy(desc_buf, desc, 20); |
215 | 214 | ||
216 | /* save state */ | 215 | /* save state */ |
217 | write(fd, desc_buf, 20); | 216 | write(fd, desc_buf, 20); |
@@ -241,8 +240,7 @@ static bool do_slot(size_t slot_id, bool is_load) { | |||
241 | if (!is_load) | 240 | if (!is_load) |
242 | if (rb->kbd_input(desc_buf, 20) || !strlen(desc_buf)) | 241 | if (rb->kbd_input(desc_buf, 20) || !strlen(desc_buf)) |
243 | { | 242 | { |
244 | memset(desc_buf, 0, 20); | 243 | strlcpy(desc_buf, "Untitled", 20); |
245 | strncpy(desc_buf, "Untitled", 20); | ||
246 | } | 244 | } |
247 | 245 | ||
248 | /* load/save file */ | 246 | /* load/save file */ |
diff --git a/apps/plugins/rockboy/rockmacros.h b/apps/plugins/rockboy/rockmacros.h index 414b889003..0fd13f6ef9 100644 --- a/apps/plugins/rockboy/rockmacros.h +++ b/apps/plugins/rockboy/rockmacros.h | |||
@@ -67,7 +67,7 @@ void dynamic_recompile (struct dynarec_block *newblock); | |||
67 | #define strcat(a,b) rb->strcat((a),(b)) | 67 | #define strcat(a,b) rb->strcat((a),(b)) |
68 | #define memset(a,b,c) rb->memset((a),(b),(c)) | 68 | #define memset(a,b,c) rb->memset((a),(b),(c)) |
69 | #define strcpy(a,b) rb->strcpy((a),(b)) | 69 | #define strcpy(a,b) rb->strcpy((a),(b)) |
70 | #define strncpy(a,b,c) rb->strncpy((a),(b),(c)) | 70 | #define strlcpy(a,b,c) rb->strlcpy((a),(b),(c)) |
71 | #define strlen(a) rb->strlen((a)) | 71 | #define strlen(a) rb->strlen((a)) |
72 | #define strcmp(a,b) rb->strcmp((a),(b)) | 72 | #define strcmp(a,b) rb->strcmp((a),(b)) |
73 | #define strchr(a,b) rb->strchr((a),(b)) | 73 | #define strchr(a,b) rb->strchr((a),(b)) |
diff --git a/apps/plugins/rockpaint.c b/apps/plugins/rockpaint.c index 20bebdd11f..5de6c14a6b 100644 --- a/apps/plugins/rockpaint.c +++ b/apps/plugins/rockpaint.c | |||
@@ -686,7 +686,7 @@ static bool browse( char *dst, int dst_size, const char *start ) | |||
686 | if( selected < 0 || selected >= item_count ) | 686 | if( selected < 0 || selected >= item_count ) |
687 | break; | 687 | break; |
688 | struct entry* e = &dc[indexes[selected]]; | 688 | struct entry* e = &dc[indexes[selected]]; |
689 | rb->strncpy( bbuf_s, e->name, sizeof( bbuf_s ) ); | 689 | rb->strlcpy( bbuf_s, e->name, sizeof( bbuf_s ) ); |
690 | if( !( e->attr & ATTR_DIRECTORY ) ) | 690 | if( !( e->attr & ATTR_DIRECTORY ) ) |
691 | { | 691 | { |
692 | *tree = backup; | 692 | *tree = backup; |
diff --git a/apps/plugins/shortcuts/shortcuts_common.c b/apps/plugins/shortcuts/shortcuts_common.c index a06abd3f7f..1a781b23eb 100644 --- a/apps/plugins/shortcuts/shortcuts_common.c +++ b/apps/plugins/shortcuts/shortcuts_common.c | |||
@@ -213,8 +213,7 @@ bool parse_entry_content(char *line, sc_entry_t *entry, int last_segm) | |||
213 | DEBUGF("Bad entry: pathlen=%d, displen=%d\n", path_len, disp_len); | 213 | DEBUGF("Bad entry: pathlen=%d, displen=%d\n", path_len, disp_len); |
214 | return false; | 214 | return false; |
215 | } | 215 | } |
216 | rb->strncpy(entry->path, path, path_len); | 216 | rb->strlcpy(entry->path, path, path_len + 1); |
217 | entry->path[path_len] = '\0'; | ||
218 | rb->strcpy(entry->disp, disp); /* Safe since we've checked the length */ | 217 | rb->strcpy(entry->disp, disp); /* Safe since we've checked the length */ |
219 | entry->explicit_disp = expl; | 218 | entry->explicit_disp = expl; |
220 | return true; | 219 | return true; |
@@ -295,15 +294,14 @@ bool parse_name_value(char *line, char *name, int namesize, | |||
295 | /* Too long name */ | 294 | /* Too long name */ |
296 | return false; | 295 | return false; |
297 | } | 296 | } |
298 | rb->strncpy(name, line, name_len); | 297 | rb->strlcpy(name, line, name_len + 1); |
299 | name[name_len] = '\0'; | ||
300 | 298 | ||
301 | val_len = rb->strlen(line) - name_len - NAME_VALUE_SEPARATOR_LEN; | 299 | val_len = rb->strlen(line) - name_len - NAME_VALUE_SEPARATOR_LEN; |
302 | if (val_len >= valuesize) { | 300 | if (val_len >= valuesize) { |
303 | /* Too long value */ | 301 | /* Too long value */ |
304 | return false; | 302 | return false; |
305 | } | 303 | } |
306 | rb->strncpy(value, sep+NAME_VALUE_SEPARATOR_LEN, val_len+1); | 304 | rb->strlcpy(value, sep+NAME_VALUE_SEPARATOR_LEN, val_len+1); |
307 | return true; | 305 | return true; |
308 | } | 306 | } |
309 | 307 | ||
diff --git a/apps/plugins/sokoban.c b/apps/plugins/sokoban.c index 8672249bdc..bfd400b408 100644 --- a/apps/plugins/sokoban.c +++ b/apps/plugins/sokoban.c | |||
@@ -689,7 +689,8 @@ static bool redo(void) | |||
689 | 689 | ||
690 | static void init_boards(void) | 690 | static void init_boards(void) |
691 | { | 691 | { |
692 | rb->strncpy(buffered_boards.filename, SOKOBAN_LEVELS_FILE, MAX_PATH); | 692 | rb->strlcpy(buffered_boards.filename, SOKOBAN_LEVELS_FILE, |
693 | sizeof(buffered_boards.filename)); | ||
693 | 694 | ||
694 | current_info.level.index = 0; | 695 | current_info.level.index = 0; |
695 | current_info.player.row = 0; | 696 | current_info.player.row = 0; |
@@ -1026,8 +1027,8 @@ static bool save(char *filename, bool solution) | |||
1026 | 1027 | ||
1027 | /* Create dir if it doesn't exist */ | 1028 | /* Create dir if it doesn't exist */ |
1028 | if ((loc = rb->strrchr(filename, '/')) != NULL) { | 1029 | if ((loc = rb->strrchr(filename, '/')) != NULL) { |
1029 | rb->strncpy(dirname, filename, loc - filename); | 1030 | rb->strlcpy(dirname, filename, loc - filename + 1); |
1030 | dirname[loc - filename] = '\0'; | 1031 | |
1031 | if(!(dir = rb->opendir(dirname))) | 1032 | if(!(dir = rb->opendir(dirname))) |
1032 | rb->mkdir(dirname); | 1033 | rb->mkdir(dirname); |
1033 | else | 1034 | else |
@@ -1082,7 +1083,9 @@ static bool load(char *filename, bool silent) | |||
1082 | if (rb->strncmp(buf, "Sokoban", 7) != 0) { | 1083 | if (rb->strncmp(buf, "Sokoban", 7) != 0) { |
1083 | rb->close(fd); | 1084 | rb->close(fd); |
1084 | 1085 | ||
1085 | rb->strncpy(buffered_boards.filename, filename, MAX_PATH); | 1086 | rb->strlcpy(buffered_boards.filename, filename, |
1087 | sizeof(buffered_boards.filename)); | ||
1088 | |||
1086 | if (!read_levels(true)) | 1089 | if (!read_levels(true)) |
1087 | return false; | 1090 | return false; |
1088 | 1091 | ||
diff --git a/apps/plugins/splitedit.c b/apps/plugins/splitedit.c index 9f62b7a346..a169a61a47 100644 --- a/apps/plugins/splitedit.c +++ b/apps/plugins/splitedit.c | |||
@@ -780,11 +780,11 @@ static void save_editor(struct mp3entry *mp3, int splittime) | |||
780 | bool part2_save = true; | 780 | bool part2_save = true; |
781 | 781 | ||
782 | /* file name for left part */ | 782 | /* file name for left part */ |
783 | rb->strncpy(part1_name, mp3->path, MAX_PATH); | 783 | rb->strlcpy(part1_name, mp3->path, MAX_PATH); |
784 | generateFileName(part1_name, 1); | 784 | generateFileName(part1_name, 1); |
785 | 785 | ||
786 | /* file name for right part */ | 786 | /* file name for right part */ |
787 | rb->strncpy(part2_name, mp3->path, MAX_PATH); | 787 | rb->strlcpy(part2_name, mp3->path, MAX_PATH); |
788 | generateFileName(part2_name, 2); | 788 | generateFileName(part2_name, 2); |
789 | 789 | ||
790 | while (!exit_request) | 790 | while (!exit_request) |
diff --git a/apps/plugins/sudoku/sudoku.c b/apps/plugins/sudoku/sudoku.c index f8a438592d..77f6ca7899 100644 --- a/apps/plugins/sudoku/sudoku.c +++ b/apps/plugins/sudoku/sudoku.c | |||
@@ -603,7 +603,7 @@ void default_state(struct sudoku_state_t* state) | |||
603 | { | 603 | { |
604 | int r,c; | 604 | int r,c; |
605 | 605 | ||
606 | rb->strncpy(state->filename,GAME_FILE,MAX_PATH); | 606 | rb->strlcpy(state->filename,GAME_FILE,MAX_PATH); |
607 | for (r=0;r<9;r++) { | 607 | for (r=0;r<9;r++) { |
608 | for (c=0;c<9;c++) { | 608 | for (c=0;c<9;c++) { |
609 | state->startboard[r][c]=default_game[r][c]; | 609 | state->startboard[r][c]=default_game[r][c]; |
@@ -626,7 +626,7 @@ void clear_state(struct sudoku_state_t* state) | |||
626 | { | 626 | { |
627 | int r,c; | 627 | int r,c; |
628 | 628 | ||
629 | rb->strncpy(state->filename,GAME_FILE,MAX_PATH); | 629 | rb->strlcpy(state->filename,GAME_FILE,MAX_PATH); |
630 | for (r=0;r<9;r++) { | 630 | for (r=0;r<9;r++) { |
631 | for (c=0;c<9;c++) { | 631 | for (c=0;c<9;c++) { |
632 | state->startboard[r][c]='0'; | 632 | state->startboard[r][c]='0'; |
@@ -719,7 +719,7 @@ bool load_sudoku(struct sudoku_state_t* state, char* filename) | |||
719 | return(false); | 719 | return(false); |
720 | } | 720 | } |
721 | 721 | ||
722 | rb->strncpy(state->filename,filename,MAX_PATH); | 722 | rb->strlcpy(state->filename,filename,MAX_PATH); |
723 | n=rb->read(fd,buf,300); | 723 | n=rb->read(fd,buf,300); |
724 | if (n <= 0) { | 724 | if (n <= 0) { |
725 | return(false); | 725 | return(false); |
@@ -1111,7 +1111,7 @@ bool sudoku_generate(struct sudoku_state_t* state) | |||
1111 | rb->snprintf(str,sizeof(str),"Difficulty: %s",difficulty); | 1111 | rb->snprintf(str,sizeof(str),"Difficulty: %s",difficulty); |
1112 | display_board(state); | 1112 | display_board(state); |
1113 | rb->splash(HZ*3, str); | 1113 | rb->splash(HZ*3, str); |
1114 | rb->strncpy(state->filename,GAME_FILE,MAX_PATH); | 1114 | rb->strlcpy(state->filename,GAME_FILE,MAX_PATH); |
1115 | } else { | 1115 | } else { |
1116 | display_board(&new_state); | 1116 | display_board(&new_state); |
1117 | rb->splash(HZ*2, "Aborted"); | 1117 | rb->splash(HZ*2, "Aborted"); |
diff --git a/apps/plugins/test_codec.c b/apps/plugins/test_codec.c index a708ed7b07..c51fc4006f 100644 --- a/apps/plugins/test_codec.c +++ b/apps/plugins/test_codec.c | |||
@@ -451,7 +451,6 @@ static void init_ci(void) | |||
451 | 451 | ||
452 | /* strings and memory */ | 452 | /* strings and memory */ |
453 | ci.strcpy = rb->strcpy; | 453 | ci.strcpy = rb->strcpy; |
454 | ci.strncpy = rb->strncpy; | ||
455 | ci.strlen = rb->strlen; | 454 | ci.strlen = rb->strlen; |
456 | ci.strcmp = rb->strcmp; | 455 | ci.strcmp = rb->strcmp; |
457 | ci.strcat = rb->strcat; | 456 | ci.strcat = rb->strcat; |
@@ -716,7 +715,7 @@ enum plugin_status plugin_start(const void* parameter) | |||
716 | /* Test all files in the same directory as the file selected by the | 715 | /* Test all files in the same directory as the file selected by the |
717 | user */ | 716 | user */ |
718 | 717 | ||
719 | rb->strncpy(dirpath,parameter,sizeof(dirpath)); | 718 | rb->strlcpy(dirpath,parameter,sizeof(dirpath)); |
720 | ch = rb->strrchr(dirpath,'/'); | 719 | ch = rb->strrchr(dirpath,'/'); |
721 | ch[1]=0; | 720 | ch[1]=0; |
722 | 721 | ||
diff --git a/apps/plugins/text_editor.c b/apps/plugins/text_editor.c index 703b330d6c..617aeae8b1 100644 --- a/apps/plugins/text_editor.c +++ b/apps/plugins/text_editor.c | |||
@@ -133,7 +133,7 @@ char *list_get_name_cb(int selected_item, void* data, | |||
133 | rb->snprintf(buf , buf_len, "%s ...", b); | 133 | rb->snprintf(buf , buf_len, "%s ...", b); |
134 | b[buf_len-10] = t; | 134 | b[buf_len-10] = t; |
135 | } | 135 | } |
136 | else rb->strncpy(buf, b, buf_len); | 136 | else rb->strlcpy(buf, b, buf_len); |
137 | return buf; | 137 | return buf; |
138 | } | 138 | } |
139 | 139 | ||
diff --git a/apps/plugins/zxbox/snapshot.c b/apps/plugins/zxbox/snapshot.c index d078ec78b1..9a68540a04 100644 --- a/apps/plugins/zxbox/snapshot.c +++ b/apps/plugins/zxbox/snapshot.c | |||
@@ -603,8 +603,7 @@ void save_snapshot_file(char *name) | |||
603 | { | 603 | { |
604 | int type; | 604 | int type; |
605 | 605 | ||
606 | rb->strncpy(filenamebuf, name, MAXFILENAME-10); | 606 | rb->strlcpy(filenamebuf, name, MAXFILENAME-10 + 1); |
607 | filenamebuf[MAXFILENAME-10] = '\0'; | ||
608 | 607 | ||
609 | type = SN_Z80; | 608 | type = SN_Z80; |
610 | if(check_ext(filenamebuf, "z80")) type = SN_Z80; | 609 | if(check_ext(filenamebuf, "z80")) type = SN_Z80; |
@@ -642,8 +641,7 @@ void load_snapshot_file_type(char *name, int type) | |||
642 | int snsh; | 641 | int snsh; |
643 | SNFILE snfil; | 642 | SNFILE snfil; |
644 | 643 | ||
645 | rb->strncpy(filenamebuf, name, MAXFILENAME-10); | 644 | rb->strlcpy(filenamebuf, name, MAXFILENAME-10 + 1); |
646 | filenamebuf[MAXFILENAME-10] = '\0'; | ||
647 | 645 | ||
648 | spcf_find_file_type(filenamebuf, &filetype, &type); | 646 | spcf_find_file_type(filenamebuf, &filetype, &type); |
649 | if(type < 0) type = SN_Z80; | 647 | if(type < 0) type = SN_Z80; |
diff --git a/apps/plugins/zxbox/spconf.c b/apps/plugins/zxbox/spconf.c index 5a14959adc..728f78638c 100644 --- a/apps/plugins/zxbox/spconf.c +++ b/apps/plugins/zxbox/spconf.c | |||
@@ -111,8 +111,7 @@ void spcf_read_command_line(const void* parameter) | |||
111 | 111 | ||
112 | file_type = extensions[ix].type; | 112 | file_type = extensions[ix].type; |
113 | file_subtype = extensions[ix].subtype; | 113 | file_subtype = extensions[ix].subtype; |
114 | rb->strncpy(filenamebuf, parameter, MAXFILENAME - 10); | 114 | rb->strlcpy(filenamebuf, parameter, MAXFILENAME - 10 + 1); |
115 | filenamebuf[MAXFILENAME-10] = '\0'; | ||
116 | if(file_type < 0) file_subtype = -1; | 115 | if(file_type < 0) file_subtype = -1; |
117 | if(!spcf_find_file_type(filenamebuf, &file_type, &file_subtype)) | 116 | if(!spcf_find_file_type(filenamebuf, &file_type, &file_subtype)) |
118 | return; | 117 | return; |
diff --git a/apps/plugins/zxbox/sptape.c b/apps/plugins/zxbox/sptape.c index f0e04de2fb..21f962ea28 100644 --- a/apps/plugins/zxbox/sptape.c +++ b/apps/plugins/zxbox/sptape.c | |||
@@ -594,8 +594,7 @@ void start_play_file_type(char *name, int seg, int type) | |||
594 | { | 594 | { |
595 | int filetype = FT_TAPEFILE; | 595 | int filetype = FT_TAPEFILE; |
596 | 596 | ||
597 | rb->strncpy(tapename, name, MAXFILENAME-10); | 597 | rb->strlcpy(tapename, name, MAXFILENAME-10 + 1); |
598 | tapename[MAXFILENAME-10] = '\0'; | ||
599 | 598 | ||
600 | currseg = seg; | 599 | currseg = seg; |
601 | tapetype = type; | 600 | tapetype = type; |
diff --git a/apps/plugins/zxbox/tapefile.c b/apps/plugins/zxbox/tapefile.c index 19f6aba980..0e262aa0f7 100644 --- a/apps/plugins/zxbox/tapefile.c +++ b/apps/plugins/zxbox/tapefile.c | |||
@@ -510,8 +510,7 @@ static int interpret_tzx_header(byte *hb, struct seginfo *csp) | |||
510 | int blen; | 510 | int blen; |
511 | rb->snprintf(seg_desc,DESC_LEN, "Begin Group: "); | 511 | rb->snprintf(seg_desc,DESC_LEN, "Begin Group: "); |
512 | blen = (int) rb->strlen(seg_desc); | 512 | blen = (int) rb->strlen(seg_desc); |
513 | rb->strncpy(seg_desc+blen, (char *) rbuf, (unsigned) csp->len); | 513 | rb->strlcpy(seg_desc+blen, (char *) rbuf, (unsigned) csp->len + 1); |
514 | seg_desc[csp->len + blen] = '\0'; | ||
515 | } | 514 | } |
516 | break; | 515 | break; |
517 | 516 | ||
@@ -618,8 +617,7 @@ static int interpret_tzx_header(byte *hb, struct seginfo *csp) | |||
618 | return 0; | 617 | return 0; |
619 | } | 618 | } |
620 | csp->ptr += csp->len; | 619 | csp->ptr += csp->len; |
621 | rb->strncpy(seg_desc, (char *) rbuf, (unsigned) csp->len); | 620 | rb->strlcpy(seg_desc, (char *) rbuf, (unsigned) csp->len + 1); |
622 | seg_desc[csp->len] = '\0'; | ||
623 | break; | 621 | break; |
624 | 622 | ||
625 | case 0x32: | 623 | case 0x32: |