[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#950950: hamlib: Please include patch to fix unaligned access in dummy/dummy.c



Source: hamlib
Version: 3.3-8
Severity: normal
Tags: patch
User: debian-sparc@lists.debian.org
Usertags: sparc64

Hi!

The attached patch fixes an unaligned access in dummy_get_level() which
resulted in the testsuite crashing on sparc64 [1].

I have opened a pull request upstream as well to address the issue [2],
so carrying the patch should hopefully not be necessary in the future.

Thanks,
Adrian

> [1] https://buildd.debian.org/status/fetch.php?pkg=hamlib&arch=sparc64&ver=3.3-8&stamp=1580780480&raw=0

--
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
dummy/dummy.c: Fix unaligned access in dummy_get_level()

This fixes an unaligned access in dummy/dummy.c in the function
dummy_get_level() which resulted in crashes (Bus Error) on systems
with stricter alignment requirements such as SPARC.

On x86_64 (and any other architecture with less strict alignment
requirements), the compiler automatically optimizes the memcpy()
out if necessary such that there are no performance issues.

--- hamlib-3.3.orig/dummy/dummy.c
+++ hamlib-3.3/dummy/dummy.c
@@ -834,7 +834,7 @@ static int dummy_get_level(RIG *rig, vfo
     }
   }
 
-  *val = curr->levels[idx];
+  memcpy (val, &curr->levels[idx], sizeof(value_t));
   rig_debug(RIG_DEBUG_VERBOSE,"%s called: %s\n",__FUNCTION__,
 				  rig_strlevel(level));
 

Reply to: