On 2020/04/19 09:17, Steve Williams wrote:
> I am missing something on building the Debug packages.  I modified the
> Makefile per your other email thread but there must be more magic as I don't
> see any of the output pertaining to "Extracting debug info..."

As others mentioned, -current has some infrastructure to produce detached
symbols (and add links to the object so gdb can find them). That isn't
available in earlier releases but the standard old method of setting
DEBUG=-g in the environment is available:

make clean
make DEBUG=-g repackage (add e.g. MAKE_JOBS=4 to build on multiple cpus)
make reinstall

> It is a bit disappointing that the newer version of freerdp needs
> significant work to have it functional in OpenBSD.  I had a look at the
> Apple code for the timers... the whole timers file.  Not very pleasant with
> all the #ifdef's all over the place.  I am sure greater minds than mine have
> looked at what it would take to have it working in OpenBSD.

cheloha@ mentioned that he has done some work on posix timers for OpenBSD,
I'm not sure what state that is currently in, but it's probably more pleasant
and more useful to gone down that road than add special OpenBSD support to
freerdp..

> I guess that leaves debugging the existing code.  I started by comparing the
> 2.0rc1 /winpr/libwinpr/crt/alignment.c with the version in 2.0 and there
> have been quite a few changes.  It seems most of them are for clarity of
> code,  but hidden in the changes must be some alignment challenges.  Lots of
> math going on... and a few confusing comments.
> 
> For example:
>     /* alignment must be a power of 2 */
>     if (alignment % 2 == 1)
>         return NULL;
> 
> That's not a "power" of two, that's a "multiple" of 2.  What did they really
> mean??  I assume they meant multiple... but that's not what the code is
> doing.

There are only 2 commits in that file between rc1 and 2.0; one is code
formatting, the other is this:

https://github.com/FreeRDP/FreeRDP/issues/2039 /
https://github.com/FreeRDP/FreeRDP/pull/4961

Perhaps it will fix the problem you're seeing. Please try building with the
attached file saved in /usr/ports/x11/freerdp/patches.

$OpenBSD$

>From 71036fe0b2e3b599ba67340fb0e66daee29a4975 Mon Sep 17 00:00:00 2001
From: Armin Novak <armin.no...@thincast.com>
Date: Wed, 24 Oct 2018 10:59:54 +0200
Subject: [PATCH] Fixed #2039: Check for overflow in calculations.

Index: winpr/libwinpr/crt/alignment.c
--- winpr/libwinpr/crt/alignment.c.orig
+++ winpr/libwinpr/crt/alignment.c
@@ -27,6 +27,9 @@
 
 #ifndef _WIN32
 
+#include <stdint.h>
+#include <limits.h>
+
 #define WINPR_ALIGNED_MEM_SIGNATURE            0x0BA0BAB
 
 #define WINPR_ALIGNED_MEM_STRUCT_FROM_PTR(_memptr) \
@@ -70,6 +73,8 @@ void* _aligned_recalloc(void* memblock, size_t num, si
 
 void* _aligned_offset_malloc(size_t size, size_t alignment, size_t offset)
 {
+       size_t header, alignsize;
+       uintptr_t basesize;
        void* base;
        void* memblock;
        WINPR_ALIGNED_MEM* pMem;
@@ -86,13 +91,31 @@ void* _aligned_offset_malloc(size_t size, size_t align
        if (alignment < sizeof(void*))
                alignment = sizeof(void*);
 
+       if (alignment > SIZE_MAX - sizeof(WINPR_ALIGNED_MEM))
+               return NULL;
+
+       header = sizeof(WINPR_ALIGNED_MEM) + alignment;
+
+       if (size > SIZE_MAX - header)
+               return NULL;
+
+       alignsize = size + header;
        /* malloc size + alignment to make sure we can align afterwards */
-       base = malloc(size + alignment + sizeof(WINPR_ALIGNED_MEM));
+       base = malloc(alignsize);
 
        if (!base)
                return NULL;
 
-       memblock = (void*)((((size_t)(((BYTE*) base) + alignment + offset + 
sizeof(WINPR_ALIGNED_MEM)) & ~(alignment - 1)) - offset));
+       basesize = (uintptr_t)base;
+
+       if ((offset > UINTPTR_MAX) || (header > UINTPTR_MAX - offset) ||
+           (basesize > UINTPTR_MAX - header - offset))
+       {
+               free(base);
+               return NULL;
+       }
+
+       memblock = (void*)(((basesize + header + offset) & ~(alignment - 1)) - 
offset);
        pMem = WINPR_ALIGNED_MEM_STRUCT_FROM_PTR(memblock);
        pMem->sig = WINPR_ALIGNED_MEM_SIGNATURE;
        pMem->base_addr = base;
@@ -111,6 +134,7 @@ void* _aligned_offset_realloc(void* memblock, size_t s
                return _aligned_offset_malloc(size, alignment, offset);
 
        pMem = WINPR_ALIGNED_MEM_STRUCT_FROM_PTR(memblock);
+
        if (pMem->sig != WINPR_ALIGNED_MEM_SIGNATURE)
        {
                WLog_ERR(TAG, "_aligned_offset_realloc: memory block was not 
allocated by _aligned_malloc!");
@@ -124,18 +148,19 @@ void* _aligned_offset_realloc(void* memblock, size_t s
        }
 
        newMemblock = _aligned_offset_malloc(size, alignment, offset);
+
        if (!newMemblock)
                return NULL;
 
        pNewMem = WINPR_ALIGNED_MEM_STRUCT_FROM_PTR(newMemblock);
-
        copySize = (pNewMem->size < pMem->size) ? pNewMem->size : pMem->size;
        CopyMemory(newMemblock, memblock, copySize);
        _aligned_free(memblock);
        return newMemblock;
 }
 
-void* _aligned_offset_recalloc(void* memblock, size_t num, size_t size, size_t 
alignment, size_t offset)
+void* _aligned_offset_recalloc(void* memblock, size_t num, size_t size, size_t 
alignment,
+                               size_t offset)
 {
        void* newMemblock;
        WINPR_ALIGNED_MEM* pMem;
@@ -144,15 +169,18 @@ void* _aligned_offset_recalloc(void* memblock, size_t 
        if (!memblock)
        {
                newMemblock = _aligned_offset_malloc(size * num, alignment, 
offset);
+
                if (newMemblock)
                {
                        pNewMem = 
WINPR_ALIGNED_MEM_STRUCT_FROM_PTR(newMemblock);
                        ZeroMemory(newMemblock, pNewMem->size);
                }
+
                return memblock;
        }
 
        pMem = WINPR_ALIGNED_MEM_STRUCT_FROM_PTR(memblock);
+
        if (pMem->sig != WINPR_ALIGNED_MEM_SIGNATURE)
        {
                WLog_ERR(TAG, "_aligned_offset_recalloc: memory block was not 
allocated by _aligned_malloc!");
@@ -171,7 +199,6 @@ void* _aligned_offset_recalloc(void* memblock, size_t 
                return NULL;
 
        pNewMem = WINPR_ALIGNED_MEM_STRUCT_FROM_PTR(newMemblock);
-
        ZeroMemory(newMemblock, pNewMem->size);
        _aligned_free(memblock);
        return newMemblock;

Reply via email to