MIT-LCP / MIT-LCP/physionet

Offset off by one in parsescp.c

Open
#119 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
82
Forks
21
Avg merge
35m
Merged PRs (30d)
1

Description

The title says it all. Encoding type it read from the second byte of sampling period, and compression byte is read from the encoding byte. Here is the patch:

--- convert/parsescp.c.orig	2018-11-28 22:55:57.000000000 +0100
+++ convert/parsescp.c	2019-07-28 21:32:33.361920818 +0200
@@ -1958,8 +1958,8 @@
 	printf("Error: sampling frequency not specified;  assuming 500 Hz\n");
 	sfreq = 500;
     }
-    if (vflag) printf("  Encoding type: %d ", *(p+3));
-    switch (*(p+3)) {
+    if (vflag) printf("  Encoding type: %d ", *(p+4));
+    switch (*(p+4)) {
     case 0: if (vflag) printf("(amplitudes)\n"); enctype = 0; break;
     case 1: if (vflag) printf("(first differences)\n"); enctype = 1; break;
     case 2: if (vflag) printf("(second differences)\n"); enctype = 2; break;
@@ -1968,7 +1968,7 @@
     }
     if (section == 6) {
 	if (vflag) printf("  Compression type: %d ", *(p+4));
-	switch (*(p+4)) {
+	switch (*(p+5)) {
 	case 0: if (vflag) printf("(non-bimodal)\n"); comptype = 0; break;
 	case 1: if (vflag) printf("(bimodal)\n"); comptype = 1; break;
 	default: if (vflag) printf("<undefined, assuming bimodal>\n"); comptype = 1;

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in convert/parsescp.c around the sampling-period parsing shown in the issue, and trace the byte offsets used for encoding and compression, including section 6. Confirm the diagnostic output and parsed values use the intended bytes for both fields, then validate the affected SCP parsing behavior with representative input.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.