Skip to content

Commit ce93481

Browse files
authored
Changes behavior when comparing versions (#199)
There is a check for version mismatch between signing and validation. If the stream has been signed with a newer version than what is used when validating the validation result cannot be guaranteed. The reason is that it is not possible to be forward compatible. However, if the change is minor, like when the patch number only has changed, it should still be possible to trust the result. This commit checks only major and minor for version mismatch. Also, the authenticity report is now initialized with the current version.
1 parent 3dfde4d commit ce93481

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

lib/src/includes/onvif_media_signing_common.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ onvif_media_signing_get_version();
142142
* done with a newer version of this library than what is used in the validation firmware
143143
* there is no guarantee that validation can be performed correctly.
144144
*
145+
* The comparison is done on major and minor numbers only. Patch number should not affect
146+
* changes in the validation result. This makes it more convenient to keep, for example,
147+
* a media player up to date.
148+
*
145149
* @param version1 First version string for comparison
146150
* @param version2 Second version string for comparison
147151
*

lib/src/oms_authenticity_report.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ authenticity_report_init(onvif_media_signing_authenticity_t *authenticity_report
233233
assert(!authenticity_report->this_version);
234234
authenticity_report->version_on_signing_side = calloc(1, OMS_VERSION_MAX_STRLEN);
235235
authenticity_report->this_version = calloc(1, OMS_VERSION_MAX_STRLEN);
236+
strcpy(authenticity_report->this_version, ONVIF_MEDIA_SIGNING_VERSION);
236237

237238
latest_validation_init(&authenticity_report->latest_validation);
238239
accumulated_validation_init(&authenticity_report->accumulated_validation);

lib/src/oms_common.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ onvif_media_signing_compare_versions(const char *version1, const char *version2)
11391139

11401140
int result = 0;
11411141
int j = 0;
1142-
while (result == 0 && j < OMS_VERSION_BYTES) {
1142+
while (result == 0 && j < OMS_VERSION_BYTES - 1) {
11431143
result = arr1[j] - arr2[j];
11441144
j++;
11451145
}

0 commit comments

Comments
 (0)