• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

コミットメタ情報

リビジョン8d9634346817a65f4ec927f3bc87a2dded7791bf (tree)
日時2021-08-09 10:30:47
作者mirabilos <m@mirb...>
コミッターmirabilos

ログメッセージ

libc/inet/resolv.c: use dn_{comp,expand} for {en,de}code_dotted

Minimal-invasive change: just ifdeffing away the older code.

There is no reason to have two different sets of functions doing
the same thing, one used in half the code and another, doing less
escaping, in the other half; just use one.

Signed-off-by: mirabilos <mirabilos@evolvis.org>

変更サマリ

差分

--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -11,6 +11,7 @@
1111 /*
1212 * Portions Copyright (c) 1985, 1993
1313 * The Regents of the University of California. All rights reserved.
14+ * Portions Copyright © 2021 mirabilos <m@mirbsd.org>
1415 *
1516 * Redistribution and use in source and binary forms, with or without
1617 * modification, are permitted provided that the following conditions
@@ -559,6 +560,9 @@ void __decode_header(unsigned char *data,
559560 the data */
560561 int __encode_dotted(const char *dotted, unsigned char *dest, int maxlen)
561562 {
563+#ifndef WHY_UCLIBC_WHY_DID_YOU_DO_THIS
564+ return (dn_comp(dotted, dest, maxlen, NULL, NULL));
565+#else
562566 unsigned used = 0;
563567
564568 while (dotted && *dotted) {
@@ -587,6 +591,7 @@ int __encode_dotted(const char *dotted, unsigned char *dest, int maxlen)
587591 dest[used++] = 0;
588592
589593 return used;
594+#endif
590595 }
591596 #endif /* L_encoded */
592597
@@ -601,6 +606,9 @@ int __decode_dotted(const unsigned char *packet,
601606 char *dest,
602607 int dest_len)
603608 {
609+#ifndef WHY_UCLIBC_WHY_DID_YOU_DO_THIS
610+ return (dn_expand(packet, packet + packet_len, packet + offset, dest, dest_len));
611+#else
604612 unsigned b;
605613 bool measure = 1;
606614 unsigned total = 0;
@@ -658,6 +666,7 @@ int __decode_dotted(const unsigned char *packet,
658666 DPRINTF("Total decode len = %d\n", total);
659667
660668 return total;
669+#endif
661670 }
662671 #endif /* L_decoded */
663672