summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/opkg/opkg/0002-md5-Add-md5_to_string-function.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/opkg/opkg/0002-md5-Add-md5_to_string-function.patch')
-rw-r--r--meta/recipes-devtools/opkg/opkg/0002-md5-Add-md5_to_string-function.patch110
1 files changed, 110 insertions, 0 deletions
diff --git a/meta/recipes-devtools/opkg/opkg/0002-md5-Add-md5_to_string-function.patch b/meta/recipes-devtools/opkg/opkg/0002-md5-Add-md5_to_string-function.patch
new file mode 100644
index 0000000000..3b823c693c
--- /dev/null
+++ b/meta/recipes-devtools/opkg/opkg/0002-md5-Add-md5_to_string-function.patch
@@ -0,0 +1,110 @@
1From ecad8afab377d8be95eeaafc08afa228c8e030c3 Mon Sep 17 00:00:00 2001
2From: Paul Barker <paul@paulbarker.me.uk>
3Date: Sat, 7 Nov 2015 10:23:50 +0000
4Subject: [PATCH 2/4] md5: Add md5_to_string function
5
6Signed-off-by: Paul Barker <paul@paulbarker.me.uk>
7Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
8
9Upstream-Status: Accepted
10---
11 libopkg/file_util.c | 28 +++-------------------------
12 libopkg/md5.c | 7 +++++++
13 libopkg/md5.h | 3 +++
14 3 files changed, 13 insertions(+), 25 deletions(-)
15
16diff --git a/libopkg/file_util.c b/libopkg/file_util.c
17index 5eff469..cb3dbf0 100644
18--- a/libopkg/file_util.c
19+++ b/libopkg/file_util.c
20@@ -349,27 +349,13 @@ int file_mkdir_hier(const char *path, long mode)
21
22 char *file_md5sum_alloc(const char *file_name)
23 {
24- static const int md5sum_bin_len = 16;
25- static const int md5sum_hex_len = 32;
26-
27- static const unsigned char bin2hex[16] = {
28- '0', '1', '2', '3',
29- '4', '5', '6', '7',
30- '8', '9', 'a', 'b',
31- 'c', 'd', 'e', 'f'
32- };
33-
34- int i, err;
35+ int err;
36 FILE *file;
37- char *md5sum_hex;
38- unsigned char md5sum_bin[md5sum_bin_len];
39-
40- md5sum_hex = xcalloc(1, md5sum_hex_len + 1);
41+ unsigned char md5sum_bin[16];
42
43 file = fopen(file_name, "r");
44 if (file == NULL) {
45 opkg_perror(ERROR, "Failed to open file %s", file_name);
46- free(md5sum_hex);
47 return NULL;
48 }
49
50@@ -377,20 +363,12 @@ char *file_md5sum_alloc(const char *file_name)
51 if (err) {
52 opkg_msg(ERROR, "Could't compute md5sum for %s.\n", file_name);
53 fclose(file);
54- free(md5sum_hex);
55 return NULL;
56 }
57
58 fclose(file);
59
60- for (i = 0; i < md5sum_bin_len; i++) {
61- md5sum_hex[i * 2] = bin2hex[md5sum_bin[i] >> 4];
62- md5sum_hex[i * 2 + 1] = bin2hex[md5sum_bin[i] & 0xf];
63- }
64-
65- md5sum_hex[md5sum_hex_len] = '\0';
66-
67- return md5sum_hex;
68+ return md5_to_string(md5sum_bin);
69 }
70
71 #ifdef HAVE_SHA256
72diff --git a/libopkg/md5.c b/libopkg/md5.c
73index d476b8b..bc2b229 100644
74--- a/libopkg/md5.c
75+++ b/libopkg/md5.c
76@@ -30,6 +30,8 @@
77 #include <string.h>
78 #include <sys/types.h>
79
80+#include "string_util.h"
81+
82 #if USE_UNLOCKED_IO
83 #include "unlocked-io.h"
84 #endif
85@@ -431,3 +433,8 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
86 ctx->C = C;
87 ctx->D = D;
88 }
89+
90+char *md5_to_string(const void *md5sum_bin)
91+{
92+ return bin_to_hex(md5sum_bin, 16);
93+}
94diff --git a/libopkg/md5.h b/libopkg/md5.h
95index 01320f5..2a7274d 100644
96--- a/libopkg/md5.h
97+++ b/libopkg/md5.h
98@@ -118,6 +118,9 @@ extern int __md5_stream(FILE * stream, void *resblock) __THROW;
99 extern void *__md5_buffer(const char *buffer, size_t len,
100 void *resblock) __THROW;
101
102+/* Convert a binary md5sum value to an ASCII string. */
103+char *md5_to_string(const void *md5sum_bin);
104+
105 #ifdef __cplusplus
106 }
107 #endif
108--
1091.9.1
110