From c908a1a3ae084bd2fa6c10874e9e2dfc40926cc3 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Mon, 29 Aug 2016 17:02:08 +0000 Subject: [PATCH] Correcty unpack both 4 & 6 character grids from WSPR type 3 messages git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7043 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- lib/wsprd/wsprd_utils.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/wsprd/wsprd_utils.c b/lib/wsprd/wsprd_utils.c index 26828938d..8c993287b 100644 --- a/lib/wsprd/wsprd_utils.c +++ b/lib/wsprd/wsprd_utils.c @@ -300,18 +300,18 @@ int unpk_(signed char *message, char *hashtab, char *call_loc_pow, char *callsig } else if ( ntype < 0 ) { ndbm=-(ntype+1); memset(grid6,0,sizeof(char)*7); - strncat(grid6,callsign+5,1); - strncat(grid6,callsign,5); + size_t len=strlen(callsign); + strncat(grid6,callsign+len-1,1); + strncat(grid6,callsign,len-1); int nu=ndbm%10; - if( (nu == 0 || nu == 3 || nu == 7 || nu == 10) && \ - (isalpha(grid6[0]) && isalpha(grid6[1]) && \ - isdigit(grid6[2]) && isdigit(grid6[3]) ) ) { + if ((nu != 0 && nu != 3 && nu != 7 && nu != 10) || + !isalpha(grid6[0]) || !isalpha(grid6[1]) || + !isdigit(grid6[2]) || !isdigit(grid6[3])) { // not testing 4'th and 5'th chars because of this case: JO33 40 // grid is only 4 chars even though this is a hashed callsign... // isalpha(grid6[4]) && isalpha(grid6[5]) ) ) { - ihash=nhash(callsign,strlen(callsign),(uint32_t)146); - strcpy(hashtab+ihash*13,callsign); - } else noprint=1; + noprint=1; + } ihash=(n2-ntype-64)/128; if( strncmp(hashtab+ihash*13,"\0",1) != 0 ) {