Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
GNOME
GLib
Commits
c6404e83
Commit
c6404e83
authored
Oct 24, 2008
by
Matthias Clasen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Accept short data
svn path=/trunk/; revision=7625
parent
b616e892
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
1 deletion
+45
-1
ChangeLog
ChangeLog
+7
-0
glib/gchecksum.c
glib/gchecksum.c
+0
-1
tests/checksum-test.c
tests/checksum-test.c
+38
-0
No files found.
ChangeLog
View file @
c6404e83
2008-10-23 Matthias Clasen <mclasen@redhat.com>
* glib/gchecksum.c (g_compute_checksum_for_data): Accept
lengths < 2. Patch by Tommi Komulainen
* tests/checksum-test.c: Add a test for this
2008-10-23 Matthias Clasen <mclasen@redhat.com>
Bug 556921 – gpoll.h breaks hal compilation
...
...
glib/gchecksum.c
View file @
c6404e83
...
...
@@ -1389,7 +1389,6 @@ g_compute_checksum_for_data (GChecksumType checksum_type,
g_return_val_if_fail
(
IS_VALID_TYPE
(
checksum_type
),
NULL
);
g_return_val_if_fail
(
data
!=
NULL
,
NULL
);
g_return_val_if_fail
(
length
>
1
,
NULL
);
checksum
=
g_checksum_new
(
checksum_type
);
if
(
!
checksum
)
...
...
tests/checksum-test.c
View file @
c6404e83
...
...
@@ -617,11 +617,45 @@ test_checksum (GChecksumType checksum_type,
}
}
static
void
test_checksum_string
(
GChecksumType
checksum_type
,
const
gchar
*
type
,
const
gchar
**
sums
)
{
int
length
;
for
(
length
=
0
;
length
<=
FIXED_LEN
;
length
++
)
{
const
char
*
expected
=
sums
[
length
];
char
*
checksum
;
checksum
=
g_compute_checksum_for_string
(
checksum_type
,
FIXED_STR
,
length
);
if
(
strcmp
(
checksum
,
expected
)
!=
0
)
{
g_print
(
"Invalid %s checksum for `%.*s' (length %d):
\n
"
"%s (expecting: %s)
\n
"
,
type
,
length
,
FIXED_STR
,
length
,
checksum
,
expected
);
exit
(
1
);
}
g_free
(
checksum
);
}
}
#define test(type, length) test_checksum (G_CHECKSUM_##type, \
#type, \
type##_sums[length], \
length)
#define test_string(type) test_checksum_string (G_CHECKSUM_##type, \
#type, \
type##_sums)
int
main
(
int
argc
,
char
*
argv
[])
{
...
...
@@ -634,5 +668,9 @@ main (int argc, char *argv[])
test
(
SHA256
,
length
);
}
test_string
(
MD5
);
test_string
(
SHA1
);
test_string
(
SHA256
);
return
EXIT_SUCCESS
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment