History

Bgetbe(): return int status.

dhoskin committed 12 years ago

Commit 4ee1ab21 parent c4d55081 file · +10 −8Browse files

Unified · Split

websocket.c+10−8
@@ -165,8 +165,8 @@ testwsversion(const char *vs) · 164 unmodified lines
165165 return 0;
166166 }
167167
168−uvlong
169−Bgetbe(Biobuf *b, int sz)
168+int
169+Bgetbe(Biobuf *b, uvlong *u, int sz)
170170 {
171171 uchar buf[8];
172172 int i;
@@ -175,11 +175,14 @@ Bgetbe(Biobuf *b, int sz) · 2 unmodified lines
175175 if(Bread(b, buf, sz) != sz)
176176 return -1;
177177
178+ /* XXX This should use getbe(). */
179+ //*u = getbe(buf, sz);
178180 x = 0;
179181 for(i = 0; i < sz; ++i)
180182 x |= buf[i] << (8 * (sz - 1 - i));
181183
182− return x;
184+ *u = x;
185+ return 1;
183186 }
184187
185188 int
@@ -242,12 +245,11 @@ recvpkt(Wspkt *pkt, Biobuf *b) · 56 unmodified lines
242245 pkt->n &= 0x7F;
243246
244247 if(pkt->n >= 127){
245− pkt->n = Bgetbe(b, 8);
248+ if(Bgetbe(b, (uvlong *)&pkt->n, 8) != 1)
249+ return -1;
246250 }else if(pkt->n == 126){
247− pkt->n = Bgetbe(b, 2);
248− }
249− if(pkt->n < 0){
250− return -1;
251+ if(Bgetbe(b, (uvlong *)&pkt->n, 2) != 1)
252+ return -1;
251253 }
252254
253255 if(masked){

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t