diff options
author | Rob Landley <rob@landley.net> | 2006-06-25 00:34:52 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-06-25 00:34:52 +0000 |
commit | 768945b762b8850691acd2b63116eed18faa1812 (patch) | |
tree | 7b443f4d614e327205a5aa17f2c0371c2a04723e | |
parent | 641c3537c0bf63793a6195108a1d2e682ed4cba1 (diff) | |
download | busybox-w32-768945b762b8850691acd2b63116eed18faa1812.tar.gz busybox-w32-768945b762b8850691acd2b63116eed18faa1812.tar.bz2 busybox-w32-768945b762b8850691acd2b63116eed18faa1812.zip |
A few patches from Erik Hovland, turning strncpy() into safe_strncpy() and
removing some unnecessary code.
-rw-r--r-- | archival/tar.c | 9 | ||||
-rw-r--r-- | e2fsprogs/tune2fs.c | 4 | ||||
-rw-r--r-- | editors/vi.c | 3 | ||||
-rw-r--r-- | networking/zcip.c | 2 |
4 files changed, 6 insertions, 12 deletions
diff --git a/archival/tar.c b/archival/tar.c index f3594f685..5b7c1425a 100644 --- a/archival/tar.c +++ b/archival/tar.c | |||
@@ -42,12 +42,8 @@ | |||
42 | #ifdef CONFIG_FEATURE_TAR_CREATE | 42 | #ifdef CONFIG_FEATURE_TAR_CREATE |
43 | 43 | ||
44 | /* Tar file constants */ | 44 | /* Tar file constants */ |
45 | # define TAR_MAGIC "ustar" /* ustar and a null */ | ||
46 | # define TAR_VERSION " " /* Be compatible with GNU tar format */ | ||
47 | 45 | ||
48 | #define TAR_BLOCK_SIZE 512 | 46 | #define TAR_BLOCK_SIZE 512 |
49 | #define TAR_MAGIC_LEN 6 | ||
50 | #define TAR_VERSION_LEN 2 | ||
51 | 47 | ||
52 | /* POSIX tar Header Block, from POSIX 1003.1-1990 */ | 48 | /* POSIX tar Header Block, from POSIX 1003.1-1990 */ |
53 | #define NAME_SIZE 100 | 49 | #define NAME_SIZE 100 |
@@ -208,15 +204,14 @@ static inline int writeTarHeader(struct TarBallInfo *tbInfo, | |||
208 | 204 | ||
209 | memset(&header, 0, size); | 205 | memset(&header, 0, size); |
210 | 206 | ||
211 | strncpy(header.name, header_name, sizeof(header.name)); | 207 | safe_strncpy(header.name, header_name, sizeof(header.name)); |
212 | 208 | ||
213 | putOctal(header.mode, sizeof(header.mode), statbuf->st_mode); | 209 | putOctal(header.mode, sizeof(header.mode), statbuf->st_mode); |
214 | putOctal(header.uid, sizeof(header.uid), statbuf->st_uid); | 210 | putOctal(header.uid, sizeof(header.uid), statbuf->st_uid); |
215 | putOctal(header.gid, sizeof(header.gid), statbuf->st_gid); | 211 | putOctal(header.gid, sizeof(header.gid), statbuf->st_gid); |
216 | putOctal(header.size, sizeof(header.size), 0); /* Regular file size is handled later */ | 212 | putOctal(header.size, sizeof(header.size), 0); /* Regular file size is handled later */ |
217 | putOctal(header.mtime, sizeof(header.mtime), statbuf->st_mtime); | 213 | putOctal(header.mtime, sizeof(header.mtime), statbuf->st_mtime); |
218 | strncpy(header.magic, TAR_MAGIC TAR_VERSION, | 214 | strcpy(header.magic, "ustar "); |
219 | TAR_MAGIC_LEN + TAR_VERSION_LEN); | ||
220 | 215 | ||
221 | /* Enter the user and group names (default to root if it fails) */ | 216 | /* Enter the user and group names (default to root if it fails) */ |
222 | if (bb_getpwuid(header.uname, statbuf->st_uid, sizeof(header.uname)) == NULL) | 217 | if (bb_getpwuid(header.uname, statbuf->st_uid, sizeof(header.uname)) == NULL) |
diff --git a/e2fsprogs/tune2fs.c b/e2fsprogs/tune2fs.c index 65ff445e7..521e49874 100644 --- a/e2fsprogs/tune2fs.c +++ b/e2fsprogs/tune2fs.c | |||
@@ -699,13 +699,13 @@ int tune2fs_main(int argc, char **argv) | |||
699 | if (strlen(new_label) > sizeof(sb->s_volume_name)) | 699 | if (strlen(new_label) > sizeof(sb->s_volume_name)) |
700 | bb_error_msg("Warning: label too long, truncating\n"); | 700 | bb_error_msg("Warning: label too long, truncating\n"); |
701 | memset(sb->s_volume_name, 0, sizeof(sb->s_volume_name)); | 701 | memset(sb->s_volume_name, 0, sizeof(sb->s_volume_name)); |
702 | strncpy(sb->s_volume_name, new_label, | 702 | safe_strncpy(sb->s_volume_name, new_label, |
703 | sizeof(sb->s_volume_name)); | 703 | sizeof(sb->s_volume_name)); |
704 | ext2fs_mark_super_dirty(fs); | 704 | ext2fs_mark_super_dirty(fs); |
705 | } | 705 | } |
706 | if (M_flag) { | 706 | if (M_flag) { |
707 | memset(sb->s_last_mounted, 0, sizeof(sb->s_last_mounted)); | 707 | memset(sb->s_last_mounted, 0, sizeof(sb->s_last_mounted)); |
708 | strncpy(sb->s_last_mounted, new_last_mounted, | 708 | safe_strncpy(sb->s_last_mounted, new_last_mounted, |
709 | sizeof(sb->s_last_mounted)); | 709 | sizeof(sb->s_last_mounted)); |
710 | ext2fs_mark_super_dirty(fs); | 710 | ext2fs_mark_super_dirty(fs); |
711 | } | 711 | } |
diff --git a/editors/vi.c b/editors/vi.c index 660c01c3c..a890ad9d3 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -1088,13 +1088,12 @@ static void Hit_Return(void) | |||
1088 | //----- Synchronize the cursor to Dot -------------------------- | 1088 | //----- Synchronize the cursor to Dot -------------------------- |
1089 | static void sync_cursor(Byte * d, int *row, int *col) | 1089 | static void sync_cursor(Byte * d, int *row, int *col) |
1090 | { | 1090 | { |
1091 | Byte *beg_cur, *end_cur; // begin and end of "d" line | 1091 | Byte *beg_cur; // begin and end of "d" line |
1092 | Byte *beg_scr, *end_scr; // begin and end of screen | 1092 | Byte *beg_scr, *end_scr; // begin and end of screen |
1093 | Byte *tp; | 1093 | Byte *tp; |
1094 | int cnt, ro, co; | 1094 | int cnt, ro, co; |
1095 | 1095 | ||
1096 | beg_cur = begin_line(d); // first char of cur line | 1096 | beg_cur = begin_line(d); // first char of cur line |
1097 | end_cur = end_line(d); // last char of cur line | ||
1098 | 1097 | ||
1099 | beg_scr = end_scr = screenbegin; // first char of screen | 1098 | beg_scr = end_scr = screenbegin; // first char of screen |
1100 | end_scr = end_screen(); // last char of screen | 1099 | end_scr = end_screen(); // last char of screen |
diff --git a/networking/zcip.c b/networking/zcip.c index a6b034ea2..e25f01755 100644 --- a/networking/zcip.c +++ b/networking/zcip.c | |||
@@ -240,7 +240,7 @@ int zcip_main(int argc, char *argv[]) | |||
240 | 240 | ||
241 | // initialize saddr | 241 | // initialize saddr |
242 | memset(&saddr, 0, sizeof (saddr)); | 242 | memset(&saddr, 0, sizeof (saddr)); |
243 | strncpy(saddr.sa_data, intf, sizeof (saddr.sa_data)); | 243 | safe_strncpy(saddr.sa_data, intf, sizeof (saddr.sa_data)); |
244 | 244 | ||
245 | // open an ARP socket | 245 | // open an ARP socket |
246 | if ((fd = socket(PF_PACKET, SOCK_PACKET, htons(ETH_P_ARP))) < 0) { | 246 | if ((fd = socket(PF_PACKET, SOCK_PACKET, htons(ETH_P_ARP))) < 0) { |