projects
/
silc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
9062ad9
)
Fixed length checking.
author
Pekka Riikonen
<priikone@silcnet.org>
Sun, 27 Mar 2005 21:01:31 +0000
(21:01 +0000)
committer
Pekka Riikonen
<priikone@silcnet.org>
Sun, 27 Mar 2005 21:01:31 +0000
(21:01 +0000)
lib/silcutil/silcutf8.c
patch
|
blob
|
history
diff --git
a/lib/silcutil/silcutf8.c
b/lib/silcutil/silcutf8.c
index 4d37c91ef9ce03887253c99c47ca3f849644a256..6c4168c1c43edd4c1802f4489d80cf640004387f 100644
(file)
--- a/
lib/silcutil/silcutf8.c
+++ b/
lib/silcutil/silcutf8.c
@@
-4,7
+4,7
@@
Author: Pekka Riikonen <priikone@silcnet.org>
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2004 Pekka Riikonen
+ Copyright (C) 2004
- 2005
Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-35,8
+35,13
@@
SilcUInt32 silc_utf8_encode(const unsigned char *bin, SilcUInt32 bin_len,
if (!bin || !bin_len)
return 0;
if (!bin || !bin_len)
return 0;
- if (bin_encoding == SILC_STRING_UTF8 ||
- (silc_utf8_valid(bin, bin_len) && bin_len <= utf8_size)) {
+ if (bin_encoding == SILC_STRING_UTF8) {
+ if (!silc_utf8_valid(bin, bin_len))
+ return 0;
+ if (!utf8)
+ return bin_len;
+ if (bin_len > utf8_size)
+ return 0;
memcpy(utf8, bin, bin_len);
return bin_len;
}
memcpy(utf8, bin, bin_len);
return bin_len;
}