Skip to content

Commit

Permalink
String unpack off-by-one offset increment
Browse files Browse the repository at this point in the history
  • Loading branch information
attipaci committed Oct 8, 2024
1 parent 9b5d662 commit 1a9ad6e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/smax-lazy.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ static LazyMonitor *GetMonitorAsync(const char *table, const char *key);
static LazyMonitor *GetSpecificMonitorAsync(const char *table, const char *key);
static void ProcessLazyUpdates(const char *pattern, const char *channel, const char *msg, long length);


/**
* Decrements the number of concurrent user calls that currently need access to the specific
* lazy monitor data. If the monitor has no users left and is not currently monitored
Expand Down
5 changes: 2 additions & 3 deletions src/smax-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ unsigned char smaxGetHashLookupIndex(const char *table, int lTab, const char *ke
}
/// \endcond


/**
* \cond PROTECTED
*
Expand Down Expand Up @@ -1136,13 +1135,13 @@ int smaxUnpackStrings(const char *data, int len, int count, char **dst) {

for(l=0; from[l] && offset + l < len; l++) if(from[l] == '\r') break;

dst[i] = (char *) malloc(l+1);
dst[i] = (char *) malloc(l + 1);
if(!dst[i]) return x_error(X_INCOMPLETE, errno, fn, "malloc() error (%d bytes)", (l+1));

if(l) memcpy(dst[i], from, l);
dst[i][l] = '\0'; // termination...

offset += l;
offset += l + 1;
}

// Pad remaining elements with empty strings...
Expand Down

0 comments on commit 1a9ad6e

Please sign in to comment.