aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshwini Sharma <ak.ashwini1981@gmail.com>2014-07-14 05:44:29 -0500
committerAshwini Sharma <ak.ashwini1981@gmail.com>2014-07-14 05:44:29 -0500
commit30f6ef5fcd571c554c2c59585d126b92793379d0 (patch)
tree9f4d0292ba4edcb03b653913620422b3d7c4dc98
parentfbe5dda4d488fdd9961ef1fd21beee59467d8e29 (diff)
downloadtoybox-30f6ef5fcd571c554c2c59585d126b92793379d0.tar.gz
fdisk : partitions > 60, are deleted, offset entry for extended partitions was wrong.
fsck: memory leak/segfault resolved. ftpget : warning for unused variable 'ptr' removed.
-rw-r--r--toys/pending/fdisk.c18
-rw-r--r--toys/pending/fsck.c11
-rw-r--r--toys/pending/ftpget.c2
3 files changed, 22 insertions, 9 deletions
diff --git a/toys/pending/fdisk.c b/toys/pending/fdisk.c
index 932b38df..3ee9f598 100644
--- a/toys/pending/fdisk.c
+++ b/toys/pending/fdisk.c
@@ -243,6 +243,13 @@ static void read_ebr(int idx)
if (!extended_offset) extended_offset = local_start_off;
do {
+ if (num_parts >= 60) {
+ xprintf("Warning: deleting partitions after 60\n");
+ memset(q, 0, sizeof(struct partition)); //clear_partition
+ partitions[num_parts-1].modified = 1;
+ break;
+ }
+
sec_buf = xzalloc(g_sect_size);
partitions[num_parts].part = part_offset(sec_buf, 0);
partitions[num_parts].sec_buffer = sec_buf;
@@ -258,7 +265,7 @@ static void read_ebr(int idx)
}
num_parts++; //extended partions present.
q = part_offset(sec_buf, 1);
- } while (!is_partition_clear(q));
+ } while (!is_partition_clear(q) && IS_EXTENDED(q->sys_ind));
}
static void physical_HS(int* h, int *s)
@@ -461,7 +468,7 @@ static void list_partitions(int validate)
p = partitions[i].part;
if (is_partition_clear(p)) continue;
- boot = p->boot_ind == 0x80?'*':' ';
+ boot = ((p->boot_ind == 0x80)?'*':(!p->boot_ind)?' ':'?');
start_sec = swap_le32toh(p->start4) + partitions[i].start_offset;
secs = swap_le32toh(p->size4);
@@ -872,8 +879,11 @@ static sector_t ask_end_sector(int idx, sector_t* begin, sector_t* end, int ext_
if (idx >= 4) limit = end[ext_idx];
- for (i = 0; i < num_parts; i++)
+ for (i = 0; i < num_parts; i++) {
+ struct part_entry *pe = &partitions[i];
+ if (start < pe->start_offset && limit >= pe->start_offset) limit = pe->start_offset - 1;
if (start < begin[i] && limit >= begin[i]) limit = begin[i] - 1;
+ }
start_cyl = start/(g_sectors * g_heads) + 1;
limit_cyl = limit/(g_sectors * g_heads) + 1;
@@ -949,7 +959,7 @@ static int add_partition(int idx, int sys_id)
p = partitions[idx-1].part + 1; //extended pointer for logical partitions
set_levalue(p->start4, pe->start_offset - extended_offset);
set_levalue(p->size4, end - start + 1 + (dos_flag? g_sectors: 1));
- set_hsc(p, start, end);
+ set_hsc(p, pe->start_offset, end);
p->boot_ind = 0;
p->sys_ind = EXTENDED;
partitions[idx-1].modified = 1;
diff --git a/toys/pending/fsck.c b/toys/pending/fsck.c
index b968844a..56dfb5df 100644
--- a/toys/pending/fsck.c
+++ b/toys/pending/fsck.c
@@ -215,8 +215,10 @@ static void do_fsck(struct f_sys_info *finfo)
xputc('\n');
}
- if (toys.optflags & FLAG_N) return;
- else {
+ if (toys.optflags & FLAG_N) {
+ free(args);
+ return;
+ } else {
if ((pid = fork()) < 0) {
perror_msg(args[0]);
return;
@@ -244,12 +246,13 @@ static int wait_for(int for_all)
{
pid_t pid;
int status = 0, child_exited;
- struct child_list *prev, *temp = c_list;
- prev = temp;
+ struct child_list *prev, *temp;
errno = 0;
if (!c_list) return 0;
while ((pid = wait(&status))) {
+ temp = c_list;
+ prev = temp;
if (TT.sig_num) kill_all();
child_exited = 0;
if (pid < 0) {
diff --git a/toys/pending/ftpget.c b/toys/pending/ftpget.c
index 8643badb..a68ceeb6 100644
--- a/toys/pending/ftpget.c
+++ b/toys/pending/ftpget.c
@@ -129,7 +129,7 @@ static void send_requests(void)
static void get_sockaddr(char *host)
{
struct addrinfo hints, *result;
- char *ptr, port[6];
+ char port[6];
int status;
errno = 0;