%!PS-Adobe-3.0 %%Creator: groff version 1.11 %%CreationDate: Thu Jun 10 17:50:55 1999 %%DocumentNeededResources: font Palatino-Bold %%+ font Times-Roman %%+ font Courier %%+ font Times-Bold %%+ font Times-Italic %%DocumentSuppliedResources: procset grops 1.11 0 %%Pages: 14 %%PageOrder: Ascend %%Orientation: Landscape %%EndComments %%BeginProlog %%BeginResource: procset grops 1.11 0 /setpacking where{ pop currentpacking true setpacking }if /grops 120 dict dup begin /SC 32 def /A/show load def /B{0 SC 3 -1 roll widthshow}bind def /C{0 exch ashow}bind def /D{0 exch 0 SC 5 2 roll awidthshow}bind def /E{0 rmoveto show}bind def /F{0 rmoveto 0 SC 3 -1 roll widthshow}bind def /G{0 rmoveto 0 exch ashow}bind def /H{0 rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def /I{0 exch rmoveto show}bind def /J{0 exch rmoveto 0 SC 3 -1 roll widthshow}bind def /K{0 exch rmoveto 0 exch ashow}bind def /L{0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def /M{rmoveto show}bind def /N{rmoveto 0 SC 3 -1 roll widthshow}bind def /O{rmoveto 0 exch ashow}bind def /P{rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def /Q{moveto show}bind def /R{moveto 0 SC 3 -1 roll widthshow}bind def /S{moveto 0 exch ashow}bind def /T{moveto 0 exch 0 SC 5 2 roll awidthshow}bind def /SF{ findfont exch [exch dup 0 exch 0 exch neg 0 0]makefont dup setfont [exch/setfont cvx]cvx bind def }bind def /MF{ findfont [5 2 roll 0 3 1 roll neg 0 0]makefont dup setfont [exch/setfont cvx]cvx bind def }bind def /level0 0 def /RES 0 def /PL 0 def /LS 0 def /MANUAL{ statusdict begin/manualfeed true store end }bind def /PLG{ gsave newpath clippath pathbbox grestore exch pop add exch pop }bind def /BP{ /level0 save def 1 setlinecap 1 setlinejoin 72 RES div dup scale LS{ 90 rotate }{ 0 PL translate }ifelse 1 -1 scale }bind def /EP{ level0 restore showpage }bind def /DA{ newpath arcn stroke }bind def /SN{ transform .25 sub exch .25 sub exch round .25 add exch round .25 add exch itransform }bind def /DL{ SN moveto SN lineto stroke }bind def /DC{ newpath 0 360 arc closepath }bind def /TM matrix def /DE{ TM currentmatrix pop translate scale newpath 0 0 .5 0 360 arc closepath TM setmatrix }bind def /RC/rcurveto load def /RL/rlineto load def /ST/stroke load def /MT/moveto load def /CL/closepath load def /FL{ currentgray exch setgray fill setgray }bind def /BL/fill load def /LW/setlinewidth load def /RE{ findfont dup maxlength 1 index/FontName known not{1 add}if dict begin { 1 index/FID ne{def}{pop pop}ifelse }forall /Encoding exch def dup/FontName exch def currentdict end definefont pop }bind def /DEFS 0 def /EBEGIN{ moveto DEFS begin }bind def /EEND/end load def /CNT 0 def /level1 0 def /PBEGIN{ /level1 save def translate div 3 1 roll div exch scale neg exch neg exch translate 0 setgray 0 setlinecap 1 setlinewidth 0 setlinejoin 10 setmiterlimit []0 setdash /setstrokeadjust where{ pop false setstrokeadjust }if /setoverprint where{ pop false setoverprint }if newpath /CNT countdictstack def userdict begin /showpage{}def }bind def /PEND{ clear countdictstack CNT sub{end}repeat level1 restore }bind def end def /setpacking where{ pop setpacking }if %%EndResource %%IncludeResource: font Palatino-Bold %%IncludeResource: font Times-Roman %%IncludeResource: font Courier %%IncludeResource: font Times-Bold %%IncludeResource: font Times-Italic grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72 def/PL 792 def/LS true def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron /scaron/zcaron/Ydieresis/trademark/quotesingle/.notdef/.notdef/.notdef /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef /.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent /ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/hyphen /period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon /semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O /P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/circumflex /underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y /z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase/guillemotleft /guillemotright/bullet/florin/fraction/perthousand/dagger/daggerdbl /endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut /dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash /quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen /brokenbar/section/dieresis/copyright/ordfeminine/guilsinglleft /logicalnot/minus/registered/macron/degree/plusminus/twosuperior /threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior /ordmasculine/guilsinglright/onequarter/onehalf/threequarters /questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE /Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex /Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis /multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn /germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla /egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis /eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash /ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]def /Times-Italic@0 ENC0/Times-Italic RE/Times-Bold@0 ENC0/Times-Bold RE /Courier@0 ENC0/Courier RE/Times-Roman@0 ENC0/Times-Roman RE /Palatino-Bold@0 ENC0/Palatino-Bold RE %%EndProlog %%Page: 1 1 %%BeginPageSetup BP %%EndPageSetup /F0 23/Palatino-Bold@0 SF(strlcpy and strlcat)302.758 164 Q (consistent, safe, string copy and concatenation)153.591 256 Q -2.553 (To)319.019 348 S(dd C. Miller)2.553 E()-2.553 E(Theo de Raadt)319.973 417 Q ()268.373 440 Q .012 LW 72.012 504.001 72.012 108.001 DL 108.012 504.001 36 -180.0000 90.0000 DA 273.612 540.001 108.012 540.001 DL 340.005 540.001 273.612 540.001 DL 633.261 540.001 452.019 540.001 DL 684.012 504.001 36 90.0000 0.0000 DA 720.012 108.001 720.012 504.001 DL 684.012 108.001 36 0.0000 -90.0000 DA 108.012 72.001 684.012 72.001 DL 108.012 108.001 36 -90.0000 180.0000 DA/F1 9 /Times-Roman@0 SF -.72(To)342.243 543.001 S(dd C. Miller\255strlcp).72 E 183.492(y/strlcat Jun)-.09 F(10, 1999)2.25 E/F2 14/Courier@0 SF(Slide 1) 704.4 588 Q EP %%Page: 2 2 %%BeginPageSetup BP %%EndPageSetup /F0 23/Palatino-Bold@0 SF(Overview)344.25 118 Q 10.8<8352>119.262 187 S (ationale)-10.8 E 10.8<8357>119.262 233 S(hat')-10.8 E 5.75(sw)-1.265 G (rong with using strncpy/strncat?)-5.75 E 10.8<8348>119.262 279 S (ow do strlcpy/strlcat help?)-10.8 E 10.8<8357>119.262 325 S (hat they don')-10.8 E 5.75(td)-.414 G(o)-5.75 E 10.8<8349>119.262 371 S (mplementation)-10.8 E 10.8<8357>119.262 417 S(ho')-10.8 E 5.75(su) -1.265 G(sing them?)-5.75 E 10.8<8357>119.262 463 S (here to get the code)-10.8 E .012 LW 72.012 504.001 72.012 108.001 DL 108.012 504.001 36 -180.0000 90.0000 DA 273.612 540.001 108.012 540.001 DL 340.005 540.001 273.612 540.001 DL 633.261 540.001 452.019 540.001 DL 684.012 504.001 36 90.0000 0.0000 DA 720.012 108.001 720.012 504.001 DL 684.012 108.001 36 0.0000 -90.0000 DA 108.012 72.001 684.012 72.001 DL 108.012 108.001 36 -90.0000 180.0000 DA/F1 9/Times-Roman@0 SF -.72(To) 342.243 543.001 S(dd C. Miller\255strlcp).72 E 183.492(y/strlcat Jun) -.09 F(10, 1999)2.25 E/F2 14/Courier@0 SF(Slide 2)704.4 588 Q EP %%Page: 3 3 %%BeginPageSetup BP %%EndPageSetup /F0 23/Palatino-Bold@0 SF(Rationale)345.538 118 Q 10.8<8342>119.262 187 S(uf)-10.8 E(fer over\215ows have become trivial to exploit)-.414 E 162.3 227.25 5.75 DC .012 LW ST(Access to source code helps both sides) 180 233 Q 162.3 273.25 5.75 DC ST (Programmers are eradicating strcpy/strcat from)180 279 Q (setuid programs)180 302 Q 162.3 342.25 5.75 DC ST (Need something to easily replace calls to)180 348 Q(strcpy/strcat)180 371 Q 162.3 411.25 5.75 DC ST(strncpy/strncat are not a good match)180 417 Q 72.012 504.001 72.012 108.001 DL 108.012 504.001 36 -180.0000 90.0000 DA 273.612 540.001 108.012 540.001 DL 340.005 540.001 273.612 540.001 DL 633.261 540.001 452.019 540.001 DL 684.012 504.001 36 90.0000 0.0000 DA 720.012 108.001 720.012 504.001 DL 684.012 108.001 36 0.0000 -90.0000 DA 108.012 72.001 684.012 72.001 DL 108.012 108.001 36 -90.0000 180.0000 DA/F1 9/Times-Roman@0 SF -.72(To)342.243 543.001 S (dd C. Miller\255strlcp).72 E 183.492(y/strlcat Jun)-.09 F(10, 1999)2.25 E/F2 14/Courier@0 SF(Slide 3)704.4 588 Q EP %%Page: 4 4 %%BeginPageSetup BP %%EndPageSetup /F0 23/Palatino-Bold@0 SF(Why not use strncpy/strncat?)244.729 118 Q (strncpy/strncat not well suited to size-bounded)108 187 Q(operations) 119.5 210 Q 10.8<834e>119.262 279 S (on-intuitive API \(lots of people get it wrong\))-10.8 E 10.8<8349> 119.262 325 S(nconsistent use of the length/size parameter)-10.8 E 10.8 <8344>119.262 371 S(if)-10.8 E(\214cult to detect truncation)-.414 E 10.8<834e>119.262 417 S(UL \214ll in strncpy\( \) has a hidden cost) -10.8 E .012 LW 72.012 504.001 72.012 108.001 DL 108.012 504.001 36 -180.0000 90.0000 DA 273.612 540.001 108.012 540.001 DL 340.005 540.001 273.612 540.001 DL 633.261 540.001 452.019 540.001 DL 684.012 504.001 36 90.0000 0.0000 DA 720.012 108.001 720.012 504.001 DL 684.012 108.001 36 0.0000 -90.0000 DA 108.012 72.001 684.012 72.001 DL 108.012 108.001 36 -90.0000 180.0000 DA/F1 9/Times-Roman@0 SF -.72(To)342.243 543.001 S (dd C. Miller\255strlcp).72 E 183.492(y/strlcat Jun)-.09 F(10, 1999)2.25 E/F2 14/Courier@0 SF(Slide 4)704.4 588 Q EP %%Page: 5 5 %%BeginPageSetup BP %%EndPageSetup /F0 23/Palatino-Bold@0 SF(Why Not \(continued\))284.852 118 Q 10.8<8373> 119.262 187 S(trncpy/strncat API non-intuitive)-10.8 E 162.3 227.25 5.75 DC .012 LW ST(Found lots of misuse when auditing OpenBSD)180 233 Q 162.3 273.25 5.75 DC ST(Many programmers assume strncpy\( \))180 279 Q (guarantees NUL-termination--it does not)180 302 Q 162.3 342.25 5.75 DC ST(The programmer must clear the last byte)180 348 Q (manually in case strlen\(src\) >= sizeof\(dst\))180 371 Q 72.012 504.001 72.012 108.001 DL 108.012 504.001 36 -180.0000 90.0000 DA 273.612 540.001 108.012 540.001 DL 340.005 540.001 273.612 540.001 DL 633.261 540.001 452.019 540.001 DL 684.012 504.001 36 90.0000 0.0000 DA 720.012 108.001 720.012 504.001 DL 684.012 108.001 36 0.0000 -90.0000 DA 108.012 72.001 684.012 72.001 DL 108.012 108.001 36 -90.0000 180.0000 DA /F1 9/Times-Roman@0 SF -.72(To)342.243 543.001 S(dd C. Miller\255strlcp) .72 E 183.492(y/strlcat Jun)-.09 F(10, 1999)2.25 E/F2 14/Courier@0 SF (Slide 5)704.4 588 Q EP %%Page: 6 6 %%BeginPageSetup BP %%EndPageSetup /F0 23/Palatino-Bold@0 SF(Why Not \(continued\))284.852 118 Q 10.8<834c> 119.262 187 S(ength parameter used inconsistently)-10.8 E 162.3 227.25 5.75 DC .012 LW ST(For strncpy\( \) it is sizeof\(dest\))180 233 Q (For strncat\( \) it is sizeof\(dest\) - 1)180 256 Q 162.3 296.25 5.75 DC ST(Length parameter for strncat\( \) must usually be)180 302 Q (computed--often incorrectly Eg:)180 325 Q (strncat\(path, \214le, sizeof\(path\) - strlen\(path\) - 1\);)180 348 Q 10.8<8344>119.262 394 S(if)-10.8 E(\214cult to detect truncation)-.414 E 162.3 434.25 5.75 DC ST(For strncpy)180 440 Q 5.75(,m)-2.116 G (ust check strlen\(src\))-5.75 E 162.3 480.25 5.75 DC ST (For strncat, must save the old length of dst)180 486 Q 72.012 504.001 72.012 108.001 DL 108.012 504.001 36 -180.0000 90.0000 DA 273.612 540.001 108.012 540.001 DL 340.005 540.001 273.612 540.001 DL 633.261 540.001 452.019 540.001 DL 684.012 504.001 36 90.0000 0.0000 DA 720.012 108.001 720.012 504.001 DL 684.012 108.001 36 0.0000 -90.0000 DA 108.012 72.001 684.012 72.001 DL 108.012 108.001 36 -90.0000 180.0000 DA/F1 9 /Times-Roman@0 SF -.72(To)342.243 543.001 S(dd C. Miller\255strlcp).72 E 183.492(y/strlcat Jun)-.09 F(10, 1999)2.25 E/F2 14/Courier@0 SF(Slide 6) 704.4 588 Q EP %%Page: 7 7 %%BeginPageSetup BP %%EndPageSetup /F0 23/Palatino-Bold@0 SF(NUL \214ll in strncpy\( \) has a hidden cost) 193.531 118 Q 10.8<8346>119.262 187 S (ound strncpy\( \) of a small string into a 1K buf)-10.8 E(fer)-.414 E (to be 3-5 times slower than strcpy\( \) depending on)144 210 Q (the CPU.)144 233 Q 162.3 273.25 5.75 DC .012 LW ST (This is the worst case scenario since you are)180 279 Q (clearing many more bytes than you copy--but it)180 302 Q (is also a very common case.)180 325 Q(Consider copying a)11.5 E (pathname info a buf)180 348 Q(fer of size MAXP)-.414 E -2.116(AT)-1.702 G(HLEN.)2.116 E 162.3 388.25 5.75 DC ST (Probably not just the cost of clearing bytes, but)180 394 Q(ef)180 417 Q(fectively fushing the data cache.)-.414 E 10.8<8373>119.262 463 S (trlcpy\( \) performs almost as well as strcpy\( \))-10.8 E 72.012 504.001 72.012 108.001 DL 108.012 504.001 36 -180.0000 90.0000 DA 273.612 540.001 108.012 540.001 DL 340.005 540.001 273.612 540.001 DL 633.261 540.001 452.019 540.001 DL 684.012 504.001 36 90.0000 0.0000 DA 720.012 108.001 720.012 504.001 DL 684.012 108.001 36 0.0000 -90.0000 DA 108.012 72.001 684.012 72.001 DL 108.012 108.001 36 -90.0000 180.0000 DA /F1 9/Times-Roman@0 SF -.72(To)342.243 543.001 S(dd C. Miller\255strlcp) .72 E 183.492(y/strlcat Jun)-.09 F(10, 1999)2.25 E/F2 14/Courier@0 SF (Slide 7)704.4 588 Q EP %%Page: 8 8 %%BeginPageSetup BP %%EndPageSetup /F0 23/Palatino-Bold@0 SF(How do strlcpy/strlcat help?)248.57 118 Q (size_t strlcat \(char *dst, const char *src, size_t siz\))108 187 Q (size_t strlcpy \(char *dst, const char *src, size_t siz\))108 210 Q 10.8<8343>119.262 256 S(onsistent, unambiguous interface)-10.8 E 162.3 296.25 5.75 DC .012 LW ST(Always NUL-terminate the destination)180 302 Q 162.3 342.25 5.75 DC ST (Size parameter is the full size of the destination)180 348 Q(\(Eg:)180 371 Q/F1 23/Courier@0 SF(sizeof\(buf\))5.75 E F0(\))A 162.3 411.25 5.75 DC ST(Neither function zero-\214lls the destination)180 417 Q (\(except for the \214nal NUL to terminate the)180 440 Q(string\).)180 463 Q 72.012 504.001 72.012 108.001 DL 108.012 504.001 36 -180.0000 90.0000 DA 273.612 540.001 108.012 540.001 DL 340.005 540.001 273.612 540.001 DL 633.261 540.001 452.019 540.001 DL 684.012 504.001 36 90.0000 0.0000 DA 720.012 108.001 720.012 504.001 DL 684.012 108.001 36 0.0000 -90.0000 DA 108.012 72.001 684.012 72.001 DL 108.012 108.001 36 -90.0000 180.0000 DA/F2 9/Times-Roman@0 SF -.72(To)342.243 543.001 S (dd C. Miller\255strlcp).72 E 183.492(y/strlcat Jun)-.09 F(10, 1999)2.25 E/F3 14/Courier@0 SF(Slide 8)704.4 588 Q EP %%Page: 9 9 %%BeginPageSetup BP %%EndPageSetup /F0 23/Palatino-Bold@0 SF(How do strlcpy/strlcat help? \(continued\)) 185.021 118 Q 10.8<8342>119.262 187 S (oth functions provide a useful return value)-10.8 E 162.3 227.25 5.75 DC .012 LW ST(Return the length of the dst string as if there)180 233 Q (was in\214nite space)180 256 Q 162.3 296.25 5.75 DC ST (For strlcpy\( \) this is just strlen\(src\))180 302 Q 162.3 342.25 5.75 DC ST(For strlcat\( \) this is strlen\(src\) + strlen\(orig_dst\))180 348 Q 162.3 388.25 5.75 DC ST (Similar to BSD and C9X snprintf\( \) return value)180 394 Q 162.3 434.25 5.75 DC ST(Makes checking for truncation easy)180 440 Q (If rval >= siz, truncation occurred)180 463 Q 72.012 504.001 72.012 108.001 DL 108.012 504.001 36 -180.0000 90.0000 DA 273.612 540.001 108.012 540.001 DL 340.005 540.001 273.612 540.001 DL 633.261 540.001 452.019 540.001 DL 684.012 504.001 36 90.0000 0.0000 DA 720.012 108.001 720.012 504.001 DL 684.012 108.001 36 0.0000 -90.0000 DA 108.012 72.001 684.012 72.001 DL 108.012 108.001 36 -90.0000 180.0000 DA/F1 9 /Times-Roman@0 SF -.72(To)342.243 543.001 S(dd C. Miller\255strlcp).72 E 183.492(y/strlcat Jun)-.09 F(10, 1999)2.25 E/F2 14/Courier@0 SF(Slide 9) 704.4 588 Q EP %%Page: 10 10 %%BeginPageSetup BP %%EndPageSetup /F0 23/Palatino-Bold@0 SF(What strlcpy/strlcat are not...)246.327 118 Q 10.8<8354>119.262 187 S (hey are not an attempt to somehow "\214x" string)-10.8 E(handling in C) 144 210 Q 162.3 250.25 5.75 DC .012 LW ST(If that')180 256 Q 5.75(sw) -1.265 G(hat you want there are other options)-5.75 E(\(including C++\)) 180 279 Q 10.8<8354>119.262 325 S(hey only operate on normal C strings) -10.8 E 162.3 365.25 5.75 DC ST (Source string must end in a NUL since we)180 371 Q (traverse the entire string)180 394 Q 162.3 434.25 5.75 DC ST (Not usable for strings in)180 440 Q/F1 23/Courier@0 SF(struct utmp)5.75 E/F2 23/Times-Bold@0 SF -.575(fo)5.75 G(r).575 E(example)180 463 Q 72.012 504.001 72.012 108.001 DL 108.012 504.001 36 -180.0000 90.0000 DA 273.612 540.001 108.012 540.001 DL 340.005 540.001 273.612 540.001 DL 633.261 540.001 452.019 540.001 DL 684.012 504.001 36 90.0000 0.0000 DA 720.012 108.001 720.012 504.001 DL 684.012 108.001 36 0.0000 -90.0000 DA 108.012 72.001 684.012 72.001 DL 108.012 108.001 36 -90.0000 180.0000 DA /F3 9/Times-Roman@0 SF -.72(To)342.243 543.001 S(dd C. Miller\255strlcp) .72 E 183.492(y/strlcat Jun)-.09 F(10, 1999)2.25 E/F4 14/Courier@0 SF (Slide 10)696 588 Q EP %%Page: 11 11 %%BeginPageSetup BP %%EndPageSetup /F0 23/Times-Bold@0 SF(Simplest implementation of strlcpy\(\))216.807 118 Q/F1 23/Courier@0 SF(size_t strlcpy\(char *dst, const char *src,)108 187 Q(size_t siz\))163.2 210 Q({)108 233 Q(size_t n;)144 256 Q (size_t slen = strlen\(src\);)144 279 Q(if \(siz\) {)144 325 Q (if \(\(n = MIN\(slen, siz - 1\)\)\))180 348 Q(memcpy\(dst, src, n\);) 216 371 Q(dst[n] = '\\0';)180 394 Q(})144 417 Q(return\(slen\);)144 440 Q(})108 463 Q .012 LW 72.012 504.001 72.012 108.001 DL 108.012 504.001 36 -180.0000 90.0000 DA 273.612 540.001 108.012 540.001 DL 340.005 540.001 273.612 540.001 DL 633.261 540.001 452.019 540.001 DL 684.012 504.001 36 90.0000 0.0000 DA 720.012 108.001 720.012 504.001 DL 684.012 108.001 36 0.0000 -90.0000 DA 108.012 72.001 684.012 72.001 DL 108.012 108.001 36 -90.0000 180.0000 DA/F2 9/Times-Roman@0 SF -.72(To)342.243 543.001 S(dd C. Miller\255strlcp).72 E 183.492(y/strlcat Jun)-.09 F (10, 1999)2.25 E/F3 14/Courier@0 SF(Slide 11)696 588 Q EP %%Page: 12 12 %%BeginPageSetup BP %%EndPageSetup /F0 23/Times-Bold@0 SF(Simplest implementation of strlcat\(\))219.371 118 Q/F1 23/Courier@0 SF(size_t strlcat\(char *dst, const char *src,)108 187 Q(size_t siz\))163.2 210 Q({)108 233 Q(size_t dlen = strlen\(dst\);) 144 256 Q(/* Make sure siz is sane */)144 302 Q(if \(dlen < siz - 1\)) 144 325 Q(return\(dlen + strlcpy\(dst + dlen,)180 348 Q (src, siz - dlen\)\);)235.2 371 Q(else)144 394 Q (return\(dlen + strlen\(src\)\);)180 417 Q(})108 440 Q .012 LW 72.012 504.001 72.012 108.001 DL 108.012 504.001 36 -180.0000 90.0000 DA 273.612 540.001 108.012 540.001 DL 340.005 540.001 273.612 540.001 DL 633.261 540.001 452.019 540.001 DL 684.012 504.001 36 90.0000 0.0000 DA 720.012 108.001 720.012 504.001 DL 684.012 108.001 36 0.0000 -90.0000 DA 108.012 72.001 684.012 72.001 DL 108.012 108.001 36 -90.0000 180.0000 DA /F2 9/Times-Roman@0 SF -.72(To)342.243 543.001 S(dd C. Miller\255strlcp) .72 E 183.492(y/strlcat Jun)-.09 F(10, 1999)2.25 E/F3 14/Courier@0 SF (Slide 12)696 588 Q EP %%Page: 13 13 %%BeginPageSetup BP %%EndPageSetup /F0 23/Times-Bold@0 SF(Who')258.425 118 Q 5.75(su)-.851 G (sing strlcpy/strlcat?)-5.75 E 10.8<834f>125.15 187 S(perating Systems) -10.8 E 162.3 227.25 5.75 DC .012 LW ST/F1 23/Palatino-Bold@0 SF (First shipped with OpenBSD 2.4)180 233 Q 162.3 273.25 5.75 DC ST (Approved for inclusion in a future release of)180 279 Q(Solaris)180 302 Q 10.8<8341>119.262 348 S(pplications)-10.8 E 162.3 388.25 5.75 DC ST (Used by the)180 394 Q/F2 23/Times-Italic@0 SF -.23(rs)5.75 G(ync).23 E F1(package)5.75 E 162.3 434.25 5.75 DC ST (Simple implementation makes it easy to check for)180 440 Q (the function in a con\214gure script and provide)180 463 Q (it if needed)180 486 Q 72.012 504.001 72.012 108.001 DL 108.012 504.001 36 -180.0000 90.0000 DA 273.612 540.001 108.012 540.001 DL 340.005 540.001 273.612 540.001 DL 633.261 540.001 452.019 540.001 DL 684.012 504.001 36 90.0000 0.0000 DA 720.012 108.001 720.012 504.001 DL 684.012 108.001 36 0.0000 -90.0000 DA 108.012 72.001 684.012 72.001 DL 108.012 108.001 36 -90.0000 180.0000 DA/F3 9/Times-Roman@0 SF -.72(To)342.243 543.001 S(dd C. Miller\255strlcp).72 E 183.492(y/strlcat Jun)-.09 F (10, 1999)2.25 E/F4 14/Courier@0 SF(Slide 13)696 588 Q EP %%Page: 14 14 %%BeginPageSetup BP %%EndPageSetup /F0 23/Palatino-Bold@0 SF(Where to get the code)282.92 118 Q 10.8<834f> 119.262 187 S(penBSD 2.5 CD')-10.8 E(s)-1.265 E 10.8<8341>119.262 233 S (ny OpenBSD ftp mirror)-10.8 E 162.3 273.25 5.75 DC .012 LW ST (pub/OpenBSD/lib/libc/string/strlcpy)180 279 Q(.c)-2.116 E 162.3 296.25 5.75 DC ST(pub/OpenBSD/lib/libc/string/strlcat.c)180 302 Q 162.3 319.25 5.75 DC ST(pub/OpenBSD/lib/libc/string/strlcpy)180 325 Q(.3)-2.116 E 10.8<833c>119.262 394 S -2.553(To)-10.8 G(dd.Miller@cs.colorado.edu>) 2.553 E 10.8<833c>119.262 440 S(deraadt@openbsd.org>)-10.8 E 72.012 504.001 72.012 108.001 DL 108.012 504.001 36 -180.0000 90.0000 DA 273.612 540.001 108.012 540.001 DL 340.005 540.001 273.612 540.001 DL 633.261 540.001 452.019 540.001 DL 684.012 504.001 36 90.0000 0.0000 DA 720.012 108.001 720.012 504.001 DL 684.012 108.001 36 0.0000 -90.0000 DA 108.012 72.001 684.012 72.001 DL 108.012 108.001 36 -90.0000 180.0000 DA /F1 9/Times-Roman@0 SF -.72(To)342.243 543.001 S(dd C. Miller\255strlcp) .72 E 183.492(y/strlcat Jun)-.09 F(10, 1999)2.25 E/F2 14/Courier@0 SF (Slide 14)696 588 Q EP %%Trailer end %%EOF