| @@ -1,18 +1,6 @@ |
| 1 | /* | | |
| 2 | * This is 9p client and server implementation which aims to be | | |
| 3 | * correct, small and secure. It's the lowest level implementation. | | |
| 4 | * It doesn't have much comments, mostly because it doesn't make | | |
| 5 | * any sense to copy-paste protocol documentation, which | | |
| 6 | * you can read at http://man.cat-v.org/plan_9/5/, see 'intro'. | | |
| 7 | */ | | |
| 8 | #ifdef __plan9__ | | |
| 9 | #include <u.h> | | |
| 10 | #include <libc.h> | | |
| 11 | #else | | |
| 12 | #include <stdint.h> | 1 | #include <stdint.h> |
| 13 | #include <string.h> | 2 | #include <string.h> |
| 14 | #endif | 3 | #include "c9/proto.h" |
| 15 | #include "c9.h" | | |
| 16 | | 4 | |
| 17 | enum | 5 | enum |
| 18 | { | 6 | { |
| @@ -138,7 +126,7 @@ newtag(C9ctx *c, C9ttype type, C9tag *tag) · 119 unmodified lines |
| 138 | } | 126 | } |
| 139 | } | 127 | } |
| 140 | | 128 | |
| 141 | c->error("newtag: no free tags"); | 129 | c->error(c, "newtag: no free tags"); |
| 142 | return C9Etag; | 130 | return C9Etag; |
| 143 | } | 131 | } |
| 144 | | 132 | |
| @@ -148,11 +136,11 @@ freetag(C9ctx *c, C9tag tag) · 3 unmodified lines |
| 148 | if(tag != 0xffff){ | 136 | if(tag != 0xffff){ |
| 149 | uint32_t d = tag / C9tagsbits, m = tag % C9tagsbits; | 137 | uint32_t d = tag / C9tagsbits, m = tag % C9tagsbits; |
| 150 | if(tag >= C9maxtags){ | 138 | if(tag >= C9maxtags){ |
| 151 | c->error("freetag: invalid tag %ud", (uint32_t)tag); | 139 | c->error(c, "freetag: invalid tag %ud", (uint32_t)tag); |
| 152 | return -1; | 140 | return -1; |
| 153 | } | 141 | } |
| 154 | if((c->tags[d] & 1<<m) != 0){ | 142 | if((c->tags[d] & 1<<m) != 0){ |
| 155 | c->error("freetag: double free for tag %ud", (uint32_t)tag); | 143 | c->error(c, "freetag: double free for tag %ud", (uint32_t)tag); |
| 156 | return -1; | 144 | return -1; |
| 157 | } | 145 | } |
| 158 | if(c->lowfreetag > tag) | 146 | if(c->lowfreetag > tag) |
| @@ -168,12 +156,12 @@ T(C9ctx *c, uint32_t size, C9ttype type, C9tag *tag, C9error *err) · 9 unmodified lines |
| 168 | uint8_t *p = NULL; | 156 | uint8_t *p = NULL; |
| 169 | | 157 | |
| 170 | if(size > c->msize-4-1-2){ | 158 | if(size > c->msize-4-1-2){ |
| 171 | c->error("T: invalid size %ud", size); | 159 | c->error(c, "T: invalid size %ud", size); |
| 172 | *err = C9Esize; | 160 | *err = C9Esize; |
| 173 | }else if((*err = newtag(c, type, tag)) == 0){ | 161 | }else if((*err = newtag(c, type, tag)) == 0){ |
| 174 | size += 4+1+2; | 162 | size += 4+1+2; |
| 175 | if((p = c->begin(c, size)) == NULL){ | 163 | if((p = c->begin(c, size)) == NULL){ |
| 176 | c->error("T: no buffer for %ud bytes", size); | 164 | c->error(c, "T: no buffer for %ud bytes", size); |
| 177 | freetag(c, *tag); | 165 | freetag(c, *tag); |
| 178 | *err = C9Ebuf; | 166 | *err = C9Ebuf; |
| 179 | }else{ | 167 | }else{ |
| @@ -193,7 +181,7 @@ c9version(C9ctx *c, C9tag *tag, uint32_t msize) · 13 unmodified lines |
| 193 | C9error err; | 181 | C9error err; |
| 194 | | 182 | |
| 195 | if(msize < C9minmsize){ | 183 | if(msize < C9minmsize){ |
| 196 | c->error("c9version: msize too small: %ud", msize); | 184 | c->error(c, "c9version: msize too small: %ud", msize); |
| 197 | return C9Einit; | 185 | return C9Einit; |
| 198 | } | 186 | } |
| 199 | memset(c->tags, 0xff, sizeof(c->tags)); | 187 | memset(c->tags, 0xff, sizeof(c->tags)); |
| @@ -217,7 +205,7 @@ c9auth(C9ctx *c, C9tag *tag, C9fid afid, const char *uname, const char *aname) · 17 unmodified lines |
| 217 | C9error err; | 205 | C9error err; |
| 218 | | 206 | |
| 219 | if(ulen > C9maxstr || alen > C9maxstr){ | 207 | if(ulen > C9maxstr || alen > C9maxstr){ |
| 220 | c->error("c9auth: string too long: %ud chars", ulen > alen ? ulen : alen); | 208 | c->error(c, "c9auth: string too long: %ud chars", ulen > alen ? ulen : alen); |
| 221 | return C9Estr; | 209 | return C9Estr; |
| 222 | } | 210 | } |
| 223 | if((b = T(c, 4+2+ulen+2+alen, Tauth, tag, &err)) != NULL){ | 211 | if((b = T(c, 4+2+ulen+2+alen, Tauth, tag, &err)) != NULL){ |
| @@ -238,7 +226,7 @@ c9flush(C9ctx *c, C9tag *tag, C9tag oldtag) · 14 unmodified lines |
| 238 | | 226 | |
| 239 | for(i = 0; i < C9maxflush && c->flush[i] != (uint32_t)~0; i++); | 227 | for(i = 0; i < C9maxflush && c->flush[i] != (uint32_t)~0; i++); |
| 240 | if(i == C9maxflush){ | 228 | if(i == C9maxflush){ |
| 241 | c->error("c9flush: no free flush slots"); | 229 | c->error(c, "c9flush: no free flush slots"); |
| 242 | return C9Eflush; | 230 | return C9Eflush; |
| 243 | } | 231 | } |
| 244 | if((b = T(c, 2, Tflush, tag, &err)) != NULL){ | 232 | if((b = T(c, 2, Tflush, tag, &err)) != NULL){ |
| @@ -258,7 +246,7 @@ c9attach(C9ctx *c, C9tag *tag, C9fid fid, C9fid afid, const char *uname, const c · 13 unmodified lines |
| 258 | C9error err; | 246 | C9error err; |
| 259 | | 247 | |
| 260 | if(ulen > C9maxstr || alen > C9maxstr){ | 248 | if(ulen > C9maxstr || alen > C9maxstr){ |
| 261 | c->error("c9attach: string too long: %ud chars", ulen > alen ? ulen : alen); | 249 | c->error(c, "c9attach: string too long: %ud chars", ulen > alen ? ulen : alen); |
| 262 | return C9Estr; | 250 | return C9Estr; |
| 263 | } | 251 | } |
| 264 | if((b = T(c, 4+4+2+ulen+2+alen, Tattach, tag, &err)) != NULL){ | 252 | if((b = T(c, 4+4+2+ulen+2+alen, Tattach, tag, &err)) != NULL){ |
| @@ -282,13 +270,13 @@ c9walk(C9ctx *c, C9tag *tag, C9fid fid, C9fid newfid, const char *path[]) · 17 unmodified lines |
| 282 | for(sz = i = 0; i < (int)sizeof(len)/sizeof(len[0]) && path[i] != NULL; i++){ | 270 | for(sz = i = 0; i < (int)sizeof(len)/sizeof(len[0]) && path[i] != NULL; i++){ |
| 283 | len[i] = safestrlen(path[i]); | 271 | len[i] = safestrlen(path[i]); |
| 284 | if(len[i] == 0 || len[i] > C9maxstr){ | 272 | if(len[i] == 0 || len[i] > C9maxstr){ |
| 285 | c->error("c9walk: invalid path element: %ud chars", len[i]); | 273 | c->error(c, "c9walk: invalid path element: %ud chars", len[i]); |
| 286 | return C9Epath; | 274 | return C9Epath; |
| 287 | } | 275 | } |
| 288 | sz += 2 + len[i]; | 276 | sz += 2 + len[i]; |
| 289 | } | 277 | } |
| 290 | if(path[i] != NULL){ | 278 | if(path[i] != NULL){ |
| 291 | c->error("c9walk: invalid elements !(0 <= %ud <= %ud)", i, C9maxpathel); | 279 | c->error(c, "c9walk: invalid elements !(0 <= %ud <= %ud)", i, C9maxpathel); |
| 292 | return C9Epath; | 280 | return C9Epath; |
| 293 | } | 281 | } |
| 294 | | 282 | |
| @@ -325,7 +313,7 @@ c9create(C9ctx *c, C9tag *tag, C9fid fid, const char *name, uint32_t perm, C9mod · 30 unmodified lines |
| 325 | C9error err; | 313 | C9error err; |
| 326 | | 314 | |
| 327 | if(nlen == 0 || nlen > C9maxstr){ | 315 | if(nlen == 0 || nlen > C9maxstr){ |
| 328 | c->error("c9create: invalid name: %ud chars", nlen); | 316 | c->error(c, "c9create: invalid name: %ud chars", nlen); |
| 329 | return C9Epath; | 317 | return C9Epath; |
| 330 | } | 318 | } |
| 331 | if((b = T(c, 4+2+nlen+4+1, Tcreate, tag, &err)) != NULL){ | 319 | if((b = T(c, 4+2+nlen+4+1, Tcreate, tag, &err)) != NULL){ |
| @@ -423,11 +411,11 @@ c9wstat(C9ctx *c, C9tag *tag, C9fid fid, const C9stat *s) · 91 unmodified lines |
| 423 | C9error err; | 411 | C9error err; |
| 424 | | 412 | |
| 425 | if(nlen == 0 || nlen > C9maxstr){ | 413 | if(nlen == 0 || nlen > C9maxstr){ |
| 426 | c->error("c9wstat: invalid name: %ud chars", nlen); | 414 | c->error(c, "c9wstat: invalid name: %ud chars", nlen); |
| 427 | return C9Epath; | 415 | return C9Epath; |
| 428 | } | 416 | } |
| 429 | if(ulen > C9maxstr || glen > C9maxstr){ | 417 | if(ulen > C9maxstr || glen > C9maxstr){ |
| 430 | c->error("c9wstat: string too long: %ud chars", ulen > glen ? ulen : glen); | 418 | c->error(c, "c9wstat: string too long: %ud chars", ulen > glen ? ulen : glen); |
| 431 | return C9Estr; | 419 | return C9Estr; |
| 432 | } | 420 | } |
| 433 | if((b = T(c, 4+2+2+statsz, Twstat, tag, &err)) != NULL){ | 421 | if((b = T(c, 4+2+2+statsz, Twstat, tag, &err)) != NULL){ |
| @@ -460,20 +448,20 @@ c9proc(C9ctx *c) · 26 unmodified lines |
| 460 | err = -1; | 448 | err = -1; |
| 461 | if((b = c->read(c, 4, &err)) == NULL){ | 449 | if((b = c->read(c, 4, &err)) == NULL){ |
| 462 | if(err != 0) | 450 | if(err != 0) |
| 463 | c->error("c9proc: short read"); | 451 | c->error(c, "c9proc: short read"); |
| 464 | return err == 0 ? 0 : C9Epkt; | 452 | return err == 0 ? 0 : C9Epkt; |
| 465 | } | 453 | } |
| 466 | | 454 | |
| 467 | sz = r32(&b); | 455 | sz = r32(&b); |
| 468 | if(sz < 7 || sz > c->msize){ | 456 | if(sz < 7 || sz > c->msize){ |
| 469 | c->error("c9proc: invalid packet size !(7 <= %ud <= %ud)", sz, c->msize); | 457 | c->error(c, "c9proc: invalid packet size !(7 <= %ud <= %ud)", sz, c->msize); |
| 470 | return C9Epkt; | 458 | return C9Epkt; |
| 471 | } | 459 | } |
| 472 | sz -= 4; | 460 | sz -= 4; |
| 473 | err = -1; | 461 | err = -1; |
| 474 | if((b = c->read(c, sz, &err)) == NULL){ | 462 | if((b = c->read(c, sz, &err)) == NULL){ |
| 475 | if(err != 0) | 463 | if(err != 0) |
| 476 | c->error("c9proc: short read"); | 464 | c->error(c, "c9proc: short read"); |
| 477 | return err == 0 ? 0 : C9Epkt; | 465 | return err == 0 ? 0 : C9Epkt; |
| 478 | } | 466 | } |
| 479 | | 467 | |
| @@ -481,7 +469,7 @@ c9proc(C9ctx *c) · 1 unmodified line |
| 481 | r.tag = r16(&b); | 469 | r.tag = r16(&b); |
| 482 | if(r.type != Rversion){ | 470 | if(r.type != Rversion){ |
| 483 | if(r.tag >= C9maxtags){ | 471 | if(r.tag >= C9maxtags){ |
| 484 | c->error("c9proc: invalid tag %ud", (uint32_t)r.tag); | 472 | c->error(c, "c9proc: invalid tag %ud", (uint32_t)r.tag); |
| 485 | return C9Epkt; | 473 | return C9Epkt; |
| 486 | } | 474 | } |
| 487 | if(freetag(c, r.tag) != 0) | 475 | if(freetag(c, r.tag) != 0) |
| @@ -510,7 +498,7 @@ c9proc(C9ctx *c) · 22 unmodified lines |
| 510 | if(sz < 2 || (cnt = r16(&b))*13 > sz-2) | 498 | if(sz < 2 || (cnt = r16(&b))*13 > sz-2) |
| 511 | goto error; | 499 | goto error; |
| 512 | if(cnt > C9maxpathel){ | 500 | if(cnt > C9maxpathel){ |
| 513 | c->error("c9proc: Rwalk !(%ud <= %ud)", cnt, C9maxpathel); | 501 | c->error(c, "c9proc: Rwalk !(%ud <= %ud)", cnt, C9maxpathel); |
| 514 | return C9Epath; | 502 | return C9Epath; |
| 515 | } | 503 | } |
| 516 | for(i = 0; i < cnt; i++){ | 504 | for(i = 0; i < cnt; i++){ |
| @@ -580,7 +568,7 @@ c9proc(C9ctx *c) · 63 unmodified lines |
| 580 | if(sz < 4+2 || (msize = r32(&b)) < C9minmsize || (cnt = r16(&b)) > sz-4-2) | 568 | if(sz < 4+2 || (msize = r32(&b)) < C9minmsize || (cnt = r16(&b)) > sz-4-2) |
| 581 | goto error; | 569 | goto error; |
| 582 | if(cnt < 6 || memcmp(b, "9P2000", 6) != 0){ | 570 | if(cnt < 6 || memcmp(b, "9P2000", 6) != 0){ |
| 583 | c->error("invalid version"); | 571 | c->error(c, "invalid version"); |
| 584 | return C9Ever; | 572 | return C9Ever; |
| 585 | } | 573 | } |
| 586 | if(msize < c->msize) | 574 | if(msize < c->msize) |
| @@ -593,7 +581,7 @@ c9proc(C9ctx *c) · 6 unmodified lines |
| 593 | } | 581 | } |
| 594 | return 0; | 582 | return 0; |
| 595 | error: | 583 | error: |
| 596 | c->error("c9proc: invalid packet type %ud", r.type); | 584 | c->error(c, "c9proc: invalid packet type %ud", r.type); |
| 597 | return C9Epkt; | 585 | return C9Epkt; |
| 598 | } | 586 | } |
| 599 | | 587 | |
| @@ -633,7 +621,7 @@ c9parsedir(C9ctx *c, C9stat *stat, uint8_t **t, uint32_t *size) · 33 unmodified lines |
| 633 | *t += sz; | 621 | *t += sz; |
| 634 | return 0; | 622 | return 0; |
| 635 | error: | 623 | error: |
| 636 | c->error("c9parsedir: invalid size: size=%ud sz=%ud", *size, sz); | 624 | c->error(c, "c9parsedir: invalid size: size=%ud sz=%ud", *size, sz); |
| 637 | return C9Epkt; | 625 | return C9Epkt; |
| 638 | } | 626 | } |
| 639 | | 627 | |
| @@ -645,12 +633,12 @@ R(C9ctx *c, uint32_t size, C9rtype type, C9tag tag, C9error *err) · 5 unmodified lines |
| 645 | uint8_t *p = NULL; | 633 | uint8_t *p = NULL; |
| 646 | | 634 | |
| 647 | if(size > c->msize-4-1-2){ | 635 | if(size > c->msize-4-1-2){ |
| 648 | c->error("R: invalid size %ud", size); | 636 | c->error(c, "R: invalid size %ud", size); |
| 649 | *err = C9Esize; | 637 | *err = C9Esize; |
| 650 | }else{ | 638 | }else{ |
| 651 | size += 4+1+2; | 639 | size += 4+1+2; |
| 652 | if((p = c->begin(c, size)) == NULL){ | 640 | if((p = c->begin(c, size)) == NULL){ |
| 653 | c->error("R: no buffer for %ud bytes", size); | 641 | c->error(c, "R: no buffer for %ud bytes", size); |
| 654 | *err = C9Ebuf; | 642 | *err = C9Ebuf; |
| 655 | }else{ | 643 | }else{ |
| 656 | *err = 0; | 644 | *err = 0; |
| @@ -699,7 +687,7 @@ s9error(C9ctx *c, C9tag tag, const char *ename) · 42 unmodified lines |
| 699 | C9error err; | 687 | C9error err; |
| 700 | | 688 | |
| 701 | if(len > C9maxstr){ | 689 | if(len > C9maxstr){ |
| 702 | c->error("s9error: invalid ename: %ud chars", len); | 690 | c->error(c, "s9error: invalid ename: %ud chars", len); |
| 703 | return C9Estr; | 691 | return C9Estr; |
| 704 | } | 692 | } |
| 705 | if((b = R(c, 2+len, Rerror, tag, &err)) != NULL){ | 693 | if((b = R(c, 2+len, Rerror, tag, &err)) != NULL){ |
| @@ -743,7 +731,7 @@ s9walk(C9ctx *c, C9tag tag, C9qid *qids[]) · 37 unmodified lines |
| 743 | | 731 | |
| 744 | for(n = 0; n < C9maxpathel && qids[n] != NULL; n++); | 732 | for(n = 0; n < C9maxpathel && qids[n] != NULL; n++); |
| 745 | if(n > C9maxpathel){ | 733 | if(n > C9maxpathel){ |
| 746 | c->error("s9walk: invalid elements !(0 <= %ud <= %ud)", n, C9maxpathel); | 734 | c->error(c, "s9walk: invalid elements !(0 <= %ud <= %ud)", n, C9maxpathel); |
| 747 | return C9Epath; | 735 | return C9Epath; |
| 748 | } | 736 | } |
| 749 | | 737 | |
| @@ -839,13 +827,13 @@ s9readdir(C9ctx *c, C9tag tag, C9stat *st[], int *num, uint64_t *offset, uint32_ · 89 unmodified lines |
| 839 | mulen = safestrlen(s->muid); | 827 | mulen = safestrlen(s->muid); |
| 840 | | 828 | |
| 841 | if(nlen == 0 || nlen > C9maxstr){ | 829 | if(nlen == 0 || nlen > C9maxstr){ |
| 842 | c->error("s9readdir: invalid name: %ud chars", nlen); | 830 | c->error(c, "s9readdir: invalid name: %ud chars", nlen); |
| 843 | return C9Epath; | 831 | return C9Epath; |
| 844 | } | 832 | } |
| 845 | if(ulen > C9maxstr || glen > C9maxstr || mulen > C9maxstr){ | 833 | if(ulen > C9maxstr || glen > C9maxstr || mulen > C9maxstr){ |
| 846 | ulen = ulen > glen ? ulen : glen; | 834 | ulen = ulen > glen ? ulen : glen; |
| 847 | ulen = ulen > mulen ? ulen : mulen; | 835 | ulen = ulen > mulen ? ulen : mulen; |
| 848 | c->error("s9readdir: string too long: %ud chars", ulen); | 836 | c->error(c, "s9readdir: string too long: %ud chars", ulen); |
| 849 | return C9Estr; | 837 | return C9Estr; |
| 850 | } | 838 | } |
| 851 | | 839 | |
| @@ -916,13 +904,13 @@ s9stat(C9ctx *c, C9tag tag, const C9stat *s) · 64 unmodified lines |
| 916 | C9error err; | 904 | C9error err; |
| 917 | | 905 | |
| 918 | if(nlen == 0 || nlen > C9maxstr){ | 906 | if(nlen == 0 || nlen > C9maxstr){ |
| 919 | c->error("s9stat: invalid name: %ud chars", nlen); | 907 | c->error(c, "s9stat: invalid name: %ud chars", nlen); |
| 920 | return C9Epath; | 908 | return C9Epath; |
| 921 | } | 909 | } |
| 922 | if(ulen > C9maxstr || glen > C9maxstr || mulen > C9maxstr){ | 910 | if(ulen > C9maxstr || glen > C9maxstr || mulen > C9maxstr){ |
| 923 | ulen = ulen > glen ? ulen : glen; | 911 | ulen = ulen > glen ? ulen : glen; |
| 924 | ulen = ulen > mulen ? ulen : mulen; | 912 | ulen = ulen > mulen ? ulen : mulen; |
| 925 | c->error("s9stat: string too long: %ud chars", ulen); | 913 | c->error(c, "s9stat: string too long: %ud chars", ulen); |
| 926 | return C9Estr; | 914 | return C9Estr; |
| 927 | } | 915 | } |
| 928 | | 916 | |
| @@ -969,20 +957,20 @@ s9proc(C9ctx *c) · 40 unmodified lines |
| 969 | readerr = -1; | 957 | readerr = -1; |
| 970 | if((b = c->read(c, 4, &readerr)) == NULL){ | 958 | if((b = c->read(c, 4, &readerr)) == NULL){ |
| 971 | if(readerr != 0) | 959 | if(readerr != 0) |
| 972 | c->error("s9proc: short read"); | 960 | c->error(c, "s9proc: short read"); |
| 973 | return readerr == 0 ? 0 : C9Epkt; | 961 | return readerr == 0 ? 0 : C9Epkt; |
| 974 | } | 962 | } |
| 975 | | 963 | |
| 976 | sz = r32(&b); | 964 | sz = r32(&b); |
| 977 | if(sz < 7 || sz > c->msize){ | 965 | if(sz < 7 || sz > c->msize){ |
| 978 | c->error("s9proc: invalid packet size !(7 <= %ud <= %ud)", sz, c->msize); | 966 | c->error(c, "s9proc: invalid packet size !(7 <= %ud <= %ud)", sz, c->msize); |
| 979 | return C9Epkt; | 967 | return C9Epkt; |
| 980 | } | 968 | } |
| 981 | sz -= 4; | 969 | sz -= 4; |
| 982 | readerr = -1; | 970 | readerr = -1; |
| 983 | if((b = c->read(c, sz, &readerr)) == NULL){ | 971 | if((b = c->read(c, sz, &readerr)) == NULL){ |
| 984 | if(readerr != 0) | 972 | if(readerr != 0) |
| 985 | c->error("s9proc: short read"); | 973 | c->error(c, "s9proc: short read"); |
| 986 | return readerr == 0 ? 0 : C9Epkt; | 974 | return readerr == 0 ? 0 : C9Epkt; |
| 987 | } | 975 | } |
| 988 | | 976 | |
| @@ -991,7 +979,7 @@ s9proc(C9ctx *c) · 2 unmodified lines |
| 991 | sz -= 3; | 979 | sz -= 3; |
| 992 | | 980 | |
| 993 | if((c->svflags & Svver) == 0 && t.type != Tversion){ | 981 | if((c->svflags & Svver) == 0 && t.type != Tversion){ |
| 994 | c->error("s9proc: expected Tversion, got %ud", t.type); | 982 | c->error(c, "s9proc: expected Tversion, got %ud", t.type); |
| 995 | return C9Epkt; | 983 | return C9Epkt; |
| 996 | } | 984 | } |
| 997 | | 985 | |
| @@ -1035,7 +1023,7 @@ s9proc(C9ctx *c) · 37 unmodified lines |
| 1035 | t.fid = r32(&b); | 1023 | t.fid = r32(&b); |
| 1036 | t.walk.newfid = r32(&b); | 1024 | t.walk.newfid = r32(&b); |
| 1037 | if((n = r16(&b)) > 16){ | 1025 | if((n = r16(&b)) > 16){ |
| 1038 | c->error("s9proc: Twalk !(%ud <= 16)", n); | 1026 | c->error(c, "s9proc: Twalk !(%ud <= 16)", n); |
| 1039 | return C9Epath; | 1027 | return C9Epath; |
| 1040 | } | 1028 | } |
| 1041 | sz -= 4+4+2; | 1029 | sz -= 4+4+2; |
| @@ -1044,7 +1032,7 @@ s9proc(C9ctx *c) · 2 unmodified lines |
| 1044 | if(sz < 2 || (cnt = r16(&b)) > sz-2) | 1032 | if(sz < 2 || (cnt = r16(&b)) > sz-2) |
| 1045 | goto error; | 1033 | goto error; |
| 1046 | if(cnt < 1){ | 1034 | if(cnt < 1){ |
| 1047 | c->error("s9proc: Twalk invalid element [%ud]", i); | 1035 | c->error(c, "s9proc: Twalk invalid element [%ud]", i); |
| 1048 | return C9Epath; | 1036 | return C9Epath; |
| 1049 | } | 1037 | } |
| 1050 | b[-2] = 0; | 1038 | b[-2] = 0; |
| @@ -1076,7 +1064,7 @@ s9proc(C9ctx *c) · 25 unmodified lines |
| 1076 | if((cnt = r16(&b)) > sz-4) | 1064 | if((cnt = r16(&b)) > sz-4) |
| 1077 | goto error; | 1065 | goto error; |
| 1078 | if((err = c9parsedir(c, &t.wstat, &b, &cnt)) != 0){ | 1066 | if((err = c9parsedir(c, &t.wstat, &b, &cnt)) != 0){ |
| 1079 | c->error("s9proc"); | 1067 | c->error(c, "s9proc"); |
| 1080 | return err; | 1068 | return err; |
| 1081 | } | 1069 | } |
| 1082 | c->t(c, &t); | 1070 | c->t(c, &t); |
| @@ -1111,7 +1099,7 @@ s9proc(C9ctx *c) · 28 unmodified lines |
| 1111 | w32(&b, 0); | 1099 | w32(&b, 0); |
| 1112 | wcs(&b, "unknown", 7); | 1100 | wcs(&b, "unknown", 7); |
| 1113 | err = c->end(c); | 1101 | err = c->end(c); |
| 1114 | c->error("s9proc: invalid version"); | 1102 | c->error(c, "s9proc: invalid version"); |
| 1115 | } | 1103 | } |
| 1116 | return C9Ever; | 1104 | return C9Ever; |
| 1117 | } | 1105 | } |
| @@ -1169,7 +1157,7 @@ s9proc(C9ctx *c) · 51 unmodified lines |
| 1169 | } | 1157 | } |
| 1170 | return 0; | 1158 | return 0; |
| 1171 | error: | 1159 | error: |
| 1172 | c->error("s9proc: invalid packet (type=%ud)", t.type); | 1160 | c->error(c, "s9proc: invalid packet (type=%ud)", t.type); |
| 1173 | return C9Epkt; | 1161 | return C9Epkt; |
| 1174 | } | 1162 | } |
| 1175 | | 1163 | |