X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: djgpp AT delorie DOT com X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=18iVUjYJmZTx4OSw6C/myc1oQYhzkik3CHNvh1W+I3E=; b=if0TNyrHjk4luVLqpeRpT3IJVPLhwTBsOZrbWFEqGPyWw2SU6Ht0CEz7Mr8vusem0r swuxBV/2I25Pek78v8vXaQc713aKmDIC23oQilTqxbs0BxpcfaVlx3ZJOc/sgEozeMvj xxeP5JvsUJQFzIdmoDPjuxbLn35B0iTU779ZmJFD1JfjjGmfytbpFqBnFGTCEDJXydPp QNYvt+KOOIsOMBmOyK9KB9aDSi8BnEG4GqZc+rUDoCKFrJrSqol3i3QxEuyFuB+nDHAB a3qkqNKOImEEqWQRm4j9D70N91auVVMiEkVa+1V31NIOyvKUMTf1OL9ql2tn8EsQbpJX if1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=18iVUjYJmZTx4OSw6C/myc1oQYhzkik3CHNvh1W+I3E=; b=a0pm+b7bheKIe3YfXaIcwSJWQSGedZIqatAQFoERb3xiv3aE7bligQQmSj9LPcVz3m edsVDFZPbSEiXHqG9nrpglOWN1PfWQZB+lWAHhG7qngPhw6kyMTNr+UoK2CpHijP+n81 LQxjlhk3KrcjdKP2StXmLRixMBphbMlNQo9iutS8sNDRZPv8tJIWj9XnLATnNdRFFtjB GgjkgOySj9FWfhoRpQE7zsK/ndbD1DX0t8LS+SF7EtSHWg9Ym/21tOuHHN4rQ3T1PXDy T/EqvHoSDfPh1Ai+KEt8kFrQO+85CFrccsdebTNnv30i3Ljub3ooLgF3mYbQ08yXVjDN mP6Q== X-Gm-Message-State: AN3rC/6NLenYBmfBLM2M8uZ2YSH3wJ6shyXL1u/SCAjvbJl2PnNE9rM3 CyMEVzwmWl7svlqOVdQZLGvXBbEGTg== X-Received: by 10.200.47.2 with SMTP id j2mr24967924qta.277.1493714351169; Tue, 02 May 2017 01:39:11 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: "Ozkan Sezer (sezeroz AT gmail DOT com) [via djgpp AT delorie DOT com]" Date: Tue, 2 May 2017 11:39:10 +0300 Message-ID: Subject: Re: dxe3gen does not handle relocs > 65535 To: djgpp AT delorie DOT com Content-Type: text/plain; charset=UTF-8 Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On 5/2/17, Martin Str|mberg (ams AT ludd DOT luth DOT se) [via djgpp AT delorie DOT com] wrote: > "Ozkan Sezer (sezeroz AT gmail DOT com) [via djgpp AT delorie DOT com]" > wrote: >> Here is a somewhat cleaned-up patch with a changelog entry: > >> dxe3gen.c: handle extended relocations. bump version to 1.0.4. > ... >> diff -u -p -r1.23 dxe3gen.c >> --- src/dxe/dxe3gen.c 4 Oct 2015 10:27:26 -0000 1.23 >> +++ src/dxe/dxe3gen.c 28 Apr 2017 18:11:10 -0000 >> /* Read the relocation table */ >> - relocs = (RELOC *)malloc(sc.s_nreloc * sizeof(RELOC)); >> fseek(inf, sc.s_relptr, SEEK_SET); >> - fread(relocs, RELSZ, sc.s_nreloc, inf); >> + if (sc.s_flags & STYP_NRELOC_OVFL) { >> + fread(&real_nrelocs, 4, 1, inf); /* read r_vaddr */ >> + fseek(inf, RELSZ - 4, SEEK_CUR); /* skip the rest */ > > You don't check the return value. What if the file is truncated/corrupt? That means things are far more borked than one can imagine. I would check the returned value, but many similar calls don't do that in dxe3gen, so I didn't. > OTOH, perhaps thus praxis is all over dxe, so *shrug*. Well yes. (And it only runs on little-endian hosts, there is no syte-swapping anywhere..)